/* ============================================================
   Admin Panel Styles
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --admin-bg: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    --card-border: rgba(255,255,255,0.06);
}

body.admin-body {
    display: flex;
    min-height: 100vh;
    background: var(--admin-bg);
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar .sidebar-logo {
    padding: 0 24px 24px;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 16px;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar .nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

.sidebar .nav-item.active {
    color: var(--accent-1);
    background: rgba(124,58,237,0.1);
    border-left-color: var(--accent-1);
}

.sidebar .nav-item.logout {
    margin-top: auto;
    color: var(--error);
}

/* ---------- Main Content ---------- */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(124,58,237,0.2);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card .stat-sub {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ---------- Table ---------- */
.table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 14px 20px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--card-border);
    background: rgba(255,255,255,0.02);
}

tbody td {
    padding: 14px 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--card-border);
}

tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: rgba(16,185,129,0.12);
    color: #6ee7b7;
}

.badge-inactive {
    background: rgba(239,68,68,0.12);
    color: #fca5a5;
}

.badge-pending {
    background: rgba(245,158,11,0.12);
    color: #fcd34d;
}

.badge-success {
    background: rgba(16,185,129,0.12);
    color: #6ee7b7;
}

.badge-failed {
    background: rgba(239,68,68,0.12);
    color: #fca5a5;
}

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 32px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInUp 0.3s ease-out;
}

.modal h2 {
    margin-bottom: 24px;
    font-size: 1.2rem;
}

.modal .form-group {
    margin-bottom: 20px;
}

.modal .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

.modal .form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ---------- Key Display ---------- */
.key-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-display code {
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #a78bfa;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

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

/* ---------- Search & Filter Bar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-input {
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    min-width: 240px;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover,
.page-btn.active {
    background: var(--accent-1);
    color: #fff;
    border-color: var(--accent-1);
}

/* ---------- Progress Bar ---------- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ---------- Login Page ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.login-card .login-logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-card .login-sub {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-card .form-group {
    text-align: left;
    margin-bottom: 20px;
}

.login-card .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-card .form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.login-card .form-group input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 16px 0;
    }
    .admin-main {
        margin-left: 0;
        padding: 20px 16px;
    }
    .admin-body {
        flex-direction: column;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-input {
        min-width: auto;
        width: 100%;
    }
}
