:root {
    /* Color Palette - Dark Theme Default */
    --bg-base: #0b1120;
    --bg-surface: rgba(15, 23, 42, 0.75);
    --bg-surface-hover: rgba(30, 41, 59, 0.85);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(100, 255, 218, 0.15);
    
    /* Brand Colors */
    --brand-primary: #3b82f6; /* Corporate Blue */
    --brand-accent: #64ffda;  /* Vibrant Cyan/Teal */
    --brand-accent-glow: rgba(100, 255, 218, 0.3);
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Metrics */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --sidebar-width: 280px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme overrides */
[data-theme="light"] {
    --bg-base: #f0f4f8;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-surface-hover: rgba(241, 245, 249, 0.95);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(15, 23, 42, 0.1);
    --brand-accent-glow: rgba(59, 130, 246, 0.3);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow: hidden; /* App-like feel */
    transition: background-color var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* View Containers */
.view-container {
    display: none;
    height: 100vh;
    width: 100vw;
}

.view-container.active {
    display: flex;
    animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* ======= AUTH VIEW ======= */
.auth-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.glow-blob {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--brand-accent-glow) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(60px);
    z-index: -1;
    animation: pulse 8s infinite alternate;
}

.blob-1 { top: -100px; left: -100px; }
.blob-2 { bottom: -100px; right: -100px; animation-delay: -4s; background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%); }

@keyframes pulse {
    0% { transform: scale(0.8) translate(0, 0); }
    100% { transform: scale(1.2) translate(50px, 50px); }
}

.auth-card {
    width: 90%;
    max-width: 420px;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
}

.auth-header {
    text-align: center;
}

.auth-logo {
    width: 80px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--brand-accent-glow));
}

.auth-header h2 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-main), var(--brand-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-fast);
}

[data-theme="light"] .input-group input {
    background: rgba(0, 0, 0, 0.02);
}

.input-group input:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px var(--brand-accent-glow);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px var(--brand-accent-glow);
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1rem;
    display: none;
}

/* ======= APP VIEW ======= */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-logo {
    width: 40px;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--brand-accent);
}

[data-theme="light"] .nav-item:hover, [data-theme="light"] .nav-item.active {
    background: rgba(0, 0, 0, 0.05);
    color: var(--brand-primary);
}

.sidebar-footer {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
}

.text-danger {
    color: var(--danger) !important;
}

.text-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

.icon-only {
    justify-content: center;
    padding: 1rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.topbar {
    height: 80px;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-left h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-only {
    display: none;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
}

.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

.page-view {
    display: none;
    animation: fadeIn var(--transition-fast);
}

.page-view.active {
    display: block;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
}

.bg-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.bg-green { background: linear-gradient(135deg, #10b981, #059669); }
.bg-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.bg-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-details p {
    font-size: 1.5rem;
    font-weight: 800;
}

.dashboard-hero {
    padding: 3rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(59, 130, 246, 0.1));
}

[data-theme="light"] .dashboard-hero {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(59, 130, 246, 0.1));
}

.dashboard-hero h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--brand-primary);
}

.mt-4 { margin-top: 2rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Table View */
.table-controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
}

[data-theme="light"] .btn-secondary {
    background: #fff;
}

.btn-secondary:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.table-container {
    overflow-x: auto;
    position: relative;
    min-height: 300px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    background: rgba(0,0,0,0.2);
}

[data-theme="light"] .data-table th {
    background: rgba(0,0,0,0.03);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .data-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); border: 1px solid var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); border: 1px solid var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--info); border: 1px solid var(--info); }
.badge-secondary { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); border: 1px solid var(--text-muted); }

/* Loader */
.loader-container {
    position: absolute;
    inset: 0;
    background: var(--bg-surface);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}

.loader-container.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Action Buttons in Table */
.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 1.1rem;
}

.action-btn:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.detail-row {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

[data-theme="light"] .detail-row {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1.05rem;
    font-weight: 500;
    word-break: break-word;
}

/* Responsive Design */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

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

    .mobile-only {
        display: flex;
    }
}

@media (max-width: 576px) {
    .content-area {
        padding: 1rem;
    }
    
    .topbar {
        padding: 0 1rem;
    }
    
    .user-info {
        display: none;
    }
}
