@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --admin-primary: #009325;
  --admin-primary-dark: #007a1e;
  --admin-primary-soft: rgba(0, 147, 37, 0.12);
  --admin-sidebar: #0f172a;
  --admin-sidebar-hover: #1e293b;
  --admin-topbar: #0f172a;
  --admin-bg: #f1f5f9;
  --admin-surface: #ffffff;
  --admin-border: #e2e8f0;
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-danger: #dc2626;
  --admin-warning: #d97706;
  --admin-success: #009325;
  --admin-info: #0284c8;
  --admin-radius: 10px;
  --admin-radius-sm: 6px;
  --admin-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --offcanvas-width: 260px;
  --topNavbarHeight: 56px;
  --admin-font: "Inter", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body.admin-body {
  margin: 0;
  font-family: var(--admin-font);
  background: var(--admin-bg);
  color: var(--admin-text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar ---- */
.admin-topbar {
  background: var(--admin-topbar) !important;
  min-height: var(--topNavbarHeight);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  z-index: 1040;
}

.admin-topbar .navbar-brand {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: #fff !important;
}

.admin-topbar .nav-link,
.admin-topbar .btn {
  color: #e2e8f0 !important;
}

.admin-topbar .dropdown-menu {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  box-shadow: var(--admin-shadow);
}

/* ---- Sidebar ---- */
.sidebar-nav {
  width: var(--offcanvas-width) !important;
  background: var(--admin-sidebar) !important;
  color: #cbd5e1 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-nav .offcanvas-body {
  padding: 0.75rem 0.65rem 1.5rem;
  overflow-y: auto;
}

.sidebar-nav .nav-section-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.85rem 0.85rem 0.35rem;
}

.sidebar-nav .navbar-nav .nav-link {
  color: #cbd5e1 !important;
  border-radius: var(--admin-radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.sidebar-nav .navbar-nav .nav-link:hover,
.sidebar-nav .navbar-nav .nav-link:focus {
  background: var(--admin-sidebar-hover);
  color: #fff !important;
}

.sidebar-nav .navbar-nav .nav-link i {
  width: 1.15rem;
  text-align: center;
  opacity: 0.9;
}

.sidebar-nav .sidebar-link .right-icon {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.sidebar-nav .sidebar-link[aria-expanded="true"] .right-icon {
  transform: rotate(180deg);
}

.sidebar-nav .collapse .nav-link {
  font-size: 0.84rem;
  font-weight: 400;
  padding-left: 2.1rem;
  color: #94a3b8 !important;
}

.sidebar-nav .collapse .nav-link:hover {
  color: #fff !important;
}

.sidebar-nav .nav-item.mb-nav {
  margin-bottom: 0.2rem;
}

@media (min-width: 992px) {
  body.admin-body {
    overflow: auto !important;
  }

  .offcanvas-backdrop.show {
    display: none !important;
  }

  /* Permanent desktop sidebar — override Bootstrap offcanvas hide state */
  .sidebar-nav.offcanvas,
  .sidebar-nav.offcanvas.show,
  .sidebar-nav.offcanvas .offcanvas-body,
  .sidebar-nav.offcanvas .navbar-nav,
  .sidebar-nav.offcanvas .nav-link,
  .sidebar-nav.offcanvas .nav-section-label {
    visibility: visible !important;
    transform: none !important;
  }

  .sidebar-nav.offcanvas {
    position: fixed !important;
    top: var(--topNavbarHeight) !important;
    left: 0 !important;
    bottom: 0 !important;
    height: calc(100vh - var(--topNavbarHeight)) !important;
    z-index: 1030;
    pointer-events: auto;
    box-shadow: none;
  }

  main.admin-main,
  main.mt-5.pt-3,
  .admin-content {
    margin-left: var(--offcanvas-width);
  }
}

/* ---- Main content ---- */
main.admin-main,
main.mt-5.pt-3 {
  padding-top: calc(var(--topNavbarHeight) + 1.25rem) !important;
  padding-bottom: 2rem;
  min-height: 100vh;
}

.admin-page {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1,
.page-header h3,
.page-header .page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--admin-text);
}

.page-header .page-subtitle {
  margin: 0.2rem 0 0;
  color: var(--admin-muted);
  font-size: 0.9rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: flex-end;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--admin-shadow);
}

.filter-bar .filter-field {
  display: flex;
  flex-direction: column;
  flex: 1 1 200px;
  min-width: 200px;
  max-width: 100%;
}

.filter-bar .filter-field--wide {
  flex: 1 1 240px;
  min-width: 240px;
}

.filter-bar .filter-field .form-select,
.filter-bar .filter-field .form-control {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  pointer-events: auto !important;
  position: relative;
  z-index: 5;
  background-color: #fff;
}

.report-filters .report-filter-input {
  pointer-events: auto !important;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  z-index: 6;
}

.filter-bar .filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  flex: 1 1 220px;
}

@media (max-width: 767.98px) {
  .filter-bar .filter-field,
  .filter-bar .filter-field--wide,
  .filter-bar .filter-actions {
    flex: 1 1 100%;
    min-width: 100%;
  }
}

.filter-bar .form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--admin-muted);
  margin-bottom: 0.25rem;
}

/* Prevent Bootstrap rows inside filter-bar from collapsing controls */
.filter-bar > .row {
  width: 100%;
  margin: 0;
}

.data-card,
.card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  overflow: hidden;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--admin-border);
  padding: 0.9rem 1.1rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.card-body {
  padding: 1.1rem;
}

/* Settings media previews (Home Banner, etc.) */
.media-preview {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  background: #f8fafc;
  overflow: hidden;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-preview img {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

/* Match customer app hero: full-bleed cover, height 310, bottom radius 30 */
.media-preview--hero {
  aspect-ratio: 390 / 310;
  min-height: 0;
  width: 100%;
  max-width: 390px;
  margin-inline: auto;
  border-radius: 0 0 30px 30px;
  background: #0f172a;
}

.media-preview--hero img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

/* Match customer app promo strip: full width × 96px → ~3.75:1, BoxFit.cover */
.media-preview--strip {
  aspect-ratio: 3.75 / 1;
  min-height: 0;
  width: 100%;
}

.media-preview--strip img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

.app-frame-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

/* Exact app-visible window: clip everything outside */
.crop-viewport {
  position: relative;
  overflow: hidden;
  background: #0f172a;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  margin-inline: auto;
}

.crop-viewport:active {
  cursor: grabbing;
}

.crop-viewport--hero {
  width: 390px;
  height: 310px;
  max-width: 100%;
  border-radius: 0 0 30px 30px;
}

/* Keep ratio if phone-narrow admin: scale down but preserve 390:310 */
@media (max-width: 420px) {
  .crop-viewport--hero {
    width: 100%;
    height: auto;
    aspect-ratio: 390 / 310;
  }
}

.crop-viewport--strip {
  width: 390px;
  height: 104px;
  max-width: 100%;
  border-radius: 12px;
}

.crop-viewport--bottom {
  width: 390px;
  max-width: 100%;
  border-radius: 0;
  /* height set inline from CMS bottomPromoHeight */
  clip-path: polygon(
    0% 10px,
    2.78% 0%, 5.56% 10px,
    8.33% 0%, 11.11% 10px,
    13.89% 0%, 16.67% 10px,
    19.44% 0%, 22.22% 10px,
    25% 0%, 27.78% 10px,
    30.56% 0%, 33.33% 10px,
    36.11% 0%, 38.89% 10px,
    41.67% 0%, 44.44% 10px,
    47.22% 0%, 50% 10px,
    52.78% 0%, 55.56% 10px,
    58.33% 0%, 61.11% 10px,
    63.89% 0%, 66.67% 10px,
    69.44% 0%, 72.22% 10px,
    75% 0%, 77.78% 10px,
    80.56% 0%, 83.33% 10px,
    86.11% 0%, 88.89% 10px,
    91.67% 0%, 94.44% 10px,
    97.22% 0%, 100% 10px,
    100% 100%,
    0% 100%
  );
}

.home-content-card .card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

@media (max-width: 420px) {
  .crop-viewport--strip {
    width: 100%;
    height: auto;
    aspect-ratio: 3.75 / 1;
  }
}

.crop-viewport--empty {
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-viewport__empty {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.crop-layer {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.crop-layer img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-stage {
  position: relative;
  width: 100%;
  max-width: 390px;
  margin-inline: auto;
  overflow: hidden;
  background: #0f172a;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-stage--hero {
  aspect-ratio: 390 / 310;
  border-radius: 0 0 30px 30px;
}

.crop-stage--strip {
  aspect-ratio: 3.75 / 1;
  border-radius: 12px;
  max-width: 100%;
}

.crop-stage--empty {
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-stage__empty {
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.crop-stage__chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0));
  pointer-events: none;
}

.crop-controls .form-range {
  cursor: pointer;
}

.media-preview--empty {
  padding: 1.25rem;
  border-style: dashed;
}

.table th[scope="row"] {
  background: transparent !important;
  color: var(--admin-muted) !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.85rem;
  font-weight: 500 !important;
}

.table {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.table thead.table-dark,
.table thead th {
  background: #0f172a !important;
  color: #f8fafc !important;
  border-color: #1e293b !important;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.table > :not(caption) > * > * {
  padding: 0.75rem 0.9rem;
  vertical-align: middle;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #f8fafc;
}

.table-responsive {
  border-radius: 0 0 var(--admin-radius) var(--admin-radius);
}

/* ---- Buttons ---- */
.btn-primary,
.btn-success {
  background: var(--admin-primary) !important;
  border-color: var(--admin-primary) !important;
  color: #fff !important;
  font-weight: 600;
  border-radius: var(--admin-radius-sm);
}

.btn-primary:hover,
.btn-success:hover {
  background: var(--admin-primary-dark) !important;
  border-color: var(--admin-primary-dark) !important;
}

.btn-outline-primary {
  color: var(--admin-primary) !important;
  border-color: var(--admin-primary) !important;
}

.btn-outline-primary:hover {
  background: var(--admin-primary-soft) !important;
}

.btn-secondary {
  border-radius: var(--admin-radius-sm);
}

/* ---- Badges / status ---- */
.status-badge,
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

.status-badge--active,
.badge-status.active {
  background: rgba(0, 147, 37, 0.12);
  color: #007a1e;
}

.status-badge--inactive,
.badge-status.inactive {
  background: rgba(100, 116, 139, 0.15);
  color: #475569;
}

.status-badge--pending {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
}

.status-badge--danger {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

/* ---- Metric cards ---- */
.metric-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--admin-shadow);
  height: 100%;
}

.metric-card .metric-label {
  color: var(--admin-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-card .metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.35rem;
  color: var(--admin-text);
}

/* ---- Forms / modals ---- */
.form-control,
.form-select {
  border-radius: var(--admin-radius-sm);
  border-color: var(--admin-border);
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 0.2rem var(--admin-primary-soft);
}

.modal-content {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
}

.modal-header {
  border-bottom: 1px solid var(--admin-border);
}

.modal-footer {
  border-top: 1px solid var(--admin-border);
}

.nav-tabs .nav-link {
  color: var(--admin-text);
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: none;
}

.nav-tabs .nav-link:hover {
  color: var(--admin-primary);
  border-color: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--admin-primary) !important;
  background: #fff;
  border-color: var(--admin-border) var(--admin-border) #fff;
}

/* Offer modal: keep selects readable (avoid 1-letter-wide collapse) */
#addOffersModal .form-select,
#addOffersModal .form-control {
  width: 100%;
  min-width: 0;
}

#addOffersModal label.form-label {
  font-weight: 600;
  color: var(--admin-text);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--admin-muted);
}

.alert {
  border-radius: var(--admin-radius-sm);
}

/* Kill old broken positioning if leftover CSS loads */
.modal-content.custom-modal,
.custom-modal .modal-content {
  top: auto !important;
  left: auto !important;
  width: auto !important;
}

/* Bootstrap primary override to brand green */
.bg-primary {
  background-color: var(--admin-primary) !important;
}

.text-primary {
  color: var(--admin-primary) !important;
}

@media (max-width: 991.98px) {
  main.admin-main,
  main.mt-5.pt-3,
  .admin-content {
    margin-left: 0 !important;
  }
}
