@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

html {
    font-size: 14.4px; /* Scales down all rem units to 90% of default 16px */
    max-width: 100vw;
    overflow-x: hidden;
}
:root {
    color-scheme: light;
    /* Premium Light Theme Colors */
    --bg-main: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.05);
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --sidebar-width: 260px;
    --header-height: 70px;
    
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-hover: rgba(0, 0, 0, 0.25);
}

body.dark-mode {
    color-scheme: dark;
    --bg-main: #0f172a;
    --bg-secondary: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    /* Slightly muted accents for dark mode */
    --accent-primary: #60a5fa;
    --accent-hover: #3b82f6;
    
    --hover-bg: rgba(255, 255, 255, 0.05);
    
    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --scrollbar-hover: rgba(255, 255, 255, 0.25);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    max-width: 100vw;
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 20px;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 9999;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-glass);
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 2px 0;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.nav-item:hover {
    background-color: rgba(59, 130, 246, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.05));
    color: var(--accent-primary);
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

.nav-item svg {
    transition: transform 0.3s ease;
}

.nav-item:hover svg, .nav-item.active svg {
    transform: scale(1.15);
}

.nav-item span {
    margin-left: 12px;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #9CA3AF;
    font-weight: 800;
    margin: 24px 0 8px 12px;
}

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--header-height);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-content {
    padding: 32px;
    flex: 1;
}

/* Typography */
h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 600;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }

/* Forms & Buttons */
.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
    transform: scale(0.96) translateY(0);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-secondary:hover {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: scale(0.96) translateY(0);
}

.btn-success {
    background-color: var(--accent-success);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-success:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:active {
    transform: scale(0.96) translateY(0);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
}

select, option {
    color: var(--text-primary) !important;
    background-color: var(--bg-secondary) !important;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:active {
    transform: scale(0.85);
}

.btn-icon.btn-delete:hover {
    color: var(--accent-danger) !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.btn-icon.btn-view:hover {
    color: var(--accent-success) !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.2) !important;
}

.btn-icon.btn-edit:hover {
    color: #f59e0b !important; /* Amber / Yellowish Orange */
    background-color: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.2) !important;
}

.btn-icon.btn-renew:hover {
    color: var(--accent-primary) !important;
    background-color: rgba(99, 102, 241, 0.1) !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
}

/* Button Loading State */
.is-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}
.is-loading > * {
    opacity: 0;
}
.is-loading::after {
    content: "";
    position: absolute;
    top: calc(50% - 8px);
    left: calc(50% - 8px);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}
.btn-secondary.is-loading::after {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--text-primary);
}

@keyframes button-spin {
    to { transform: rotate(360deg); }
}

.form-control {
    background-color: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 16px;
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-control:focus {
    outline: none !important;
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

/* Fix browser autofill/autocomplete white background issue in dark mode */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-secondary) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.header-search {
    width: 300px;
    padding: 8px 16px;
    border-radius: 9999px;
    margin-bottom: 0;
}

/* Tables */
.premium-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    min-width: 600px;
}

.premium-table th, .premium-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
    vertical-align: middle;
}

.premium-table th {
    background-color: var(--bg-main) !important;
    color: var(--text-secondary) !important;
    border-bottom: 1px solid var(--border-glass) !important;
    border-top: none !important;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.premium-table tbody tr {
    border-bottom: 1px solid var(--border-glass);
    transition: background-color 0.2s;
}

.premium-table tbody tr:hover {
    background-color: var(--hover-bg, rgba(0,0,0,0.02)) !important;
}

/* Standard Table Scroller */
.table-scroll-wrapper {
    flex: 1;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
}

/* Standard Table Footer */
.premium-pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-main) !important;
    border-top: 1px solid var(--border-glass) !important;
    color: var(--text-secondary) !important;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px 24px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.validation-message {
    color: var(--accent-danger, #dc3545);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-glass);
    transition: .3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--accent-success);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Custom Modal Buttons */
.modal-close-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #9CA3AF;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #4B5563;
}

.modal-cancel-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-cancel-btn:hover {
    background-color: var(--bg-primary);
    border-color: var(--text-primary);
}

.modal-delete-btn {
    padding: 8px 24px;
    border-radius: 6px;
    background: #DC2626;
    color: white;
    border: none;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.modal-delete-btn:hover {
    background-color: #B91C1C;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.2);
    transform: translateY(-1px);
}

.modal-update-btn {
    padding: 8px 24px;
    border-radius: 6px;
    background: var(--accent-primary);
    color: white;
    border: none;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(99, 102, 241, 0.1);
    transition: all 0.2s ease;
}

.modal-update-btn:hover {
    background-color: #4F46E5;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.btn-icon.btn-reset:hover {
    color: var(--accent-primary) !important;
    background-color: rgba(99, 102, 241, 0.1) !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
}

/* Mobile Responsiveness */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.responsive-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.responsive-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.grid-cols-charts {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
}

.chart-flex-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    padding: 0 12px;
}

@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-cols-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    .responsive-grid-2 {
        grid-template-columns: 1fr !important;
    }
    .chart-flex-container {
        flex-direction: column;
        gap: 24px;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .top-bar {
        padding: 0 16px;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
    
    .glass-panel {
        padding: 16px;
    }
    
    .mobile-menu-btn {
        display: block !important;
    }
    
    /* Global Buttons & Forms on Mobile */
    .btn-primary, .btn-secondary, .btn-success {
        width: 100%;
        display: block;
        margin-bottom: 8px;
    }
    
    .form-control {
        width: 100%;
    }
    
    /* Global Table Overflow on Mobile */
    .premium-table {
        white-space: nowrap;
        min-width: 600px !important;
    }
    
    .table-scroll-wrapper {
        width: calc(100vw - 32px) !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .glass-panel {
        padding: 16px !important;
        max-width: 100vw !important;
        box-sizing: border-box;
    }
    
    /* Responsive Pagination Footer */
    .premium-pagination-footer {
        flex-direction: column;
        align-items: center !important;
        gap: 16px;
        text-align: center;
    }
    
    .premium-pagination-footer > div {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Responsive Modals */
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    /* Responsive Flex Utility */
    .responsive-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
}

/* Global Fixes */
/* Hide spin buttons for number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Hide Blazor Server Reconnection Overlay */
#components-reconnect-modal {
    display: none !important;
}
