/* ── CSS Variables (Dark Theme) ──────────────────────────────────── */
:root {
    --bg: #0f1117;
    --bg-sidebar: #161822;
    --surface: #1c1f2e;
    --surface-hover: #252839;
    --border: #2a2d3e;
    --text: #e1e4ed;
    --text-muted: #8b8fa3;
    --text-dim: #6b6f82;
    --accent: #6c8aff;
    --accent-hover: #5a75e6;
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);
    --sidebar-width: 250px;
    --radius: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    transition: all 0.15s;
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
    text-decoration: none;
}

.nav-link.active {
    color: var(--accent);
    background: rgba(108, 138, 255, 0.08);
    border-right: 3px solid var(--accent);
}

.nav-icon {
    font-size: 0.8rem;
    width: 1.2rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.user-info {
    color: var(--text-muted);
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.btn-link:hover {
    color: var(--danger);
}

/* ── Hamburger ──────────────────────────────────────────────────── */
.hamburger {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    line-height: 1;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
}

/* ── Content ────────────────────────────────────────────────────── */
.content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

.content-full {
    margin-left: 0;
}

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-warn {
    border-color: rgba(251, 191, 36, 0.4);
}

.guide-card {
    margin-bottom: 1rem;
}

.guide-card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-success .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Detail Grid ────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ── Detail List ────────────────────────────────────────────────── */
.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.detail-list dt {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-list dd {
    font-size: 0.9rem;
}

/* ── Tables ─────────────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--surface-hover);
}

.mono {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.85rem;
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #e05050;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-copy {
    background: rgba(108, 138, 255, 0.15);
    color: var(--accent);
    border: 1px solid rgba(108, 138, 255, 0.3);
}

.btn-copy:hover {
    background: rgba(108, 138, 255, 0.25);
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(108, 138, 255, 0.15);
}

textarea {
    resize: vertical;
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

input[type="radio"],
input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent);
}

/* ── Filter Bar ─────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group select,
.filter-group input {
    width: auto;
    min-width: 180px;
}

/* ── Code Block ─────────────────────────────────────────────────── */
.code-block {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 0.5rem;
}

.code-block pre {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
}

.code-block .btn-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* ── License Key ────────────────────────────────────────────────── */
.license-key-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.license-key-hidden {
    position: relative;
}

.license-key {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    word-break: break-all;
    white-space: pre-wrap;
    transition: filter 0.2s;
}

.license-key.blurred {
    filter: blur(6px);
    user-select: none;
}

.key-actions {
    display: flex;
    gap: 0.5rem;
}

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

/* ── Auth Container ─────────────────────────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    color: var(--accent);
    font-size: 1.3rem;
    margin-bottom: 0.25rem;
}

.auth-card h2 {
    text-align: center;
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* ── Action Buttons ─────────────────────────────────────────────── */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Profile ───────────────────────────────────────────────────── */
.profil-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.profil-grid .card:last-child {
    grid-column: 1 / -1;
}

.otp-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.otp-qr-container {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background: #fff;
    border-radius: var(--radius);
    width: fit-content;
    margin: 0 auto;
}

.otp-qr-image {
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
}

/* ── Nav Divider ───────────────────────────────────────────────── */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1.5rem;
}

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Audit Badge ───────────────────────────────────────────────── */
.badge-audit {
    background: var(--surface-hover);
    color: var(--text);
}

/* ── Sidebar user link ─────────────────────────────────────────── */
.user-info-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.user-info-link:hover {
    color: var(--accent);
    text-decoration: none;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .hamburger {
        display: block;
    }

    .overlay.show {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4rem;
    }

    .detail-grid,
    .profil-grid {
        grid-template-columns: 1fr;
    }

    .profil-grid .card:last-child {
        grid-column: auto;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .filter-group select,
    .filter-group input {
        width: 100%;
        min-width: auto;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
