/* ============================================================
   Client Portal — Dark Blue Theme
   ============================================================ */

:root {
  --bg-base:        #07111f;
  --bg-sidebar:     #0c1a2e;
  --bg-card:        #0f2039;
  --bg-card-hover:  #132845;
  --bg-input:       #0a1828;
  --border:         #1a3050;
  --border-light:   #1e3a5f;

  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #1e3a6e;

  --accent:         #38bdf8;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #4a6080;

  --success:        #10b981;
  --success-bg:     #052e1e;
  --warning:        #f59e0b;
  --warning-bg:     #2d1f00;
  --danger:         #ef4444;
  --danger-bg:      #2d0808;
  --secondary-clr:  #64748b;

  --sidebar-w:      260px;
  --header-h:       64px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --transition:     0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text-primary); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, #0d2a4a 0%, #07111f 60%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 14px;
  margin-bottom: 1rem;
}

.login-logo .logo-icon svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-logo p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.login-form .input-wrap {
  position: relative;
}

.login-form .input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
}

.login-form .input-wrap .input-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.login-form input::placeholder {
  color: var(--text-muted);
}

.btn-login {
  width: 100%;
  padding: 0.8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.2px;
}

.btn-login:hover  { background: var(--primary-hover); }
.btn-login:active { transform: scale(0.98); }

.alert-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   APP LAYOUT — SIDEBAR + CONTENT
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: default;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.user-info span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-top: 0.25rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.logout-btn:hover {
  background: var(--danger-bg);
  color: #fca5a5;
}

.logout-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ---- Main content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.page-content {
  padding: 2rem;
  flex: 1;
}

/* ============================================================
   DASHBOARD STATS
   ============================================================ */

.page-header {
  margin-bottom: 1.75rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition), background var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-icon.blue   { background: rgba(37,99,235,0.15); color: #60a5fa; }
.stat-icon.green  { background: rgba(16,185,129,0.15); color: #34d399; }
.stat-icon.yellow { background: rgba(245,158,11,0.15); color: #fbbf24; }
.stat-icon.red    { background: rgba(239,68,68,0.15);  color: #f87171; }

.stat-body strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-body span {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  display: block;
}

/* ============================================================
   TABLES
   ============================================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-header a,
.section-header .view-all {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.section-header a:hover { color: var(--accent); }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.table-toolbar h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-box {
  position: relative;
}

.search-box input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem 0.45rem 2.25rem;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  width: 220px;
  transition: border-color var(--transition);
}

.search-box input:focus { border-color: var(--primary); }
.search-box input::placeholder { color: var(--text-muted); }

.search-box svg {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 0.75rem 1.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 0.9rem 1.25rem;
  font-size: 0.86rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(26,48,80,0.6);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--bg-card-hover); }

.td-service-name {
  font-weight: 600;
  color: var(--text-primary);
}

.td-domain {
  color: var(--accent);
  font-size: 0.82rem;
}

.td-price {
  font-weight: 600;
  color: var(--success);
}

.td-muted {
  color: var(--text-secondary);
  font-size: 0.83rem;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success   { background: var(--success-bg); color: var(--success);  border: 1px solid rgba(16,185,129,0.25); }
.badge-danger    { background: var(--danger-bg);  color: var(--danger);   border: 1px solid rgba(239,68,68,0.25); }
.badge-warning   { background: var(--warning-bg); color: var(--warning);  border: 1px solid rgba(245,158,11,0.25); }
.badge-secondary { background: rgba(100,116,139,0.15); color: var(--secondary-clr); border: 1px solid rgba(100,116,139,0.2); }

/* Expiry alerts inline */
.expiry-urgent {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-top: 3px;
}

.expiry-warn {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--warning);
  background: var(--warning-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-top: 3px;
}

/* ============================================================
   AUTO-RENEW TOGGLE
   ============================================================ */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.toggle-dot.on  { background: var(--success); }

/* ============================================================
   EMPTY STATE
   ============================================================ */

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

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1.5;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ============================================================
   NOTICE BANNER
   ============================================================ */

.notice-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.84rem;
  color: #fcd34d;
}

.notice-banner svg {
  width: 18px;
  height: 18px;
  stroke: #f59e0b;
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ---- Row highlight for expiry ---- */
tbody tr.row-urgent td { background: rgba(239,68,68,0.04); }
tbody tr.row-warn   td { background: rgba(245,158,11,0.04); }

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-content {
    padding: 1.25rem;
  }
}

@media (max-width: 540px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .search-box input {
    width: 160px;
  }

  .topbar {
    padding: 0 1rem;
  }

  thead th:nth-child(n+5),
  tbody td:nth-child(n+5) {
    display: none;
  }
}
