/* ===================================================
   MailTracker SaaS — Premium Dark Theme
   Author: Saraf Tech Lab LLP
=================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────── */
:root {
  --sidebar-w: 220px;

  --bg-base:      #080c14;
  --bg-card:      rgba(15, 22, 38, 0.75);
  --bg-card-alt:  rgba(19, 28, 48, 0.9);
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);

  --accent:       #6366f1;
  --accent-dark:  #4f46e5;
  --cyan:         #06b6d4;
  --emerald:      #10b981;
  --amber:        #f59e0b;
  --rose:         #f43f5e;

  --txt:          #f1f5f9;
  --txt-muted:    #8b97b0;
  --txt-subtle:   #4b5675;

  --radius-sm:    7px;
  --radius-md:    11px;
  --radius-lg:    16px;

  --glow:         0 0 22px rgba(99,102,241,0.22);
  --shadow-card:  0 4px 24px rgba(0,0,0,0.35);
  --ease:         all 0.18s ease;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ── Body / Root ───────────────────────────────── */
html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--txt);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%,   rgba(99,102,241,.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(6,182,212,.09)  0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════
   SHELL LAYOUT — sidebar + main side-by-side
   Uses CSS grid so there is ZERO gap between them
═══════════════════════════════════════════════ */
.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;                    /* footer never scrolls off */
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 26, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
}

/* scrollable top zone */
.sidebar-top {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.85rem 0.75rem;
  scrollbar-width: none;
}
.sidebar-top::-webkit-scrollbar { display: none; }

/* brand */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.75rem;
  padding: 0 0.25rem;
}
.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow);
  flex-shrink: 0;
}
.brand-icon i { color: #fff; font-size: 0.9rem; }

/* nav section label */
.sidebar-nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--txt-subtle);
  padding: 0 0.4rem;
  margin-bottom: 0.4rem;
}

/* nav menu */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--txt-muted);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: var(--ease);
}
.nav-link i {
  width: 16px;
  text-align: center;
  font-size: 0.82rem;
  flex-shrink: 0;
  opacity: .75;
}
.nav-link:hover {
  color: var(--txt);
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.07);
}
.nav-link:hover i { opacity: 1; }
.nav-link.active {
  color: #fff;
  background: rgba(99,102,241,0.16);
  border-color: rgba(99,102,241,0.32);
  box-shadow: 0 0 10px rgba(99,102,241,0.12);
}
.nav-link.active i { opacity: 1; color: #a5b4fc; }

/* divider */
.sidebar-divider {
  height: 1px;
  margin: 0;
  background: var(--border);
  flex-shrink: 0;
}

/* pinned footer */
.sidebar-footer-group {
  flex-shrink: 0;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* timezone picker */
.tz-picker label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-subtle);
  margin-bottom: 0.35rem;
}
.tz-picker label i { color: var(--accent); }
.tz-picker select {
  width: 100%;
  padding: 0.38rem 0.55rem;
  background: rgba(10,15,26,0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  font-size: 0.775rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--ease);
}
.tz-picker select:focus {
  border-color: rgba(99,102,241,0.5);
}

/* user profile row */
.user-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-avatar i { color: #fff; font-size: 0.72rem; }
.user-info { flex: 1; overflow: hidden; }
.user-name {
  font-size: 0.8rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-email {
  font-size: 0.68rem; color: var(--txt-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-logout {
  color: var(--txt-muted);
  font-size: 1rem;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: var(--ease);
}
.btn-logout:hover { color: var(--rose); background: rgba(244,63,94,0.12); }

/* ── Main Content ───────────────────────────────── */
.main-content {
  grid-column: 2;
  padding: 1.75rem 2rem;
  min-height: 100vh;
  overflow-x: hidden;
}

/* top-bar row (page title + action button) */
.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}
.page-title p {
  font-size: 0.85rem;
  color: var(--txt-muted);
  margin-top: 0.2rem;
}

/* ── Stats Grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--ease);
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99,102,241,0.35);
  box-shadow: var(--glow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-icon.purple  { background: rgba(99,102,241,0.18); color: #a5b4fc; }
.stat-icon.cyan    { background: rgba(6,182,212,0.18);  color: #67e8f9; }
.stat-icon.emerald { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.stat-icon.amber   { background: rgba(245,158,11,0.18); color: #fde047; }
.stat-info h3 { font-size: 1.55rem; font-weight: 700; color: #fff; line-height: 1.1; }
.stat-info p  { font-size: 0.8rem;  color: var(--txt-muted); margin-top: 0.2rem; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}
.card-title { font-size: 1rem; font-weight: 600; color: #fff; }

/* dashboard 2-col grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ── Tables ─────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  padding: 0.7rem 0.9rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.8rem 0.9rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--txt);
  vertical-align: middle;
}
td.time-col { white-space: nowrap; font-size: 0.8rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.018); }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-purple  { background: rgba(99,102,241,.18); color: #a5b4fc; border: 1px solid rgba(99,102,241,.3); }
.badge-cyan    { background: rgba(6,182,212,.18);  color: #67e8f9; border: 1px solid rgba(6,182,212,.3); }
.badge-emerald { background: rgba(16,185,129,.18); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.badge-amber   { background: rgba(245,158,11,.18); color: #fde047; border: 1px solid rgba(245,158,11,.3); }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.45); }
.btn-secondary {
  background: rgba(255,255,255,0.07);
  color: var(--txt);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.13); }
.btn-sm { padding: 0.38rem 0.8rem; font-size: 0.78rem; }

/* ── Form Controls ───────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--txt-muted); margin-bottom: 0.4rem; }
.form-input, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: rgba(10,16,30,.65);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: var(--ease);
}
.form-input:focus, .form-select:focus {
  border-color: rgba(99,102,241,0.55);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-select { cursor: pointer; }

/* ── Code Boxes ──────────────────────────────────── */
.code-box {
  background: #060a12;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-family: 'Fira Code','Courier New', monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  position: relative;
  overflow-x: auto;
  margin-top: 0.5rem;
  word-break: break-all;
  white-space: pre-wrap;
}
.code-box code { word-break: break-all; white-space: pre-wrap; display: block; }
.copy-btn {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: var(--ease);
  z-index: 2;
}
.copy-btn:hover { background: var(--accent); }

/* ── Modal ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: var(--ease);
}
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal {
  background: #0f1625;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  width: 90%; max-width: 580px;
  padding: 1.75rem;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
  transform: translateY(18px);
  transition: var(--ease);
}
.modal-backdrop.active .modal { transform: translateY(0); }

/* ── Mobile Top Bar (hidden on desktop) ──────────── */
.mobile-top-bar {
  display: none;
  background: rgba(10,15,26,0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.1rem;
  position: sticky; top: 0;
  z-index: 99;
  justify-content: space-between;
  align-items: center;
}

/* ══════════════════════════════════════════════════
   RESPONSIVE — tablet/mobile
══════════════════════════════════════════════════ */
@media (max-width: 992px) {
  /* Switch from grid to column flow */
  .app-container {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
  }

  /* Mobile sidebar: slide in from left */
  .sidebar {
    position: fixed;
    top: 0; left: -100%;
    width: 260px; height: 100vh;
    transition: left 0.28s ease;
    box-shadow: 10px 0 30px rgba(0,0,0,0.55);
    z-index: 1001;
  }
  .sidebar.active { left: 0; }

  .mobile-top-bar { display: flex; }

  .main-content {
    padding: 1.25rem 1rem;
    width: 100%;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .top-bar .btn { width: 100%; justify-content: center; }

  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 0.85rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
  .main-content { padding: 1rem 0.75rem; }
  .card { padding: 1rem; }
  .page-title h1 { font-size: 1.3rem; }
  .stat-card { padding: 1rem; gap: 0.75rem; }
  .stat-info h3 { font-size: 1.25rem; }
}
