/* ═══════════════════════════════════════════
   SRC Admin Panel — Premium Dark Theme
   ═══════════════════════════════════════════ */

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

:root {
    --bg-primary: #060a13;
    --bg-secondary: #0c1120;
    --bg-card: rgba(15, 23, 42, 0.7);
    --bg-card-hover: rgba(20, 30, 55, 0.8);
    --bg-input: rgba(15, 23, 42, 0.9);
    --border-color: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.35);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --accent-pink: #ec4899;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --gradient-secondary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ═══ Animated Background ═══ */
.bg-animation {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; overflow: hidden; pointer-events: none;
}
.bg-animation .orb {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.12;
    animation: float 20s ease-in-out infinite;
}
.bg-animation .orb:nth-child(1) { width: 500px; height: 500px; background: var(--accent-blue); top: -10%; left: -5%; animation-delay: 0s; }
.bg-animation .orb:nth-child(2) { width: 400px; height: 400px; background: var(--accent-purple); top: 50%; right: -10%; animation-delay: -7s; }
.bg-animation .orb:nth-child(3) { width: 350px; height: 350px; background: var(--accent-cyan); bottom: -5%; left: 30%; animation-delay: -14s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 35px) scale(1.02); }
}

/* ═══ Login Page ═══ */
.login-wrapper {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; position: relative; z-index: 1;
}
.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-glow);
    animation: slideUp 0.6s ease-out;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-logo {
    text-align: center; margin-bottom: 32px;
}
.login-logo .logo-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--gradient-primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px; margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
}
.login-logo h1 {
    font-size: 22px; font-weight: 700; letter-spacing: -0.5px;
    background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ═══ Form Elements ═══ */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 8px; letter-spacing: 0.3px;
}
.form-input {
    width: 100%; padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px; font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
}
.form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px;
    border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; font-family: 'Inter', sans-serif;
    cursor: pointer; transition: var(--transition);
    text-decoration: none;
}
.btn-primary {
    width: 100%;
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.45);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none !important;
}
.btn-secondary {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-blue); border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: rgba(99, 102, 241, 0.2); border-color: var(--border-hover); }
.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-icon { padding: 8px; min-width: 34px; height: 34px; }

/* ═══ Toast Notifications ═══ */
.toast {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; margin-bottom: 16px;
    display: none; animation: fadeIn 0.3s ease;
}
.toast.show { display: block; }
.toast-error { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.2); }
.toast-success { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.2); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ Dashboard Layout ═══ */
.dashboard { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    background: rgba(12, 17, 32, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { font-size: 13px; color: var(--text-secondary); }
.topbar-user strong { color: var(--text-primary); }

.main-content { padding: 28px 32px; max-width: 1400px; margin: 0 auto; }

/* ═══ Stats Cards ═══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.total::before { background: var(--gradient-primary); }
.stat-card.active::before { background: var(--accent-green); }
.stat-card.unused::before { background: var(--accent-cyan); }
.stat-card.expired::before { background: var(--accent-red); }
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stat-value { font-size: 32px; font-weight: 800; margin-top: 4px; letter-spacing: -1px; }
.stat-card.total .stat-value { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card.active .stat-value { color: var(--accent-green); }
.stat-card.unused .stat-value { color: var(--accent-cyan); }
.stat-card.expired .stat-value { color: var(--accent-red); }

/* ═══ Panel Sections ═══ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 24px; overflow: hidden;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}
.panel-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 24px; }

/* ═══ Key Generation ═══ */
.gen-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.gen-row .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }
.generated-keys {
    margin-top: 16px; display: none;
}
.generated-keys.show { display: block; }
.key-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    padding: 8px 14px; margin: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px; color: var(--accent-blue);
    cursor: pointer; transition: var(--transition);
}
.key-chip:hover { background: rgba(99, 102, 241, 0.15); border-color: var(--accent-blue); }
.key-chip .copy-icon { font-size: 12px; opacity: 0.6; }
.key-chip.copied { background: rgba(16, 185, 129, 0.1); border-color: var(--accent-green); color: var(--accent-green); }

/* ═══ Data Table ═══ */
.table-controls {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-box {
    padding: 8px 14px; background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none; min-width: 250px; transition: var(--transition);
}
.search-box:focus { border-color: var(--accent-blue); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    padding: 10px 14px;
    text-align: left; font-size: 11px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-color);
}
.data-table tbody td {
    padding: 12px 14px; font-size: 13px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.05);
    color: var(--text-secondary);
}
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(99, 102, 241, 0.04); }
.data-table .key-cell { font-family: 'JetBrains Mono', monospace; color: var(--text-primary); font-size: 12px; }

.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-active { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); }
.badge-unused { background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); }
.badge-expired { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }
.badge-revoked { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }

.actions-cell { display: flex; gap: 6px; }

/* ═══ Pagination ═══ */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; margin-top: 16px;
}
.page-btn {
    padding: 6px 12px; border-radius: 6px;
    background: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-secondary); font-size: 12px; font-family: 'Inter', sans-serif;
    cursor: pointer; transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.page-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══ Audit Log ═══ */
.audit-entry {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid rgba(99, 102, 241, 0.05);
    font-size: 13px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-time { color: var(--text-muted); font-size: 11px; min-width: 130px; font-family: 'JetBrains Mono', monospace; }
.audit-action {
    padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px; min-width: 70px; text-align: center;
}
.audit-action.login { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.audit-action.logout { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.audit-action.generate { background: rgba(99, 102, 241, 0.1); color: var(--accent-blue); }
.audit-action.revoke { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.audit-action.extend { background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }
.audit-action.delete { background: rgba(236, 72, 153, 0.1); color: var(--accent-pink); }
.audit-action.password_change { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.audit-details { color: var(--text-secondary); flex: 1; }

/* ═══ Modal ═══ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); z-index: 1000;
    display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 32px;
    width: 90%; max-width: 440px;
    animation: slideUp 0.3s ease;
}
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ═══ Spinner ═══ */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading span { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

/* ═══ Responsive ═══ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 20px; }
}

@media (max-width: 768px) {
    .topbar {
        padding: 12px 16px;
        flex-wrap: wrap; gap: 10px;
    }
    .topbar-left { flex: 1; min-width: 0; }
    .topbar-title { font-size: 14px; }
    .topbar-right { 
        flex-wrap: wrap; gap: 8px;
        width: 100%; justify-content: flex-end;
    }
    .topbar-user { font-size: 12px; width: 100%; text-align: right; }
    .main-content { padding: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 26px; }
    .stat-card { padding: 14px 16px; }
    .panel-header { padding: 14px 16px; }
    .panel-body { padding: 16px; }
    .gen-row { flex-direction: column; }
    .gen-row .form-group { min-width: auto; }
    .btn-primary { width: 100%; }
    .login-card { padding: 32px 24px; }
    .table-controls { flex-direction: column; }
    .search-box { min-width: auto; width: 100%; }
    .data-table { font-size: 12px; }
    .data-table thead th, .data-table tbody td { padding: 8px 6px; }
    .actions-cell { flex-wrap: wrap; }
    .audit-entry { flex-direction: column; gap: 4px; }
    .audit-time { min-width: auto; }
    .modal { padding: 24px 20px; width: 95%; }
}

@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 28px; }
    .topbar-logo { display: none; }
    .login-card { padding: 24px 18px; margin: 10px; }
    .login-logo h1 { font-size: 18px; }
    .key-chip { font-size: 11px; padding: 6px 10px; }
}

/* ═══ Table Responsive Wrapper ═══ */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
