/* =====================================================
   MarketHub - Main Stylesheet
   ===================================================== */
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --secondary: #0f766e;
  --accent: #f59e0b;
  --sa-primary: #1e40af;
  --sa-dark: #1e3a8a;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; color: #1e293b; background: #f1f5f9; }
a { text-decoration: none; }

/* =====================================================
   APP LAYOUT
   ===================================================== */
.app-body { margin: 0; padding: 0; }
.app-wrapper { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1050;
  transition: transform .25s ease;
}
.superadmin-theme .sidebar {
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: #fff;
  flex-shrink: 0;
}
.sa-logo { background: #4f46e5; }
.brand-text { flex: 1; min-width: 0; }
.brand-name { display: block; font-weight: 700; font-size: .9rem; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-role { display: block; font-size: .72rem; color: #64748b; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #f1f5f9; }
.sidebar-nav .nav-link.active { background: var(--primary); color: #fff; }
.superadmin-theme .sidebar-nav .nav-link.active { background: #4f46e5; }
.sidebar-nav .nav-link .fa { width: 18px; text-align: center; font-size: .9rem; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.08); }

.sidebar-toggle { background: none; border: none; color: #94a3b8; padding: 4px 8px; }

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

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

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.sa-topbar { border-bottom-color: #c7d2fe; }
.topbar-title { font-weight: 700; font-size: 1.1rem; margin: 0; flex: 1; color: #0f172a; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 5px 10px; background: #fff; }
.user-btn:hover { background: #f8fafc; }
.user-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #fff;
}
.sa-avatar { background: #4f46e5; }
.user-avatar-sm {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: #fff;
  flex-shrink: 0;
}

/* PAGE CONTENT */
.page-content { padding: 24px; flex: 1; }

/* =====================================================
   STAT CARDS
   ===================================================== */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--c, var(--primary));
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  background: color-mix(in srgb, var(--c, var(--primary)) 15%, white);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: var(--c, var(--primary));
  flex-shrink: 0;
}
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: #0f172a; line-height: 1; }
.stat-label { font-size: .8rem; color: #64748b; margin-top: 4px; }
.stat-sub { font-size: .75rem; color: #94a3b8; margin-top: 2px; }
.stat-footer { font-size: .75rem; color: #94a3b8; margin-top: 8px; }
.stat-footer a { color: var(--c, var(--primary)); }

.stat-card-mini {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-mini-val { font-size: 1.1rem; font-weight: 700; color: #0f172a; }
.stat-mini-lbl { font-size: .75rem; color: #94a3b8; display: block; }

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  padding: 16px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-header h5 { font-size: .95rem; font-weight: 700; color: #0f172a; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; background: #f8fafc; border-top: 1px solid #f1f5f9; border-radius: 0 0 var(--radius) var(--radius); }

/* =====================================================
   TABLES
   ===================================================== */
.table { font-size: .875rem; }
.table thead th { font-weight: 600; color: #374151; border-bottom: 2px solid #e2e8f0; background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table tbody td { vertical-align: middle; border-bottom: 1px solid #f1f5f9; padding: 10px 12px; }
.table-hover tbody tr:hover { background-color: #f8fafc; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn { border-radius: 8px; font-weight: 500; font-size: .875rem; }
.btn-success { background: var(--primary); border-color: var(--primary); }
.btn-success:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-xs { padding: 3px 8px; font-size: .75rem; border-radius: 6px; }
.btn-lg { font-size: 1rem; padding: 12px 24px; }

/* =====================================================
   FORMS
   ===================================================== */
.form-control, .form-select { border-radius: 8px; border-color: #e2e8f0; font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.form-label { font-weight: 600; font-size: .8rem; color: #374151; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.input-group-text { background: #f8fafc; border-color: #e2e8f0; }

/* =====================================================
   BADGES
   ===================================================== */
.badge { font-size: .7rem; font-weight: 600; border-radius: 6px; padding: 3px 8px; }

/* =====================================================
   LANDING PAGE
   ===================================================== */
.landing-body { background: #0f172a; }

.landing-nav {
  background: rgba(15,23,42,.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 12px 0;
}
.landing-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.3rem; font-weight: 700; color: #f1f5f9 !important;
}
.nav-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem;
}
.landing-nav .nav-link { color: #94a3b8 !important; font-weight: 500; }
.landing-nav .nav-link:hover { color: #f1f5f9 !important; }

.hero-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #064e3b 100%);
  color: #fff;
  min-height: 100vh;
  padding-top: 70px;
}
.hero-badge {
  display: inline-block;
  background: rgba(22,163,74,.2);
  color: #4ade80;
  border: 1px solid rgba(74,222,128,.3);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 20px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 20px;
}
.text-gradient {
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-desc { font-size: 1.1rem; color: #94a3b8; line-height: 1.7; margin-bottom: 30px; max-width: 560px; }
.hero-cta { background: var(--primary); border-color: var(--primary); border-radius: 10px; font-weight: 700; }
.hero-stats strong { font-size: 1.5rem; color: #f1f5f9; }
.hero-stats small { color: #64748b; font-size: .8rem; }

.preview-card {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 20px;
  max-width: 440px;
  margin: 0 auto;
}
.preview-header { display: flex; align-items: center; gap: 5px; padding-bottom: 10px; }
.preview-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.preview-dot.red { background: #ef4444; }
.preview-dot.yellow { background: #f59e0b; }
.preview-dot.green { background: #22c55e; }
.stat-mini { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); border-radius: 10px; padding: 10px; }
.stat-mini-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .9rem; flex-shrink: 0; }
.stat-mini-icon.green { background: #16a34a; }
.stat-mini-icon.blue { background: #2563eb; }
.stat-mini-icon.orange { background: #ea580c; }
.stat-mini-icon.purple { background: #7c3aed; }
.stat-mini small { display: block; font-size: .72rem; color: #64748b; }
.stat-mini strong { font-size: .9rem; color: #f1f5f9; }
.bar { background: #22c55e; border-radius: 3px; transition: height .3s; }
.bar.active { background: #4ade80; }
.bar-label small { color: #64748b; font-size: .75rem; }

.section-header { max-width: 640px; margin: 0 auto 40px; }
.section-title { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800; color: #f1f5f9; }
.section-sub { color: #64748b; font-size: 1rem; }

.features-section { background: #0f172a; }
.feature-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 24px;
  height: 100%;
  transition: transform .2s, border-color .2s;
}
.feature-card:hover { transform: translateY(-4px); border-color: rgba(22,163,74,.4); }
.feature-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 16px; }
.feature-title { font-size: .95rem; font-weight: 700; color: #f1f5f9; margin-bottom: 8px; }
.feature-desc { font-size: .83rem; color: #64748b; line-height: 1.6; margin: 0; }

.demo-section { background: #0f172a; }
.demo-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  height: 100%;
  transition: border-color .2s;
}
.demo-card:hover { border-color: rgba(22,163,74,.4); }
.demo-icon { margin-bottom: 12px; }
.demo-role { font-weight: 700; color: #f1f5f9; margin-bottom: 6px; }
.demo-creds { background: rgba(0,0,0,.3); border-radius: 8px; padding: 10px 14px; text-align: left; margin-top: 12px; }
.cred-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cred-label { font-size: .75rem; color: #64748b; width: 32px; }
.cred-value { font-size: .75rem; color: #4ade80; font-family: monospace; }

.pricing-section { background: #0f172a; }
.pricing-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 28px;
  height: 100%;
  transition: transform .2s;
}
.pricing-card:hover { transform: translateY(-4px); }
.pricing-popular { border-color: var(--primary); background: rgba(22,163,74,.08); transform: translateY(-4px); }
.pricing-plan { font-weight: 700; color: #f1f5f9; margin-bottom: 8px; }
.pricing-price { font-size: 1.8rem; font-weight: 800; color: #4ade80; margin-bottom: 8px; }
.pricing-features li { padding: 6px 0; font-size: .875rem; color: #94a3b8; border-bottom: 1px solid rgba(255,255,255,.05); }

.cta-section { background: linear-gradient(135deg, #16a34a, #0f766e); color: #fff; }
.cta-title { font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 800; margin-bottom: 12px; }
.cta-sub { color: rgba(255,255,255,.8); margin-bottom: 30px; }
.cta-btn { border-radius: 10px; font-weight: 700; }

.landing-footer { background: #0f172a; color: #64748b; border-top: 1px solid rgba(255,255,255,.06); }
.footer-brand { font-weight: 700; color: #94a3b8; }

/* =====================================================
   AUTH PAGES
   ===================================================== */
.auth-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-container { width: 100%; max-width: 460px; }
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  box-shadow: 0 25px 50px rgba(0,0,0,.4);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 1.4rem; font-weight: 700; color: #0f172a;
  margin-bottom: 16px;
}
.auth-logo .fa { color: var(--primary); }
.auth-title { font-size: 1.4rem; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.auth-sub { color: #64748b; font-size: .875rem; }

.auth-tabs { display: flex; gap: 4px; background: #f1f5f9; border-radius: 10px; padding: 4px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; background: transparent;
  border-radius: 7px; font-weight: 600; font-size: .82rem; cursor: pointer; color: #64748b; transition: .15s;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

.auth-submit { border-radius: 10px; font-weight: 700; font-size: .95rem; padding: 12px; }
.auth-footer a { color: #64748b; }
.auth-footer a:hover { color: var(--primary); }

.demo-creds-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.demo-creds-header { padding: 8px 14px; background: #e2e8f0; font-size: .8rem; font-weight: 700; color: #64748b; }
.demo-creds-grid > div { padding: 8px 14px; font-size: .78rem; cursor: pointer; border-bottom: 1px solid #e2e8f0; transition: .1s; color: #374151; }
.demo-creds-grid > div:last-child { border-bottom: none; }
.demo-creds-grid > div:hover { background: #dcfce7; color: #16a34a; }
.demo-creds-grid strong { color: #0f172a; margin-right: 6px; }
.demo-creds-grid code { background: none; color: #16a34a; padding: 0; font-size: .78rem; }

/* =====================================================
   ROLE CARDS
   ===================================================== */
.role-card { transition: box-shadow .15s; }
.role-card:hover { box-shadow: var(--shadow-md); }
.permission-group { transition: border-color .15s; }
.permission-group:hover { border-color: var(--primary) !important; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 1.2rem; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
  .auth-card { padding: 24px; }
  .hero-title { font-size: 1.8rem; }
}

/* =====================================================
   MISC UTILITIES
   ===================================================== */
.font-monospace { font-family: 'Courier New', monospace; }
.text-purple { color: #7c3aed; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Print styles */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; }
  body { background: #fff; }
}
