/* ==========================================================================
   Premium Dark Glassmorphic Styling for Library Gate Access Dashboard
   ========================================================================== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    /* Color Palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: rgba(16, 22, 40, 0.7);
    --glass-bg: rgba(20, 30, 55, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.18);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Neon Colors */
    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-cyan: #06b6d4;

    /* Gradients */
    --grad-indigo-pink: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --grad-cyan-blue: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --grad-emerald-teal: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
    --grad-purple-pink: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    --grad-amber-orange: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    
    /* Layout */
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    /* Transitions */
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 50px;
}

/* Background Ambient Glows */
body::before, body::after {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.15;
}

body::before {
    top: -100px;
    left: -100px;
    background: var(--accent-indigo);
}

body::after {
    bottom: 100px;
    right: -100px;
    background: var(--accent-pink);
}

/* Container */
.container {
    width: 95%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 12px;
}

/* Header Section */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-logo-icon {
    width: 48px;
    height: 48px;
    background: var(--grad-indigo-pink);
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.time-badge {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--glass-border);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.time-badge .dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 2s infinite;
}

.btn-refresh {
    background: var(--grad-indigo-pink);
    border: none;
    color: white;
    padding: 11px 20px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
    opacity: 0.95;
}

.btn-refresh:active {
    transform: translateY(0);
}

/* Auto-Refresh Progress Bar */
.refresh-progress-container {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.03);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
}

.refresh-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--grad-indigo-pink);
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.8);
    transition: width 1s linear;
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--glass-border-hover);
    box-shadow: 0 12px 40px 0 rgba(99, 102, 241, 0.15);
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-indigo);
}

.stat-card.color-pink::before { background: var(--accent-pink); }
.stat-card.color-emerald::before { background: var(--accent-emerald); }
.stat-card.color-cyan::before { background: var(--accent-cyan); }
.stat-card.color-amber::before { background: var(--accent-amber); }

.stat-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.stat-subtext {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

.stat-card:hover .stat-icon {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.05);
}

/* Charts Sections */
.dashboard-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

@media (max-width: 1200px) {
    .col-4, .col-5, .col-6, .col-7, .col-8 {
        grid-column: span 12;
    }
}

.chart-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    transition: var(--transition-smooth);
}

.chart-card:hover {
    border-color: var(--glass-border-hover);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    color: var(--accent-indigo);
}

.chart-controls {
    display: flex;
    gap: 8px;
}

.btn-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.btn-pill:hover, .btn-pill.active {
    background: var(--grad-indigo-pink);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.chart-body {
    flex-grow: 1;
    position: relative;
    min-height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Live Access Table Card */
.table-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
}

.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
    border-radius: var(--border-radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

tr {
    transition: var(--transition-smooth);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Table Badges & Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-student {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.badge-staff {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-guest {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-other {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 11px;
}

.gate-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.gate-indicator::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--accent-indigo);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Chart Canvas Wrapper */
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* No data placeholders */
.no-data-msg {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.no-data-msg i {
    font-size: 32px;
}

/* Footer style */
footer {
    text-align: center;
    margin-top: 40px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================================
   Filter Wrapper & Dropdown Select Styling
   ========================================================================== */
.filter-wrapper {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.filter-wrapper:hover {
    border-color: var(--glass-border-hover);
    background: rgba(255, 255, 255, 0.08);
}

.select-filter {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Sarabun', sans-serif;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    padding-right: 5px;
}

.select-filter option {
    background: #101628;
    color: var(--text-primary);
}

/* Custom Date Inputs container */
.custom-date-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-date {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-family: 'Outfit', 'Sarabun', sans-serif;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.input-date:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.date-separator {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==========================================================================
   Responsive Styling Overrides
   ========================================================================== */

/* Large Tablets & Small Desktops */
@media (max-width: 1024px) {
    header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
        padding: 20px;
    }

    .brand-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .filter-wrapper, .time-badge, .btn-refresh {
        font-size: 13px;
        padding: 8px 14px;
    }

    .custom-date-container {
        padding: 6px 10px;
    }
}

/* Small Tablets & Large Mobiles */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 16px 20px;
    }

    .stat-value {
        font-size: 28px;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
    }

    .chart-card {
        padding: 16px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-title {
        font-size: 14px;
    }

    .chart-controls {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* Mobile Devices */
@media (max-width: 576px) {
    .container {
        padding: 12px 8px;
    }

    header {
        padding: 16px 12px;
        margin-bottom: 20px;
    }

    .brand-logo-icon {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .brand-text h1 {
        font-size: 18px;
    }

    .brand-text p {
        font-size: 11px;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-wrapper, .time-badge, .btn-refresh, .custom-date-container {
        width: 100%;
        justify-content: center;
    }

    .select-filter {
        width: 100%;
        text-align: center;
        text-align-last: center;
    }

    .custom-date-container {
        flex-direction: column;
        gap: 6px;
    }

    .input-date {
        width: 100% !important;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 32px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Extra Small Devices */
@media (max-width: 380px) {
    .brand-text h1 {
        font-size: 16px;
    }
    
    .stat-value {
        font-size: 28px;
    }
}

/* ==========================================================================
   Right Sidebar Layout and Navigation Control Center
   ========================================================================== */
.dashboard-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
    margin-top: 5px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.right-sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 24px;
    z-index: 100;
}

/* Glass Card styling for Sidebar widgets */
.sidebar-widget {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.sidebar-widget-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Admin Profile Card */
.admin-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}
.admin-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--grad-indigo-pink);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    color: white;
}
.admin-info-text {
    display: flex;
    flex-direction: column;
}
.admin-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.admin-role {
    font-size: 12px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Sidebar Menu Navigation */
.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}
.sidebar-menu-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.05);
}
.sidebar-menu-item.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.05);
}
.sidebar-menu-item i {
    font-size: 18px;
}

/* Responsive sidebar */
@media (max-width: 1200px) {
    .dashboard-layout {
        flex-direction: column-reverse;
    }
    .right-sidebar {
        width: 100%;
        position: static;
    }
}



