/* ===========================================
   THEME VARIABLES
=========================================== */
:root {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-glass: rgba(30, 41, 59, 0.7);

    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --primary-solid: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --border-color: #334155;
    --border-highlight: #475569;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --sidebar-width: 280px;
    --header-height: 70px;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================================
   RESET & BASE
=========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-highlight);
}

/* ===========================================
   TYPOGRAPHY
=========================================== */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===========================================
   LAYOUT
=========================================== */
.login-page {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, #1e1b4b, transparent 40%),
        radial-gradient(circle at bottom left, #312e81, transparent 40%),
        var(--bg-body);
}

.login-card {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h1 {
    font-size: 1.8rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: transform var(--transition-smooth);
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.brand i {
    color: var(--primary-solid);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    width: 100%;
    max-width: 1600px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    padding: 0.5rem 1rem 0.5rem 0.5rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

/* ===========================================
   COMPONENTS
=========================================== */

/* Code Blocks (Keys) */
/* Code Blocks (Keys) */
code {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
    border: 1px solid rgba(99, 102, 241, 0.2);
    letter-spacing: 0.5px;
}

.key-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.copy-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Date Filters */
.date-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.date-filters input {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* RESPONSIVE Overrides for these specific elements handled in media queries if needed, 
   but flex-wrap usually handles it well. */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(30, 41, 59, 0.5) 100%);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-solid);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Tables */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    /* For rounded corners */
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    background: #0f172a;
}

th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--bg-card-hover);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-solid);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
    gap: 0.5rem;
}

.btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* Action Buttons */
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #334155;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition-fast);
    margin: 0 0.25rem;
}

.action-btn:hover {
    background: var(--primary-solid);
    color: white;
    transform: translateY(-2px);
}

.btn-danger:hover {
    background: var(--danger);
}

.btn-success:hover {
    background: var(--success);
}

.btn-warning:hover {
    background: var(--warning);
    color: #fff;
}

/* Badges */
.badge {
    padding: 0.35em 0.8em;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-admin {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-user {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-highlight);
    box-shadow: var(--shadow-md);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--danger);
}

/* ===========================================
   RESPONSIVE & MOBILE
=========================================== */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.mobile-topbar h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.mobile-topbar button {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 900px) {
    .main-content {
        margin-left: 0;
        margin-top: 60px;
        padding: 1.5rem;
    }

    .mobile-topbar {
        display: flex;
    }

    .header {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .page-header {
        display: none;
    }

    /* Hide PC header */

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Close sidebar on click outside - simulated by overlay if needed, or JS toggle */

    .stat-card {
        padding: 1.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }
}

@media (max-width: 700px) {

    /* TABLE CARDS VIEWS */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead {
        display: none;
    }

    tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        padding: 1.25rem;
        box-shadow: var(--shadow-sm);
    }

    td {
        padding: 0.5rem 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.8rem;
        text-align: left;
    }

    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}