/*
 * Unix Academy — Cyberpunk Dark Admin Theme (Mobile Optimized)
 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-regular.woff2') format('woff2');
}

:root {
  /* Premium Dark Mode - Deep Slate & Neon */
  --bg: #0b0f19;
  --bg-white: #111827;
  --bg-card: rgba(17, 24, 39, 0.6);
  --bg-sidebar: rgba(11, 15, 25, 0.85);
  --bg-sidebar-hover: rgba(0, 240, 255, 0.1);
  --bg-input: rgba(0, 0, 0, 0.3);
  --bg-hover: rgba(0, 240, 255, 0.08);

  --primary: #00f0ff;
  --primary-light: #67e8f9;
  --primary-lighter: rgba(0, 240, 255, 0.1);
  --primary-dark: #0891b2;
  --cyber-secondary: #6366f1; /* Indigo */
  --primary-glow: rgba(0, 240, 255, 0.2);

  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-light: #cbd5e1;
  --text-sidebar: #e2e8f0;
  --text-sidebar-muted: #94a3b8;

  --border: rgba(0, 240, 255, 0.25);
  --border-focus: #00f0ff;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --success-border: rgba(16, 185, 129, 0.3);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.3);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --warning-border: rgba(245, 158, 11, 0.3);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-lg: 0 0 20px rgba(0, 240, 255, 0.1), inset 0 0 20px rgba(112, 0, 255, 0.05);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  background-color: var(--bg);
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.02) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: var(--primary); color: #000; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary-dark); border-radius: 3px; }

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: #fff; text-shadow: 0 0 8px var(--primary); }

.app-container { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
  width: 260px; 
  background: rgba(10, 20, 35, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(0, 240, 255, 0.15);
  position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto;
  z-index: 1050; transition: transform 0.3s ease; display: flex; flex-direction: column;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
}

.main-content { flex: 1; margin-left: 260px; padding: 2rem; min-height: 100vh; max-width: 100%; }

.brand { padding: 1.5rem; border-bottom: 1px solid var(--border); text-align: center; }
.brand-title { font-size: 1.4rem; font-weight: 800; color: var(--primary); text-shadow: 0 0 10px rgba(0, 240, 255, 0.3); }
.brand-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

.nav-section { padding: 0.75rem 0; flex: 1; }
.nav-label { padding: 0.5rem 1.5rem; font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.5rem; color: var(--text-sidebar); font-weight: 500; transition: all var(--transition); }
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(0,240,255,0.1), transparent); border-right: 3px solid var(--primary); color: var(--primary); font-weight: bold; }

.topbar { 
  display: flex; justify-content: space-between; align-items: center; 
  margin-bottom: 2rem; padding: 1rem 1.5rem; 
  border-bottom: 1px solid var(--border); 
  flex-wrap: wrap; gap: 1rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.topbar-title { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 0;}

.card { 
  background: var(--bg-card); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg); 
  padding: 1.5rem; 
  box-shadow: 0 8px 32px rgba(0, 240, 255, 0.06), inset 0 0 0 1px rgba(255,255,255,0.03);
  backdrop-filter: blur(10px); 
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 1.5rem; 
  overflow-x: auto;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.card:hover {
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 12px 40px rgba(0, 240, 255, 0.1), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.card-header { font-size: 0.85rem; color: var(--text-secondary); font-weight: bold; margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;}
.card-value { font-size: 2.5rem; font-weight: bold; color: var(--primary); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

.data-table-wrapper { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 600px; background: var(--bg-card); }
.data-table th { padding: 1.2rem 1rem; text-align: right; color: var(--text-secondary); border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.15); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.8rem; }
.data-table td { padding: 1rem; border-bottom: 1px solid var(--border); color: var(--text); transition: background var(--transition); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr { transition: transform var(--transition), box-shadow var(--transition), background-color var(--transition); }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tbody tr:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); position: relative; z-index: 10; }

.badge { padding: 0.3rem 0.6rem; border-radius: 20px; font-size: 0.75rem; font-weight: bold; }
.badge-active { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }
.badge-disabled { background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); }
.badge-expired { background: var(--warning-bg); border: 1px solid var(--warning); color: var(--warning); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.6rem 1.2rem; font-weight: bold; border-radius: 6px; cursor: pointer; border: none; transition: all 0.3s; color: #fff; text-decoration: none;}
.btn-primary { background: linear-gradient(45deg, var(--cyber-secondary), var(--primary)); box-shadow: 0 0 10px rgba(0, 240, 255, 0.2); }
.btn-primary:hover { box-shadow: 0 0 20px var(--primary); transform: translateY(-2px); }
.btn-danger { background: rgba(239, 68, 68, 0.2); border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; box-shadow: 0 0 15px var(--danger); }
.btn-success { background: rgba(16, 185, 129, 0.2); border: 1px solid var(--success); color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; box-shadow: 0 0 15px var(--success); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; color: var(--text-secondary); font-size: 0.9rem; }
.form-input, .form-select {
  width: 100%; padding: 0.8rem; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; outline: none; transition: all 0.3s; box-sizing: border-box;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 10px rgba(0, 240, 255, 0.2); }
.form-select option { background: var(--bg-white); color: var(--text); }
.form-select[dir="ltr"] { text-align: left; direction: ltr; }

.select2-container--default .select2-selection--single { background-color: var(--bg-input) !important; border: 1px solid var(--border) !important; height: 42px !important; display: flex !important; align-items: center !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text) !important; }
.select2-dropdown { background-color: var(--bg-white) !important; border: 1px solid var(--border) !important; }
.select2-container--default .select2-results__option--selected { background-color: var(--primary-lighter) !important; }
.select2-container--default .select2-results__option--highlighted { background-color: var(--primary) !important; color: #000 !important; }

/* Overlay for Mobile Sidebar */
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 1040; backdrop-filter: blur(3px); }

/* RTL Definition */
[dir="rtl"] { direction: rtl; text-align: right; }
[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; }
[dir="rtl"] .main-content { margin-left: 0; margin-right: 260px; }

.mobile-toggle {
  display: none; position: fixed; top: 15px; left: 15px; z-index: 1100;
  background: var(--bg-card); border: 1px solid var(--primary); color: var(--primary);
  width: 45px; height: 45px; border-radius: 8px; cursor: pointer; font-size: 1.5rem; box-shadow: 0 0 10px rgba(0,240,255,0.3);
}

[dir="rtl"] .mobile-toggle { left: auto; right: 15px; }

/* =========================================
   Mobile Responsiveness Rules
   ========================================= */
@media (max-width: 768px) {
  .mobile-toggle { display: block; }
  
  .sidebar { transform: translateX(100%); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  
  .sidebar.open { transform: translateX(0) !important; box-shadow: 0 0 25px rgba(0,0,0,0.8); }
  .sidebar-overlay.active { display: block; }
  
  .main-content { margin-right: 0 !important; margin-left: 0 !important; padding: 1rem; padding-top: 80px; width: 100vw; }
  
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr !important; gap: 1rem; }
  
  .topbar { flex-direction: column; align-items: flex-start; }
}
/* =========================================
   Select2 Dark/Cyberpunk Theme Overrides
   ========================================= */
.select2-container--default .select2-selection--multiple {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    min-height: 42px !important;
}
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--primary) !important;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2) !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: rgba(0, 240, 255, 0.1) !important;
    border: 1px solid rgba(0, 240, 255, 0.3) !important;
    color: var(--primary) !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    margin-top: 6px !important;
    direction: ltr !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--danger) !important;
    margin-right: 8px !important;
    border-right: none !important;
    font-weight: bold;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: transparent !important;
    color: #ff4d4d !important;
}
.select2-dropdown {
    background-color: var(--bg-white) !important;
    border: 1px solid var(--border) !important;
}
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(0, 240, 255, 0.1) !important;
    color: var(--text-muted) !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
    color: #000 !important;
}
.select2-container--default .select2-search--inline .select2-search__field {
    color: var(--text) !important;
    caret-color: var(--primary) !important;
    margin-top: 8px !important;
}

/* =========================================
   Skeleton Shimmer Loader
   ========================================= */
.skeleton {
  background: linear-gradient(90deg, rgba(0,240,255,0.04) 25%, rgba(0,240,255,0.1) 50%, rgba(0,240,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  min-height: 20px;
}
.skeleton-card { height: 100px; margin-bottom: 1rem; }
.skeleton-line { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-line.short { width: 50%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =========================================
   Micro-Interactions
   ========================================= */
.hover-lift { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.hover-lift:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0, 240, 255, 0.15); }

.fade-in { animation: fadeIn 0.4s ease forwards; opacity: 0; }
@keyframes fadeIn { to { opacity: 1; } }

.pulse-glow { animation: pulseGlow 2s infinite; }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 240, 255, 0.15); }
  50% { box-shadow: 0 0 20px rgba(0, 240, 255, 0.35); }
}

/* =========================================
   Light Theme Toggle (CSS Variable Swap)
   ========================================= */
[data-theme="light"] {
  /* Premium Light Mode - Soft Glass & Sapphire */
  --bg: #f3f4f6; /* Pearl/Off-white */
  --bg-white: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.65); /* Translucent */
  --bg-sidebar: rgba(255, 255, 255, 0.8);
  --bg-sidebar-hover: rgba(37, 99, 235, 0.08);
  --bg-input: rgba(255, 255, 255, 0.9);
  --bg-hover: rgba(37, 99, 235, 0.05);

  --primary: #2563eb; /* Sapphire Blue */
  --primary-light: #3b82f6;
  --primary-lighter: rgba(37, 99, 235, 0.1);
  --primary-dark: #1d4ed8;
  --cyber-secondary: #0ea5e9; /* Light Ocean Blue */
  --primary-glow: rgba(37, 99, 235, 0.15);

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-sidebar: #1e293b;
  --text-sidebar-muted: #64748b;

  --border: rgba(0, 0, 0, 0.08);
  --border-focus: #2563eb;

  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.04), inset 0 0 0 1px rgba(255,255,255,0.4);
}
[data-theme="light"] body {
  background-image: none;
}
[data-theme="light"] ::selection { background: #4F46E5; color: #fff; }
[data-theme="light"] ::-webkit-scrollbar-track { background: #F3F4F6; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #CBD5E1; }
