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

/* Dynamic Theme Variables */
:root[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --bg-main: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(255, 255, 255, 0.5);
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --border-color: rgba(0, 0, 0, 0.08);
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --sidebar-border: rgba(255, 255, 255, 0.6);
    --shadow-color: rgba(31, 38, 135, 0.06);
    
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    
    --success-color: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --danger-color: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning-color: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --info-color: #3b82f6;
    
    --card-shadow: 0 8px 32px 0 var(--shadow-color);
}

:root[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --bg-main: #0b0f19;
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.05);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.05);
    --sidebar-bg: rgba(15, 23, 42, 0.7);
    --sidebar-border: rgba(255, 255, 255, 0.04);
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    
    --success-color: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --danger-color: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --warning-color: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --info-color: #60a5fa;
    
    --card-shadow: 0 8px 32px 0 var(--shadow-color);
}

/* Global Reset & Scrollbars */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.15s ease;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Glassmorphism Common Utilities */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--card-shadow);
}

.glass-card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px 0 var(--shadow-color);
    border-color: rgba(99, 102, 241, 0.2);
}

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

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 2.5rem;
    padding-left: 0.5rem;
}

.sidebar-logo span {
    color: var(--text-primary);
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

.sidebar-item a:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.sidebar-item.active a {
    background: var(--primary-color);
    color: #ffffff;
}

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

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

.username {
    font-weight: 600;
    font-size: 0.95rem;
}

.role-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
}

/* Main Content Workspace */
.main-workspace {
    flex-grow: 1;
    margin-left: 280px;
    padding: 2rem 2.5rem;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

/* Topbar Header */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.page-title p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Theme Switcher Toggle */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

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

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
}

input:checked + .theme-slider {
    background-color: var(--primary-color);
}

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

.theme-slider span {
    font-size: 14px;
    z-index: 1;
    user-select: none;
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--text-muted);
    color: #ffffff;
}

.btn-danger {
    background: var(--danger-color);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success-color);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* Stats Card Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stats-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stats-info .value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stats-icon.primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.stats-icon.success {
    background: var(--success-light);
    color: var(--success-color);
}

.stats-icon.danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

.stats-icon.warning {
    background: var(--warning-light);
    color: var(--warning-color);
}

/* Grid Layouts for Content */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Tables System */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    margin-top: 1rem;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.custom-table th {
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-secondary);
}

.custom-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.custom-table tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

/* Badges for Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-pending {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-success {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

/* Forms Design */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Access Denied / Centered Cards */
.access-denied-body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Login Page Spec */
.login-body {
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Modal System */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 500px;
    width: 100%;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Alert Notifications */
.alert {
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

/* Keyframe Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustment for Mobile view */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-workspace {
        margin-left: 0;
        padding: 1.5rem;
    }
}
