@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

:root, [data-theme="dark"] {
  --bg-primary:             #0F172A;
  --bg-secondary:           #1E293B;
  --bg-card:                #1E293B;
  --bg-card-hover:          #263249;

  --sidebar-bg:             linear-gradient(180deg, #0F172A 0%, #172033 100%);
  --sidebar-border:         rgba(255,255,255,0.08);
  --sidebar-text-primary:   #F1F5F9;
  --sidebar-text-secondary: #94A3B8;
  --sidebar-text-muted:     #64748B;
  --sidebar-hover-bg:       rgba(255,255,255,0.05);
  --sidebar-sub-bg:         rgba(0,0,0,0.25);

  --topbar-bg:              rgba(15,23,42,0.85);
  --sidebar-width:          260px;

  --indigo:                 #6366F1;
  --indigo-light:           #818CF8;
  --indigo-dark:            #4F46E5;
  --emerald:                #10B981;
  --amber:                  #F59E0B;
  --coral:                  #F43F5E;
  --sky:                    #38BDF8;
  --purple:                 #A855F7;

  --text-primary:           #F1F5F9;
  --text-secondary:         #94A3B8;
  --text-muted:             #64748B;

  --border:                 rgba(255,255,255,0.08);
  --border-active:          rgba(99,102,241,0.5);

  --shadow-sm:              0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:              0 4px 20px rgba(0,0,0,0.3);
  --shadow-lg:              0 10px 40px rgba(0,0,0,0.4);
  --shadow-glow:            0 0 20px rgba(99,102,241,0.25);

  --radius-sm:              8px;
  --radius-md:              12px;
  --radius-lg:              16px;
  --radius-xl:              20px;

  --transition:             all 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow:        all 0.35s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg-primary:             #F8FAFC;
  --bg-secondary:           #FFFFFF;
  --bg-card:                #FFFFFF;
  --bg-card-hover:          #F1F5F9;

  --sidebar-bg:             #FFFFFF;
  --sidebar-border:         #E2E8F0;
  --sidebar-text-primary:   #0F172A;
  --sidebar-text-secondary: #334155;
  --sidebar-text-muted:     #64748B;
  --sidebar-hover-bg:       #F1F5F9;
  --sidebar-sub-bg:         #F8FAFC;

  --topbar-bg:              rgba(255,255,255,0.9);

  --indigo:                 #4F46E5;
  --indigo-light:           #6366F1;
  --indigo-dark:            #4338CA;
  --emerald:                #059669;
  --amber:                  #D97706;
  --coral:                  #E11D48;
  --sky:                    #0284C7;
  --purple:                 #9333EA;

  --text-primary:           #0F172A;
  --text-secondary:         #334155;
  --text-muted:             #64748B;

  --border:                 #E2E8F0;
  --border-active:          rgba(79,70,229,0.4);

  --shadow-sm:              0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:              0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:              0 10px 30px rgba(0,0,0,0.08);
  --shadow-glow:            0 0 15px rgba(79,70,229,0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Collapse behavior fix */
.collapse:not(.show) { display: none !important; }
.collapse.show { display: block !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--indigo); }

#layoutSidenav { display: flex; min-height: 100vh; width: 100%; }

#layoutSidenav_nav {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: var(--transition-slow);
}

.sb-sidenav { display: flex; flex-direction: column; height: 100%; }

.sb-sidenav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none !important;
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--sidebar-text-primary); letter-spacing: -0.3px; }
.brand-sub  { font-size: 10px; color: var(--sidebar-text-muted); text-transform: uppercase; letter-spacing: 1px; }

.sb-sidenav-menu { flex: 1; overflow-y: auto; padding: 12px 0; }
.sb-sidenav-menu-heading {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sidebar-text-muted);
  padding: 16px 20px 6px;
}

.sms-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text-secondary);
  text-decoration: none !important;
  transition: var(--transition);
  position: relative;
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sms-nav-link:hover { color: var(--sidebar-text-primary); background: var(--sidebar-hover-bg); }
.sms-nav-link.active { color: var(--indigo-light); background: rgba(99,102,241,0.12); }
.sms-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--indigo), var(--purple));
  border-radius: 0 3px 3px 0;
}
.sms-nav-link .nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sms-nav-link:hover .nav-icon, .sms-nav-link.active .nav-icon { background: rgba(99,102,241,0.2); color: var(--indigo-light); }
.nav-arrow { margin-left: auto; font-size: 11px; transition: transform 0.2s; color: var(--sidebar-text-muted); }
.sms-nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

.sms-sub-menu { background: var(--sidebar-sub-bg); }
.sms-sub-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 8px 60px;
  color: var(--sidebar-text-secondary);
  text-decoration: none !important;
  font-size: 13px;
  transition: var(--transition);
}
.sms-sub-link:hover { color: var(--sidebar-text-primary); background: var(--sidebar-hover-bg); }
.sms-sub-link::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--sidebar-text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}
.sms-sub-link:hover::before { background: var(--indigo-light); }

.sb-sidenav-footer { padding: 16px 20px; border-top: 1px solid var(--sidebar-border); }
.user-footer { display: flex; align-items: center; gap: 10px; }
.user-avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.user-info .user-name { font-size: 13px; font-weight: 600; color: var(--sidebar-text-primary); }
.user-info .user-role { font-size: 11px; color: var(--sidebar-text-muted); }

#layoutSidenav_content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sms-topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-search { position: relative; flex: 0 0 260px; }
.topbar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px 8px 36px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.topbar-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  text-decoration: none !important;
  position: relative;
}
.topbar-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-active); }
.badge-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--coral); border-radius: 50%; border: 2px solid var(--bg-primary); }
.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  cursor: pointer;
  border: 2px solid var(--border-active);
  transition: var(--transition);
}
.topbar-avatar:hover { box-shadow: var(--shadow-glow); }

.sms-main { flex: 1; padding: 28px 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { border-color: var(--border-active); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.indigo  { background: rgba(99,102,241,0.15); color: var(--indigo-light); }
.stat-icon.emerald { background: rgba(16,185,129,0.15); color: var(--emerald); }
.stat-icon.amber   { background: rgba(245,158,11,0.15);  color: var(--amber); }
.stat-icon.coral   { background: rgba(244,63,94,0.15);   color: var(--coral); }
.stat-icon.sky     { background: rgba(56,189,248,0.15);  color: var(--sky); }
.stat-icon.purple  { background: rgba(168,85,247,0.15);  color: var(--purple); }
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; letter-spacing: -0.5px; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-badge { font-size: 11px; padding: 2px 8px; border-radius: 50px; font-weight: 600; margin-top: 6px; display: inline-block; }
.stat-badge.up   { background: rgba(16,185,129,0.15); color: var(--emerald); }
.stat-badge.down { background: rgba(244,63,94,0.15);  color: var(--coral); }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.panel-badge { font-size: 11px; padding: 4px 10px; border-radius: 50px; background: rgba(99,102,241,0.15); color: var(--indigo-light); font-weight: 600; }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.quick-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 50px; font-size: 13px; font-weight: 500; text-decoration: none !important; transition: var(--transition); border: 1px solid transparent; }
.quick-btn.primary { background: var(--indigo); color: #fff; }
.quick-btn.primary:hover { background: var(--indigo-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.quick-btn.outline { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.quick-btn.outline:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-active); }

.sms-table { width: 100%; border-collapse: collapse; }
.sms-table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); padding: 12px 14px; border-bottom: 1px solid var(--border); }
.sms-table td { padding: 12px 14px; font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border); vertical-align: middle; }
.sms-table tr:last-child td { border-bottom: none; }
.sms-table tbody tr { transition: var(--transition); }
.sms-table tbody tr:hover { background: rgba(99,102,241,0.03); }
.sms-table .name-cell { color: var(--text-primary); font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 600; }
.pill.green  { background: rgba(16,185,129,0.15); color: var(--emerald); }
.pill.red    { background: rgba(244,63,94,0.15);  color: var(--coral); }
.pill.yellow { background: rgba(245,158,11,0.15);  color: var(--amber); }
.pill.blue   { background: rgba(56,189,248,0.15);  color: var(--sky); }
.pill.indigo { background: rgba(99,102,241,0.15);  color: var(--indigo-light); }

.sms-form-card { width: 100% !important; max-width: 100% !important; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm); }
.sms-label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 6px; }
.sms-input, .sms-select, .sms-textarea { width: 100%; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-primary); font-size: 13.5px; font-family: 'Inter', sans-serif; outline: none; transition: var(--transition); }
.sms-input:focus, .sms-select:focus, .sms-textarea:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.sms-input::placeholder { color: var(--text-muted); }
.sms-textarea { min-height: 100px; resize: vertical; }

.btn-sms { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; border: none; cursor: pointer; transition: var(--transition); text-decoration: none !important; font-family: 'Inter', sans-serif; }
.btn-sms.indigo { background: var(--indigo); color: #fff; }
.btn-sms.indigo:hover { background: var(--indigo-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); color: #fff; }
.btn-sms.emerald { background: var(--emerald); color: #fff; }
.btn-sms.emerald:hover { background: #059669; transform: translateY(-1px); color: #fff; }
.btn-sms.coral { background: var(--coral); color: #fff; }
.btn-sms.coral:hover { background: #e11d48; transform: translateY(-1px); color: #fff; }
.btn-sms.ghost { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-sms.ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header-text h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.page-header-text p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.breadcrumb-sms { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb-sms a { color: var(--indigo-light); text-decoration: none; }

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); position: relative; overflow: hidden; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 40px; width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 32px; }
.auth-logo-icon { width: 60px; height: 60px; background: linear-gradient(135deg, var(--indigo), var(--purple)); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; box-shadow: var(--shadow-glow); }
.auth-logo h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.auth-logo p { font-size: 13px; color: var(--text-muted); text-align: center; }

.sms-alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.sms-alert.success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: var(--emerald); }
.sms-alert.error   { background: rgba(244,63,94,0.1);  border: 1px solid rgba(244,63,94,0.25);  color: var(--coral); }
.sms-alert.info    { background: rgba(99,102,241,0.1);  border: 1px solid rgba(99,102,241,0.25); color: var(--indigo-light); }
.sms-alert.warning { background: rgba(245,158,11,0.1);  border: 1px solid rgba(245,158,11,0.25); color: var(--amber); }

@media (max-width: 768px) {
  #layoutSidenav_nav { transform: translateX(-100%); }
  #layoutSidenav_nav.open { transform: translateX(0); }
  #layoutSidenav_content { margin-left: 0; width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}