/* Admin polish — All Customers + Settings (CR-0001-b palette) */

/* ===== All Customers page ===== */
.cv-title {
  font-family: 'Inter', 'Poppins', sans-serif;
  font-weight: 700; font-size: 30px;
  margin: 0 0 6px; color: #0B1220;
  letter-spacing: -0.03em;
}
.cv-title em { color: #F97316; font-style: normal; font-weight: 700; }
.cv-subtitle {
  color: #4B5563; margin: 0 0 24px; font-size: 14px;
  line-height: 1.55;
}
.cv-card {
  background: #FFFFFF;
  border: 1px solid #EEF1F4;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(11,18,32,0.04), 0 1px 1px rgba(11,18,32,0.03);
  transition: box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.cv-empty-state {
  padding: 64px 32px; text-align: center; color: #4B5563;
}
.cv-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.cv-table thead th {
  padding: 14px 18px;
  font-family: 'Inter', sans-serif; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: #4B5563; font-weight: 600; text-align: left;
  border-bottom: 1px solid #E5E7EB;
  background: #F7F8FA;
}
.cv-row {
  transition: background 0.14s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.14s cubic-bezier(0.16, 1, 0.3, 1);
  border-bottom: 1px solid #EEF1F4;
}
.cv-row-last { border-bottom: 0; }
.cv-row:hover { background: #F7F8FA; box-shadow: inset 2px 0 0 #3661E8; }
.cv-td { padding: 18px 16px; vertical-align: top; }
.cv-email-link {
  color: #3661E8; text-decoration: none; font-weight: 600; font-size: 14px;
  transition: color 0.15s ease;
}
.cv-email-link:hover { text-decoration: underline; color: #1D4ED8; }
.cv-site-pill {
  display: inline-block;
  background: #F7F8FA; border: 1px solid #E5E7EB;
  color: #111827;
  padding: 4px 11px; border-radius: 999px;
  font-family: 'Inter', sans-serif; font-size: 12px;
  font-weight: 500;
  text-decoration: none; margin: 0 6px 4px 0;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.cv-site-pill:hover { background: #F2F6FF; border-color: #3661E8; color: #1D4ED8; }
.cv-empty { color: #94A3B8; font-style: italic; }
.cv-expires { font-weight: 500; color: #111827; font-size: 14px; }
.cv-dev-tag {
  font-size: 10px; color: #6B7280;
  font-family: 'Inter', sans-serif; letter-spacing: 0.06em;
  background: #EEF1F4; padding: 2px 7px; border-radius: 4px;
  margin-left: 5px; font-weight: 600;
  text-transform: uppercase;
}
.cv-billed { color: #94A3B8; font-size: 11px; margin-top: 4px; }
.cv-status { margin-top: 8px; }
.cv-pill { font-weight: 500; font-size: 12px; }
.cv-pill-ok { color: #16A34A; }
.cv-pill-pending { color: #D97706; }
.cv-pill-fail { color: #DC2626; }
.cv-pill-cancel { color: #DC2626; }
.cv-usage { font-size: 13px; color: #111827; margin-top: 5px; }
.cv-usage:first-child { margin-top: 0; }
.cv-usage-lbl { color: #4B5563; }
.cv-soft { color: #94A3B8; }
.cv-actions { white-space: nowrap; }
.cv-btn {
  padding: 7px 14px; background: #FFFFFF;
  border: 1px solid #E5E7EB;
  color: #111827; border-radius: 8px;
  font-family: inherit; font-size: 13px; cursor: pointer;
  font-weight: 500; margin-right: 6px;
  box-shadow: 0 1px 1.5px rgba(11,18,32,0.04);
}
.cv-btn:hover { background: #F7F8FA; border-color: rgba(11,18,32,0.18); }
.cv-sub-cancel { border-color: #FECACA; color: #DC2626; }
.cv-sub-cancel:hover { background: #FEF2F2; border-color: #FCA5A5; }
.cv-sub-reactivate { border-color: #BBF7D0; color: #16A34A; }
.cv-sub-reactivate:hover { background: #F0FDF4; border-color: #86EFAC; }
.cv-confirming.cv-sub-cancel { background: #DC2626 !important; color: #fff !important; border-color: #DC2626 !important; }
.cv-confirming.cv-sub-reactivate { background: #16A34A !important; color: #fff !important; border-color: #16A34A !important; }

/* ===== Settings page polish ===== */
#panel-admin-settings > .card {
  background: #FFFFFF !important;
  border: 1px solid #EEF1F4 !important;
  border-radius: 14px !important;
  padding: 26px !important;
  margin-bottom: 16px !important;
  box-shadow: 0 1px 2px rgba(11,18,32,0.04), 0 1px 1px rgba(11,18,32,0.03) !important;
}
#panel-admin-settings > .card h3 {
  margin: 0 0 8px !important;
  font-family: 'Inter', 'Poppins', sans-serif !important;
  font-weight: 600 !important;
  font-size: 18px !important;
  color: #0B1220 !important;
  letter-spacing: -0.02em !important;
}
#panel-admin-settings > .card h3 em {
  color: #F97316 !important;
  font-style: normal !important;
  font-weight: 600 !important;
}
#panel-admin-settings > .card .help,
#panel-admin-settings > .card p.help {
  color: #4B5563 !important;
  font-size: 13px !important;
  margin: 0 0 18px !important;
  line-height: 1.6;
}
#panel-admin-settings input[type="text"],
#panel-admin-settings input[type="email"],
#panel-admin-settings input[type="password"],
#panel-admin-settings input[type="tel"],
#panel-admin-settings input[type="number"],
#panel-admin-settings #tpl-subject {
  width: 100% !important;
  padding: 11px 13px !important;
  border: 1px solid #E5E7EB !important;
  background: #FFFFFF !important;
  color: #111827 !important;
  border-radius: 9px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 14px !important;
  box-sizing: border-box !important;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.22s ease, background 0.18s ease;
}
#panel-admin-settings input:hover,
#panel-admin-settings textarea:hover,
#panel-admin-settings #tpl-subject:hover {
  border-color: #CBD2DC !important;
}
#panel-admin-settings input:focus,
#panel-admin-settings textarea:focus,
#panel-admin-settings #tpl-subject:focus {
  border-color: #3661E8 !important;
  box-shadow: 0 0 0 4px rgba(54,97,232,0.10) !important;
}
#panel-admin-settings label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: #111827;
  font-weight: 600;
  margin: 10px 0 6px;
  letter-spacing: 0.005em;
}
#tpl-html {
  min-height: 240px !important;
  border-radius: 10px !important;
  border: 1px solid #E5E7EB !important;
  background: #F7F8FA !important;
  color: #111827 !important;
  font-family: 'Geist Mono', monospace !important;
  font-size: 13px !important;
  padding: 12px !important;
  width: 100% !important;
  box-sizing: border-box;
  line-height: 1.55;
}
.stt-nav {
  margin-bottom: 24px !important;
  border-bottom: 1px solid #E5E7EB !important;
}
.stt-btn {
  background: transparent !important;
  border: 0 !important;
  padding: 12px 18px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 14px !important;
  cursor: pointer !important;
  color: #4B5563 !important;
  border-bottom: 2px solid transparent !important;
  font-weight: 500 !important;
  letter-spacing: -0.003em !important;
  margin-bottom: -1px !important;
}
.stt-btn:hover {
  color: #0B1220 !important;
  background: transparent !important;
}
.stt-btn.active {
  color: #0B1220 !important;
  border-bottom-color: #3661E8 !important;
  font-weight: 600 !important;
}

/* ============================================================ */
/* ===== CR-0001-b ADMIN POLISH (Notion/Linear-grade feel) ===== */
/* ============================================================ */

/* Sidebar — smoother transitions, subtle link interactions */
.sidebar {
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-link {
  transition: background 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
              padding-left 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: transparent;
  transition: background 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-link:hover { transform: translateX(2px); }
.sidebar-link.active::before { background: #F97316; box-shadow: 0 0 12px rgba(249,115,22,0.45); }

/* Topbar — smoother sign-out button */
.topbar .topbar-signout { transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.15s ease; }
.topbar .topbar-signout:active { transform: translateY(1px); }

/* Cards — subtle elevation + hover lift */
.card,
.cv-card,
#panel-admin-settings > .card {
  transition: box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover,
#panel-admin-settings > .card:hover {
  box-shadow: 0 14px 30px -16px rgba(11, 18, 32, 0.10), 0 4px 12px -6px rgba(11, 18, 32, 0.06);
  border-color: #E5E7EB;
}
.cv-card:hover {
  box-shadow: 0 14px 30px -16px rgba(11, 18, 32, 0.10), 0 4px 12px -6px rgba(11, 18, 32, 0.06);
  border-color: #E5E7EB;
}

/* Buttons — premium press feedback */
.btn,
.cv-btn,
.stt-btn {
  transition: background 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.18s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.12s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.cv-btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 10px -3px rgba(11, 18, 32, 0.10); }
.cv-btn:not(:disabled):active { transform: translateY(0); }

/* Form inputs — premium focus state with smooth animation */
.field input,
.field select,
.field textarea,
#panel-admin-settings input[type="text"],
#panel-admin-settings input[type="email"],
#panel-admin-settings input[type="password"],
#panel-admin-settings input[type="tel"],
#panel-admin-settings input[type="number"],
#panel-admin-settings textarea,
.auth-form input {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

/* Table rows — clean hover highlight with accent rail */
table tbody tr,
.cv-row {
  transition: background 0.14s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}
.card table tbody tr:hover,
#panel-admin-settings table tbody tr:hover {
  background: #F7F8FA;
  box-shadow: inset 2px 0 0 #3661E8;
}

/* Modal animations — fade backdrop + slide-up modal */
@keyframes lw-backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes lw-modal-pop {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-backdrop.visible {
  animation: lw-backdrop-fade 0.2s ease;
}
.modal-backdrop.visible .modal {
  animation: lw-modal-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Toast smoother slide-in */
.toast { transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

/* Layout thumb hover */
.layout-thumb { transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease; }
.layout-thumb:hover { transform: translateY(-2px); border-color: #2563EB; }

/* Switch — smoother */
.switch .slider, .switch .slider::before { transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1); }

/* Site pills hover */
.cv-site-pill, .badge { transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease; }

/* ============================================================ */
/* ===== HAMBURGER + SIDEBAR BACKDROP (mobile shell) =========== */
/* ============================================================ */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  width: 44px; height: 44px;
  border-radius: 10px;
  cursor: pointer;
  color: #0F172A;
  margin-right: auto;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hamburger:hover { background: #F8FAFC; border-color: #E2E8F0; }
.hamburger:active { background: #F1F5F9; }
.hamburger svg { width: 22px; height: 22px; display: block; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}
body.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* ============================================================ */
/* ===== BOTTOM NAV (mobile only) ============================= */
/* ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid rgba(11, 18, 32, 0.06);
  z-index: 80;
  box-shadow: 0 -10px 30px -14px rgba(11, 18, 32, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.bottom-nav button {
  background: transparent;
  border: 0;
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #475569;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}
.bottom-nav button:active { background: #F1F5F9; }
.bottom-nav button.active { color: #2563EB; }
.bottom-nav button.active svg { stroke: #2563EB; }
.bottom-nav svg {
  width: 22px; height: 22px;
  stroke: #475569;
  transition: stroke 0.15s ease;
}

/* ============================================================ */
/* ===== SCROLL-TO-TOP FAB ==================================== */
/* ============================================================ */
.scroll-top {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FB8533 0%, #EA580C 100%);
  color: #fff;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.18s ease,
              box-shadow 0.22s ease;
  z-index: 70;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 8px 22px rgba(249, 115, 22, 0.40);
  -webkit-tap-highlight-color: transparent;
}
.scroll-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.scroll-top:hover {
  background: #EA580C;
  box-shadow: 0 8px 22px rgba(249, 115, 22, 0.5);
}
.scroll-top:active { transform: scale(0.95); }
.scroll-top svg { width: 20px; height: 20px; display: block; }

/* ============================================================ */
/* ===== MOBILE OVERHAUL (slide-in sidebar, full-width main) === */
/* ============================================================ */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }

  /* App shell — single column, no horizontal scroll */
  #app.visible {
    grid-template-columns: 1fr !important;
    display: block !important;
  }

  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    min-height: 100vh !important;
    flex-direction: column !important;
    padding: 22px 0 24px !important;
    align-items: stretch !important;
    gap: 0 !important;
    overflow-y: auto;
    overflow-x: hidden !important;
    z-index: 95;
    transform: translateX(-100%);
    border-right: 1px solid #1E293B !important;
    border-bottom: 0 !important;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.3);
  }

  .sidebar-logo {
    padding: 0 22px 18px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    margin-bottom: 14px !important;
    font-size: 20px !important;
    flex-shrink: 0;
  }
  .sidebar-section {
    padding: 10px 16px 4px !important;
    flex-shrink: 0 !important;
  }
  .sidebar-section-title { display: block !important; }
  .sidebar-link {
    padding: 12px 14px !important;
    font-size: 15px !important;
    min-height: 44px;
    flex-shrink: 0 !important;
  }
  .sidebar-link .icon { display: inline-block !important; }
  .sidebar-account { display: block !important; }

  /* Hamburger visible on mobile (only when authed) */
  body.lw-authed .hamburger { display: inline-flex; }

  /* Topbar: hamburger left, sign-out right */
  .topbar {
    padding: 10px 14px !important;
    gap: 10px !important;
    justify-content: flex-start !important;
    z-index: 70 !important;
  }
  .topbar .topbar-email {
    display: none !important;
  }
  .topbar .topbar-signout {
    padding: 9px 14px !important;
    font-size: 13px !important;
    min-height: 40px;
  }

  /* Main inner padding tighter on mobile */
  .main { padding-bottom: 72px; }
  .main-inner { padding: 20px 14px !important; }

  /* Page header on mobile */
  .page-header { margin-bottom: 18px !important; gap: 12px !important; }
  .page-header h1 { font-size: 22px !important; }
  .page-header > div + div {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .page-header select,
  .page-header input[type="text"] {
    flex: 1;
    min-width: 0 !important;
  }

  /* Cards — tighter padding */
  .card { padding: 16px !important; }
  #panel-admin-settings > .card { padding: 18px !important; }

  /* Cards that contain tables get horizontal scroll */
  .card, .cv-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .card > table,
  .cv-card > .cv-table,
  .cv-card > table {
    min-width: 580px;
  }

  /* Form rows stack on mobile */
  .field-row { grid-template-columns: 1fr !important; }

  /* Touch-friendly inputs — at least 44px tall, 16px text to prevent iOS zoom */
  .field input,
  .field select,
  .field textarea,
  #panel-admin-settings input[type="text"],
  #panel-admin-settings input[type="email"],
  #panel-admin-settings input[type="password"],
  #panel-admin-settings input[type="tel"],
  #panel-admin-settings input[type="number"],
  .auth-form input {
    font-size: 16px !important;
    padding: 12px 14px !important;
    min-height: 44px;
  }

  /* Buttons larger on mobile */
  .btn { min-height: 40px; padding: 10px 16px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; font-size: 12px; }
  .cv-btn { min-height: 40px; padding: 9px 14px; }

  /* Modals: full-screen feel on mobile (slide up from bottom) */
  .modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal {
    border-radius: 14px 14px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh !important;
    padding: 22px 18px 28px !important;
    margin: 0 !important;
  }
  .modal h2 { font-size: 19px !important; }
  .modal-actions {
    flex-direction: column-reverse !important;
    gap: 10px !important;
    margin-top: 18px !important;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  @keyframes lw-modal-pop {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Auth screen — comfortable on small screens */
  .auth-card {
    padding: 28px 22px !important;
    border-radius: 12px;
  }

  /* Bottom nav visible (only when authed) */
  body.lw-authed .bottom-nav { display: block; }

  /* Scroll-to-top: sit above bottom nav */
  .scroll-top {
    bottom: 78px;
    right: 16px;
  }

  /* Customer detail header on mobile */
  #customer-detail-content h1 { font-size: 24px !important; }

  /* Email composer toolbar wraps */
  .fmt-toolbar { flex-wrap: wrap; }

  /* All Customers table: keep table layout but allow horizontal scroll */
  .cv-table { min-width: 640px; }
  .cv-td { padding: 14px 12px !important; }
}

/* Even tighter on phones */
@media (max-width: 420px) {
  .page-header h1 { font-size: 20px !important; }
  .main-inner { padding: 16px 12px !important; }
  .card { padding: 14px !important; }
  .scroll-top { width: 42px; height: 42px; }
  .bottom-nav button { font-size: 10.5px; }
}

/* Reduced motion — respect user preference */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-link, .card, .btn, .cv-btn,
  .modal-backdrop, .modal, .toast, .scroll-top,
  .layout-thumb, table tbody tr {
    transition: none !important;
    animation: none !important;
  }
}
