/* ==============================================================================
   SMART SCHOOL DIGITAL PLATFORM - ENTERPRISE DESIGN SYSTEM
   Ultra-Responsive, Modern SaaS Architecture & Dark/Light Mode Support
   ============================================================================== */

:root {
    --primary-rgb: 79, 70, 229;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-subtle: rgba(79, 70, 229, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #ffffff;
    --bg-navbar: rgba(255, 255, 255, 0.92);
    
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;
    
    --sidebar-width: 280px;
    --sidebar-bg: #0d1322;
    --sidebar-border: #1a2337;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.15);
    --sidebar-active-text: #ffffff;
    --sidebar-active-border: #6366f1;

    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.02);
    --card-shadow-hover: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
    --card-shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

[data-bs-theme="dark"] {
    --bg-body: #090d16;
    --bg-surface: #111827;
    --bg-surface-elevated: #1e293b;
    --bg-navbar: rgba(17, 24, 39, 0.92);
    
    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #1f2937;
    --border-subtle: #182234;
    
    --sidebar-bg: #060911;
    --sidebar-border: #182234;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.25);
    --sidebar-active-text: #ffffff;

    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --card-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Wrapper Architecture */
#app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    background-color: var(--bg-body);
}

/* Main Content Area */
#main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-body);
    transition: all 0.25s ease;
}

.content-body {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Top Navbar */
.top-navbar {
    height: 64px;
    background: var(--bg-navbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
    transition: background-color 0.3s ease;
}

@media (min-width: 768px) {
    .top-navbar {
        padding: 0 1.75rem;
    }
}

.page-header-title {
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: var(--primary-subtle);
    color: var(--primary);
    border-color: var(--primary);
}

.user-dropdown-toggle {
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.user-dropdown-toggle:hover {
    background-color: rgba(0, 0, 0, 0.04);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .user-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.user-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.user-name-label {
    font-size: 0.88rem;
    line-height: 1.2;
}

.user-role-label {
    font-size: 0.72rem;
    line-height: 1;
}

.user-dropdown-menu {
    min-width: 220px;
    border-radius: 0.85rem;
}

/* Sidebar Navigation Architecture */
#app-sidebar {
    width: var(--sidebar-width);
    background: #0c1220;
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s ease;
    border-right: 1px solid #192236;
    user-select: none;
    z-index: 1030;
}

/* Desktop Sidebar: Fixed full height, never leaving empty space when scrolling with the footer */
@media (min-width: 992px) {
    #app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: var(--sidebar-width);
        z-index: 1030;
    }

    #main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }

    #main-content.no-sidebar {
        margin-left: 0;
        width: 100%;
    }
}

/* Mobile & Tablet Drawer Sidebar */
@media (max-width: 991.98px) {
    #app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 285px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        z-index: 1060;
        transform: translateX(-100%);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    }

    #app-sidebar.show {
        transform: translateX(0);
    }

    #main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Brand Header */
.sidebar-brand {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid #192236;
    background: rgba(12, 18, 32, 0.95);
    flex-shrink: 0;
}

.brand-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35);
    flex-shrink: 0;
}

/* Sidebar Scrollable Menu List */
.sidebar-menu {
    padding: 0.65rem 0.6rem;
    list-style: none;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Menu Section Divider Headers */
.menu-header {
    display: flex;
    align-items: center;
    padding: 1.15rem 0.65rem 0.4rem;
    font-size: 0.64rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #52627a;
}

.menu-header:first-child {
    padding-top: 0.35rem;
}

.menu-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin-left: 0.65rem;
}

/* Menu Items & Interactive Links */
.menu-item {
    margin: 0.15rem 0;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.58rem 0.75rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 0.55rem;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.menu-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    opacity: 0.85;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.menu-link:hover .menu-icon {
    transform: scale(1.12);
    opacity: 1;
}

/* Active State Design - Premium Inset Accent */
.menu-item.active .menu-link {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.24) 0%, rgba(79, 70, 229, 0.12) 100%);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.38), 0 2px 6px rgba(0, 0, 0, 0.25);
    font-weight: 600;
}

.menu-item.active .menu-link .menu-icon {
    color: #818cf8;
    opacity: 1;
    transform: scale(1.08);
}

/* Section Tag Badges */
.sidebar-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

.sidebar-badge-pos {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.sidebar-badge-topup {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.sidebar-pill-phase {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.14);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.24);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

.menu-item-future .menu-link {
    color: #627289;
}

.menu-item-future .menu-link:hover {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
}

/* Sidebar Footer User Card */
.sidebar-footer {
    padding: 0.75rem 0.85rem;
    border-top: 1px solid #192236;
    background: rgba(11, 16, 28, 0.95);
    flex-shrink: 0;
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-logout {
    width: 32px;
    height: 32px;
    border-radius: 0.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-user-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    transform: scale(1.05);
}

/* Main Page Footer */
.app-footer {
    margin-top: auto;
    flex-shrink: 0;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.84rem;
    padding: 1rem 1.75rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Cards & Surfaces */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.1rem 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stat Metrics Card */
.stat-card {
    position: relative;
    overflow: hidden;
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* Realistic Digital RFID Smart Card Mockup */
.rfid-card-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.rfid-card-visual {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%);
    border-radius: 1.25rem;
    padding: 1.5rem;
    min-height: 235px;
    position: relative;
    overflow: hidden;
    color: #ffffff;
    box-shadow: 0 20px 35px -10px rgba(30, 27, 75, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rfid-card-visual::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

.rfid-gold-chip {
    width: 44px;
    height: 34px;
    border-radius: 6px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    border: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
}

.rfid-gold-chip::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.rfid-card-number {
    font-size: 1.15rem;
    letter-spacing: 0.15em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.pulse-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@media (max-width: 575.98px) {
    .rfid-card-visual {
        min-height: 215px;
        padding: 1.2rem;
    }
    .rfid-card-number {
        font-size: 1rem;
        letter-spacing: 0.1em;
    }
}

/* POS Terminal Layout */
.pos-screen {
    min-height: calc(100vh - 120px);
}

.product-card {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
    border-radius: 0.85rem;
    overflow: hidden;
    background: var(--bg-surface);
}

.product-card:hover {
    border-color: #6366f1;
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.product-card:active {
    transform: scale(0.98);
}

.pos-cart-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: var(--card-shadow);
}

.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.rfid-scanner-box {
    border: 2px dashed #6366f1;
    background: rgba(99, 102, 241, 0.04);
    border-radius: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    animation: pulse-border 2.5s infinite;
}

@keyframes pulse-border {
    0% { border-color: #6366f1; box-shadow: 0 0 0 rgba(99, 102, 241, 0); }
    50% { border-color: #10b981; box-shadow: 0 0 15px rgba(16, 185, 129, 0.15); }
    100% { border-color: #6366f1; box-shadow: 0 0 0 rgba(99, 102, 241, 0); }
}

/* App Footer */
.app-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Custom Thin Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* Print Styles */
@media print {
    #app-sidebar, .top-navbar, .sidebar-backdrop, .no-print {
        display: none !important;
    }
    #main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}

