/* ── Custom overrides on top of Bootstrap 5 ── */

:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --brand-light: #eef2ff;
  --sidebar-w: 250px;
  --topbar-h: 60px;
  --bottom-nav-h: 62px;
}

/* ── Auth ── */
#auth-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-card {
  width: 100%; max-width: 420px;
  border-radius: 20px; border: none;
  box-shadow: 0 25px 70px rgba(0,0,0,.25);
}
.auth-logo { font-size: 1.8rem; font-weight: 800; color: var(--brand); letter-spacing: -.03em; }
.auth-logo span { color: #6366f1; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: #0f172a; position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 300;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-logo {
  padding: 18px 20px; font-size: 1.25rem; font-weight: 800;
  color: #fff; letter-spacing: -.02em; border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: space-between;
}
.logo-text { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; color: #fff; white-space: nowrap; }
.logo-accent { color: #818cf8; }
.sidebar-close-btn {
  background: none; border: none; color: #94a3b8; font-size: 1.1rem;
  cursor: pointer; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.sidebar-close-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  color: #94a3b8; font-size: .875rem; border-radius: 10px; cursor: pointer;
  margin-bottom: 2px; transition: all .15s; border: none; background: none; width: 100%;
  text-align: left;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.active { color: #fff; background: rgba(99,102,241,.3); font-weight: 500; }
.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.07);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #4f46e5;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem; flex-shrink: 0;
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 299; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Hamburger ── */
.hamburger-btn {
  background: none; border: none; color: #0f172a; font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px; border-radius: 8px; line-height: 1;
}
.hamburger-btn:hover { background: #f1f5f9; }

/* ── Main layout ── */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; background: #f8fafc; }
.topbar {
  background: #fff; border-bottom: 1px solid #e2e8f0;
  padding: 0 24px; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar h5 { font-weight: 700; color: #0f172a; margin: 0; font-size: 1rem; }
.page-body { padding: 24px; }

/* ── Mobile bottom nav ── */
.mobile-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h); background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex; z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.mob-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; border: none; background: none;
  color: #94a3b8; font-size: .62rem; font-weight: 500; cursor: pointer;
  transition: color .15s; padding: 6px 4px;
}
.mob-nav-item i { font-size: 1.25rem; line-height: 1; }
.mob-nav-item.active { color: var(--brand); }
.mob-nav-item:hover { color: var(--brand); }

/* ── Stat cards ── */
.stat-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 20px; position: relative; overflow: hidden;
}
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin-top: 4px; }
.stat-card .stat-change { font-size: .8rem; margin-top: 8px; }

/* ── Tables ── */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table > thead > tr > th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: #64748b; background: #f8fafc; font-weight: 600; border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px; white-space: nowrap;
}
.table > tbody > tr > td { padding: 13px 16px; vertical-align: middle; border-color: #f1f5f9; }
.table-hover > tbody > tr:hover > td { background: #f8fafc; }

/* ── Badges ── */
.badge-draft    { background: #f1f5f9 !important; color: #475569 !important; }
.badge-scheduled{ background: #fef9c3 !important; color: #854d0e !important; }
.badge-sending  { background: #dbeafe !important; color: #1d4ed8 !important; }
.badge-sent     { background: #dcfce7 !important; color: #166534 !important; }
.badge-paused   { background: #fee2e2 !important; color: #991b1b !important; }
.badge-active   { background: #dcfce7 !important; color: #166534 !important; }
.badge-inactive { background: #f1f5f9 !important; color: #475569 !important; }
.badge-admin    { background: #ede9fe !important; color: #5b21b6 !important; }
.badge { font-size: .75rem; font-weight: 500; padding: 4px 10px; border-radius: 20px; }

/* ── Card tweaks ── */
.card { border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.card-header { background: #fff; border-bottom: 1px solid #f1f5f9; padding: 14px 18px; border-radius: 14px 14px 0 0 !important; }
.card-header h5, .card-header h6 { margin: 0; font-weight: 700; color: #0f172a; }

/* ── Buttons ── */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn { border-radius: 8px; font-size: .875rem; font-weight: 500; }
.btn-sm { font-size: .8rem; padding: 5px 12px; }

/* ── Progress bar ── */
.progress { height: 8px; border-radius: 8px; background: #e2e8f0; }
.progress-bar { background: var(--brand); border-radius: 8px; }

/* ── Contact list sidebar items ── */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: .875rem;
  margin-bottom: 3px; transition: all .15s;
}
.list-item:hover { background: #f1f5f9; }
.list-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

/* ── Editor toolbar ── */
.editor-toolbar {
  display: flex; gap: 5px; flex-wrap: wrap;
  padding: 8px 10px; background: #f8fafc;
  border: 1px solid #dee2e6; border-bottom: none; border-radius: 8px 8px 0 0;
}
.editor-toolbar button {
  padding: 3px 10px; font-size: .78rem; border: 1px solid #dee2e6;
  background: #fff; border-radius: 5px; cursor: pointer; color: #374151;
}
.editor-toolbar button:hover { background: #e9ecef; }
.editor-area { border-radius: 0 0 8px 8px !important; font-family: monospace; font-size: .875rem; }

/* ── Template / QS editor wrapper ── */
.tpl-editor-wrap { border: 1px solid #dee2e6; border-radius: 10px; overflow: hidden; }
.tpl-editor-tabs {
  display: flex; align-items: center; flex-wrap: wrap;
  background: #f1f5f9; border-bottom: 1px solid #dee2e6; padding: 0 8px; gap: 2px;
}
.tpl-tab {
  padding: 9px 16px; font-size: .82rem; font-weight: 500;
  border: none; background: transparent; color: #64748b; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
  white-space: nowrap;
}
.tpl-tab:hover { color: #4f46e5; background: #e8eaf6; border-radius: 6px 6px 0 0; }
.tpl-tab.active { color: #4f46e5; border-bottom-color: #4f46e5; background: #fff; border-radius: 6px 6px 0 0; font-weight: 600; }
.tpl-tab-actions {
  margin-left: auto; display: flex; gap: 4px; align-items: center;
  padding: 6px 0; flex-wrap: wrap;
}
.tpl-action-btn {
  padding: 4px 9px; font-size: .72rem; border: 1px solid #cbd5e1;
  background: #fff; border-radius: 5px; cursor: pointer; color: #475569;
  transition: all .15s; white-space: nowrap;
}
.tpl-action-btn:hover { background: #eef2ff; border-color: #4f46e5; color: #4f46e5; }
.tpl-editor-body { background: #fff; }

/* ── Quill inside editors ── */
#t-quill-editor, #qs-quill-editor { min-height: 280px; }
.tpl-editor-body .ql-toolbar.ql-snow { border-left: none; border-right: none; border-top: none; background: #f8fafc; border-radius: 0; }
.tpl-editor-body .ql-container.ql-snow { border: none; }
.tpl-editor-body .ql-editor { min-height: 260px; padding: 16px 20px; font-family: Arial, sans-serif; font-size: 14px; }
.tpl-editor-body .ql-editor img { max-width: 100%; height: auto; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 20px; color: #94a3b8; }
.empty-state svg { width: 52px; height: 52px; margin-bottom: 14px; opacity: .35; }
.empty-state h6 { color: #475569; font-weight: 600; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 80px; right: 16px; z-index: 9999; }
.toast { min-width: 260px; border: none; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }

/* ── Modal ── */
.modal-content { border: none; border-radius: 16px; box-shadow: 0 25px 80px rgba(0,0,0,.2); }
.modal-header { border-bottom: 1px solid #f1f5f9; padding: 18px 20px; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top: 1px solid #f1f5f9; padding: 14px 20px; }
.modal-title { font-weight: 700; font-size: 1rem; }

/* ── Misc ── */
.hidden { display: none !important; }
.page { animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
.text-brand { color: var(--brand) !important; }
.bg-brand-light { background: var(--brand-light) !important; }
.webhook-box {
  background: #0f172a; color: #7dd3fc; padding: 14px 16px;
  border-radius: 10px; font-family: monospace; font-size: .82rem; word-break: break-all;
}

/* ════════════════════════════════════════
   RESPONSIVE — Tablet (< 992px / lg)
   ════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; padding-bottom: calc(var(--bottom-nav-h) + 16px); }
  .topbar { padding: 0 16px; }
  .toast-container { bottom: calc(var(--bottom-nav-h) + 12px); right: 12px; }
}

/* ════════════════════════════════════════
   RESPONSIVE — Mobile (< 768px / md)
   ════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .page-body { padding: 12px; padding-bottom: calc(var(--bottom-nav-h) + 12px); }

  /* Modal full screen on mobile */
  .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
  }
  .modal-dialog-centered { align-items: flex-end !important; }
  .modal-content {
    border-radius: 20px 20px 0 0 !important;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* Editor tabs wrap cleanly */
  .tpl-tab-actions { margin-left: 0; width: 100%; padding: 4px 0 6px; border-top: 1px solid #e2e8f0; }
  .tpl-editor-tabs { padding: 0 6px; }

  /* Card padding tighter */
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }

  /* Topbar title shorter */
  .topbar h5 { font-size: .92rem; }

  /* Table cells tighter */
  .table > thead > tr > th,
  .table > tbody > tr > td { padding: 10px 10px; }

  /* Auth card full width */
  .auth-card { border-radius: 16px; }
}

/* ════════════════════════════════════════
   Desktop — hide bottom nav & hamburger
   ════════════════════════════════════════ */
@media (min-width: 992px) {
  .mobile-bottom-nav { display: none !important; }
  .hamburger-btn { display: none !important; }
  .sidebar-close-btn { display: none !important; }
}

/* ════════════════════════════════════════
   TABLE → CARD STACK on mobile
   ════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }

  .table-stack tbody tr {
    display: block;
    margin: 0 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    overflow: hidden;
  }

  .table-stack tbody tr:hover td { background: transparent; }

  .table-stack td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    font-size: .85rem;
    gap: 8px;
  }

  .table-stack td:last-child { border-bottom: none; }

  .table-stack td[data-label]::before {
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    flex-shrink: 0;
    min-width: 80px;
  }

  /* td with no data-label (like delete button) stays right-aligned */
  .table-stack td:not([data-label]) {
    justify-content: flex-end;
    padding: 8px 14px;
  }

  /* Empty-state colspan cell — override flex so it centres properly */
  .table-stack td .empty-state {
    width: 100%;
  }
  .table-stack tr:has(.empty-state) {
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .table-stack tr:has(.empty-state) td {
    display: block;
    text-align: center;
    padding: 0;
    border: none;
  }

  /* Fix progress bar width in stacked view */
  .table-stack .progress { min-width: 80px; }
}
