/* NeonLicense Dashboard v2.0 — Premium Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-primary: #0a0e1a; --bg-secondary: #111827; --bg-card: #1a1f35; --bg-card-hover: #1f2642;
  --bg-input: #151b30; --bg-sidebar: #0d1220;
  --border: #1e293b; --border-focus: #6366f1;
  --text-primary: #f1f5f9; --text-secondary: #94a3b8; --text-muted: #64748b;
  --accent: #6366f1; --accent-hover: #818cf8; --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #3b82f6;
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-card: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.04));
  --shadow: 0 4px 24px rgba(0,0,0,0.3); --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
  --radius: 12px; --radius-sm: 8px; --radius-xs: 6px;
  --sidebar-w: 260px; --header-h: 64px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f0f2f5; --bg-secondary: #ffffff; --bg-card: #ffffff; --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9; --bg-sidebar: #ffffff;
  --border: #e2e8f0; --text-primary: #0f172a; --text-secondary: #475569; --text-muted: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,0.08); --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --gradient-card: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(139,92,246,0.02));
}

html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; min-height: 100dvh; overflow-x: hidden; line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Live indicator ── */
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 6px; animation: livePulse 2s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.5); } 50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16,185,129,0); } }
.realtime-badge { display: inline-flex; align-items: center; padding: 4px 10px; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); border-radius: 100px; font-size: 0.65rem; font-weight: 700; color: var(--success); text-transform: uppercase; letter-spacing: 1px; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; background: radial-gradient(ellipse at top, #1a1040 0%, #0a0e1a 60%); padding: 20px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 48px; width: 420px; max-width: 100%; box-shadow: var(--shadow-lg); }
.login-card .logo { text-align: center; margin-bottom: 32px; }
.login-card .logo h1 { font-size: 1.8rem; font-weight: 800; background: var(--gradient-accent); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-card .logo p { color: var(--text-muted); margin-top: 4px; font-size: 0.85rem; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s ease; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sidebar .brand { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.sidebar .brand h2 { font-size: 1.2rem; font-weight: 800; background: var(--gradient-accent); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar .brand small { color: var(--text-muted); font-size: 0.7rem; }
.sidebar nav { flex: 1; padding: 12px; overflow-y: auto; }
.sidebar .nav-section { margin-bottom: 8px; }
.sidebar .nav-section-title { font-size: 0.65rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; padding: 8px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: var(--transition); font-size: 0.9rem; font-weight: 500; text-decoration: none; margin-bottom: 2px; -webkit-tap-highlight-color: transparent; }
.nav-item:hover { background: var(--accent-glow); color: var(--text-primary); }
.nav-item.active { background: var(--gradient-accent); color: white; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.nav-item .icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar .user-section { padding: 16px; border-top: 1px solid var(--border); }
.sidebar .user-info { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-card); border-radius: var(--radius-sm); }
.sidebar .user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gradient-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; font-size: 0.85rem; flex-shrink: 0; }
.sidebar .user-name { font-weight: 600; font-size: 0.85rem; }
.sidebar .user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; }

/* Sidebar overlay for mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; backdrop-filter: blur(2px); }
.sidebar-overlay.active { display: block; }

.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.header { height: var(--header-h); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--bg-secondary); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); gap: 12px; }
.header .page-title { font-size: 1.3rem; font-weight: 700; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: var(--transition); }
.card:hover { border-color: rgba(99,102,241,0.2); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 1rem; font-weight: 700; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--gradient-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; overflow: hidden; transition: var(--transition); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient-accent); opacity: 0; transition: opacity 0.3s; }
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 16px; }
.stat-card .stat-icon.purple { background: rgba(99,102,241,0.15); color: #818cf8; }
.stat-card .stat-icon.green { background: rgba(16,185,129,0.15); color: #34d399; }
.stat-card .stat-icon.yellow { background: rgba(245,158,11,0.15); color: #fbbf24; }
.stat-card .stat-icon.red { background: rgba(239,68,68,0.15); color: #f87171; }
.stat-card .stat-icon.blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1; transition: var(--transition); }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; font-weight: 500; }
.stat-card .stat-change { font-size: 0.75rem; margin-top: 8px; font-weight: 600; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Value update animation */
@keyframes valueFlash { 0% { color: var(--accent-hover); } 100% { color: var(--text-primary); } }
.value-updated { animation: valueFlash 0.6s ease; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-xs); color: var(--text-primary); font-family: inherit; font-size: 16px; transition: var(--transition); outline: none; -webkit-appearance: none; }
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border: none; border-radius: var(--radius-xs); font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: var(--transition); text-decoration: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; white-space: nowrap; }
.btn-primary { background: var(--gradient-accent); color: white; }
.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.4); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #000; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { background: var(--bg-secondary); color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 16px; text-align: left; position: sticky; top: 0; white-space: nowrap; }
td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-card-hover); }
tr.row-new td { animation: rowHighlight 1.5s ease; }
@keyframes rowHighlight { 0% { background: rgba(99,102,241,0.2); } 100% { background: transparent; } }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.badge-active { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-revoked { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-suspended { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-expired { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-owner { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-admin { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-info { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-critical { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-normal { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s; padding: 20px; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; width: 500px; max-width: 100%; max-height: 85vh; max-height: 85dvh; overflow-y: auto; box-shadow: var(--shadow-lg); padding: 28px; transform: translateY(20px) scale(0.95); transition: transform 0.2s; -webkit-overflow-scrolling: touch; }
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }

/* ── Toast ── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 40px); }
.toast { padding: 14px 20px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; color: white; box-shadow: var(--shadow); animation: toastIn 0.3s ease; min-width: 240px; max-width: 100%; display: flex; align-items: center; gap: 10px; word-break: break-word; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #000; }
.toast-info { background: var(--info); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Search Bar ── */
.search-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); flex: 1; max-width: 400px; min-width: 0; }
.search-bar input { background: none; border: none; outline: none; color: var(--text-primary); font-family: inherit; flex: 1; font-size: 16px; min-width: 0; }
.search-bar input::placeholder { color: var(--text-muted); }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 12px; flex: 1; flex-wrap: wrap; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.filter-select { padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-xs); color: var(--text-primary); font-family: inherit; font-size: 16px; outline: none; cursor: pointer; -webkit-appearance: none; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 20px; flex-wrap: wrap; }
.pagination .page-btn { padding: 6px 12px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); border-radius: var(--radius-xs); cursor: pointer; font-size: 0.8rem; font-weight: 500; transition: var(--transition); -webkit-tap-highlight-color: transparent; }
.pagination .page-btn:hover { border-color: var(--accent); color: var(--accent); }
.pagination .page-btn.active { background: var(--gradient-accent); color: white; border-color: transparent; }

/* ── Skeleton loader ── */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-xs); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Two-col grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.full-width { grid-column: 1 / -1; }

/* ── Key display ── */
.license-key { font-family: 'Courier New', monospace; background: var(--bg-input); padding: 3px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.5px; word-break: break-all; }

/* ── Theme toggle removed ── */

/* ── Activity feed ── */
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; display: flex; align-items: flex-start; gap: 10px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-dot.auth { background: var(--info); }
.activity-dot.license { background: var(--success); }
.activity-dot.system { background: var(--warning); }
.activity-dot.security { background: var(--danger); }

/* ── Connection status ── */
.connection-status { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.connection-status .dot { width: 6px; height: 6px; border-radius: 50%; }
.connection-status.connected .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.connection-status.disconnected .dot { background: var(--danger); }

/* ══════════════════════════════════════ */
/* ── RESPONSIVE — Tablet (768-1024px) ── */
/* ══════════════════════════════════════ */
.mobile-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.4rem; cursor: pointer; -webkit-tap-highlight-color: transparent; padding: 4px; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .mobile-toggle { display: block; }
  .header { padding: 0 16px; }
  .content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════ */
/* ── RESPONSIVE — Phone (<600px) ──── */
/* ══════════════════════════════════════ */
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .login-card { padding: 32px 20px; border-radius: 16px; }
  .header .page-title { font-size: 1rem; }
  .header { height: 56px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-right { justify-content: stretch; }
  .toolbar-right .btn { flex: 1; justify-content: center; }
  .search-bar { max-width: none; }
  .modal { padding: 20px; border-radius: 12px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
  .stat-card { padding: 20px; }
  .stat-card .stat-value { font-size: 1.6rem; }
  table { font-size: 0.78rem; }
  th, td { padding: 10px 12px; }
  .toast-container { top: 10px; right: 10px; left: 10px; }
  .toast { min-width: auto; width: 100%; }
  .card { padding: 16px; }
  .filter-select { flex: 1; }
}

/* ══════════════════════════════════════ */
/* ── RESPONSIVE — Small phone (<380px)  */
/* ══════════════════════════════════════ */
@media (max-width: 380px) {
  .content { padding: 12px; }
  .header { padding: 0 12px; gap: 8px; }
  .btn-sm { padding: 4px 8px; font-size: 0.7rem; }
  .badge { font-size: 0.6rem; padding: 2px 6px; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; display: inline-block; vertical-align: middle; }
