/* =========================================================
   eSIMFire Admin Console — Universal Responsive Design System
   ========================================================= */

:root {
  --bg-main: #0B0F19;
  --bg-sidebar: #070A12;
  --bg-card: #111827;
  --bg-card-hover: #172136;
  --bg-surface: #1E293B;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #FF6B00;
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --brand-orange: #FF6B00;
  --brand-orange-hover: #EA580C;
  --brand-orange-subtle: rgba(255, 107, 0, 0.15);
  --accent-cyan: #06B6D4;
  --accent-cyan-subtle: rgba(6, 182, 212, 0.15);
  --status-success: #10B981;
  --status-success-bg: rgba(16, 185, 129, 0.15);
  --status-warning: #F59E0B;
  --status-warning-bg: rgba(245, 158, 11, 0.15);
  --status-danger: #EF4444;
  --status-danger-bg: rgba(239, 68, 68, 0.15);
  --sidebar-width: 260px;
  --header-height: 64px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body, button, input, select, textarea {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

/* Base Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* =========================================================
   Sidebar Navigation & Drawer
   ========================================================= */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 95;
  transition: opacity 0.25s ease;
}

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

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.sidebar-logo i {
  color: var(--brand-orange);
  font-size: 22px;
}

.sidebar-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--brand-orange-subtle);
  color: var(--brand-orange);
  border: 1px solid rgba(255, 107, 0, 0.3);
  text-transform: uppercase;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
}

.sidebar-close-btn:hover {
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  -webkit-overflow-scrolling: touch;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 10px 4px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  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-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-orange-subtle);
  color: var(--brand-orange);
  font-weight: 700;
  border: 1px solid rgba(255, 107, 0, 0.25);
}

.nav-item-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
}

.nav-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
  background: var(--brand-orange);
  color: white;
}

.nav-badge.danger {
  background: var(--status-danger);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
}

.admin-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-orange), #FF8C38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: white;
}

.admin-meta {
  display: flex;
  flex-direction: column;
}

.admin-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-role {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* =========================================================
   Main Wrapper & Topbar
   ========================================================= */

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  transition: margin-left 0.3s ease, width 0.3s ease;
}

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

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.mobile-nav-toggle {
  display: none !important;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
}

.topbar-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maintenance-alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.live-customer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.live-customer-btn:hover {
  background: var(--accent-cyan-subtle);
  border-color: var(--accent-cyan);
}

/* =========================================================
   Content Body & Grid Systems
   ========================================================= */

.content-body {
  flex: 1;
  padding: 24px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

/* Flash Alerts */
.flash-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  animation: slideInRight 0.3s ease forwards;
  min-width: 300px;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.flash-success {
  background: var(--status-success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--status-success);
}

.flash-error {
  background: var(--status-danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--status-danger);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.icon-orange { background: var(--brand-orange-subtle); color: var(--brand-orange); }
.icon-cyan { background: var(--accent-cyan-subtle); color: var(--accent-cyan); }
.icon-green { background: var(--status-success-bg); color: var(--status-success); }
.icon-yellow { background: var(--status-warning-bg); color: var(--status-warning); }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stat-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Cards & Panels */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 18px;
}

/* =========================================================
   Tables & Data Presentation
   ========================================================= */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 600px;
}

.admin-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2.5px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success { background: var(--status-success-bg); color: var(--status-success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: var(--accent-cyan-subtle); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-neutral { background: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

/* =========================================================
   Buttons & Controls
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--brand-orange);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-orange-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--status-danger);
  color: white;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11.5px;
}

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-control:focus {
  border-color: var(--brand-orange);
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

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

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input-wrapper .form-control {
  padding-left: 36px;
}

/* =========================================================
   Modals
   ========================================================= */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}

/* Grid Utilities */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grid-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* =========================================================
   Comprehensive Responsive Breakpoints
   ========================================================= */

/* Tablets & Small Laptops (<= 992px) */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    width: 280px;
    max-width: 85vw;
  }

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

  .sidebar-close-btn {
    display: inline-flex;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .mobile-nav-toggle {
    display: inline-flex !important;
  }

  .content-body {
    padding: 18px 16px;
  }

  /* Multi-column grid auto-collapsing */
  .grid-split,
  .grid-2,
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(400px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(340px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(320px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile Phones (<= 640px) */
@media (max-width: 640px) {
  .topbar {
    padding: 0 14px;
    height: 58px;
  }

  .topbar-title {
    font-size: 14px;
  }

  .maintenance-alert-badge span {
    display: none;
  }

  .live-customer-btn span {
    display: none;
  }

  .live-customer-btn {
    padding: 6px 9px;
  }

  .content-body {
    padding: 14px 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-subtitle {
    display: none;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .filter-bar form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar form > div,
  .search-input-wrapper {
    width: 100% !important;
    min-width: 100% !important;
  }

  .panel-body {
    padding: 14px;
  }

  .panel-header {
    padding: 12px 14px;
  }

  .modal-dialog {
    max-width: 100%;
    margin: 8px;
  }

  /* Split form grids on mobile */
  div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* Ultra Small Screens (<= 380px) */
@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  margin-right: 16px;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-btn:hover {
  color: var(--brand-orange);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #F1F5F9;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-surface: #E2E8F0;
  --border-subtle: rgba(0, 0, 0, 0.1);
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
}

/* Adjust auth box for light mode */
[data-theme="light"] .auth-box {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}
[data-theme="light"] .auth-container {
  background: radial-gradient(circle at top right, #E2E8F0, #F1F5F9 60%);
}
