/* =====================================================
   BillHub — Billing Portal Stylesheet
   Font: Sora (headings/UI) + IBM Plex Mono (data)
   Theme: Dark navy with electric indigo accent
   ===================================================== */

:root {
  --bg: #0B0F1A;
  --bg-2: #111827;
  --bg-3: #1C2333;
  --bg-card: #151C2C;
  --border: #1E2B42;
  --border-light: #2A3A56;
  --text-primary: #E8EEF8;
  --text-secondary: #8A9ABB;
  --text-muted: #4E5F7A;
  --accent: #5B7CF6;
  --accent-hover: #7B98FF;
  --accent-glow: rgba(91, 124, 246, 0.15);
  --green: #22C55E;
  --green-bg: rgba(34, 197, 94, 0.1);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --orange: #F97316;
  --orange-bg: rgba(249, 115, 22, 0.1);
  --yellow: #EAB308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --sidebar-w: 250px;
  --topbar-h: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font-main: 'Sora', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(91, 124, 246, 0.2);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

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

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

.logout-btn {
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s;
}
.logout-btn:hover { background: var(--red-bg); color: var(--red); }

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

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 6px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  flex: 1;
}

.topbar-actions { display: flex; gap: 8px; }

.content {
  padding: 28px;
  flex: 1;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 16px var(--accent-glow); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.3);
}
.btn-success:hover { background: var(--green); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text-primary); }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 30px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead tr {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }

tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td strong { color: var(--text-primary); }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.badge-red    { background: var(--red-bg);    color: var(--red);   border: 1px solid rgba(239,68,68,0.2); }
.badge-orange { background: var(--orange-bg); color: var(--orange);border: 1px solid rgba(249,115,22,0.2); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue);  border: 1px solid rgba(59,130,246,0.2); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow);border: 1px solid rgba(234,179,8,0.2); }
.badge-gray   { background: var(--bg-3);      color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple { background: rgba(139,92,246,0.1); color: #A78BFA; border: 1px solid rgba(139,92,246,0.2); }

/* ─── Forms ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select option { background: var(--bg-2); }
textarea { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 20px 0 4px;
}

.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: white; border-color: var(--accent); }
.pagination .disabled { opacity: 0.3; pointer-events: none; }

/* ─── Flash Messages ─────────────────────────────────────── */
.flash-message {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  margin: 0 28px;
  margin-top: 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.flash-error   { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.flash-info    { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }

.flash-close { background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; padding: 0 4px; opacity: 0.7; }
.flash-close:hover { opacity: 1; }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  animation: modal-in 0.2s ease;
}

.modal-lg { max-width: 720px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ─── Search / Filter bar ────────────────────────────────── */
.filter-bar {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative; flex: 1; min-width: 200px;
}

.search-box input {
  padding-left: 38px;
}

.search-box svg {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* ─── Dashboard Grid ─────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

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

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  background: none; border: none;
  padding: 10px 18px;
  font-family: var(--font-main);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Product Icon Tags ──────────────────────────────────── */
.product-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ─── Detail page layout ─────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

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

.info-rows { display: flex; flex-direction: column; gap: 0; }
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); font-size: 12px; }
.info-row .value { color: var(--text-primary); font-weight: 500; }

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

/* ─── Login page ─────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

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

.login-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
  font-size: 22px; font-weight: 700;
}

/* ─── Plan cards ─────────────────────────────────────────── */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  transition: border-color 0.2s;
}

.plan-card.popular {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.plan-card .popular-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  padding: 3px 12px; border-radius: 100px;
}

.plan-price {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -1px;
  margin: 12px 0 4px;
}

.plan-price sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  vertical-align: baseline;
}

.plan-features {
  list-style: none;
  margin: 16px 0;
  display: flex; flex-direction: column; gap: 8px;
}

.plan-features li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--text-secondary);
}

.plan-features li::before {
  content: '✓';
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Chart container ────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 240px;
}

/* ─── Alerts / notices ───────────────────────────────────── */
.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.notice-warning { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(249,115,22,0.2); }
.notice-info    { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar > * { width: 100%; }
}

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

/* ─── Utilities ──────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.w-full { width: 100%; }
