/* Theme Variables */
:root {
    --bg-color: #0a0a0a;
    --text-color: #fff;
    --sidebar-bg: linear-gradient(180deg, #0f0f0f 0%, #1a0505 100%);
    --sidebar-border: rgba(220, 38, 38, 0.1);
    --card-bg: rgba(20, 20, 20, 0.9);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover-border: rgba(220, 38, 38, 0.2);
    --input-bg: rgba(255, 255, 255, 0.04);
    --input-border: rgba(255, 255, 255, 0.1);
    --table-header-bg: rgba(220, 38, 38, 0.15);
    --table-border: rgba(255, 255, 255, 0.04);
    --text-muted: rgba(255, 255, 255, 0.4);
    --text-muted-hover: rgba(255, 255, 255, 0.7);
    --modal-bg: #141414;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --main-content-bg: linear-gradient(to bottom right, #0a0a0a, #0f0505);
    --mobile-header-bg: #0f0f0f;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #fef2f2 100%);
    --sidebar-border: rgba(220, 38, 38, 0.2);
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(0, 0, 0, 0.1);
    --card-hover-border: rgba(220, 38, 38, 0.4);
    --input-bg: rgba(0, 0, 0, 0.02);
    --input-border: rgba(0, 0, 0, 0.1);
    --table-header-bg: rgba(220, 38, 38, 0.1);
    --table-border: rgba(0, 0, 0, 0.05);
    --text-muted: rgba(15, 23, 42, 0.6);
    --text-muted-hover: rgba(15, 23, 42, 0.9);
    --modal-bg: #ffffff;
    --overlay-bg: rgba(255, 255, 255, 0.8);
    --main-content-bg: linear-gradient(to bottom right, #f8fafc, #fef2f2);
    --mobile-header-bg: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { 
    height: 100%; 
    width: 100%; 
    font-family: 'Outfit', sans-serif; 
    margin: 0; 
    padding: 0; 
    overflow-x: hidden;
}
body { 
    background: var(--bg-color, #0a0a0a); 
    color: var(--text-color, #fff); 
    transition: background-color 0.3s, color 0.3s;
}

/* Login Background */
.login-bg {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0000 30%, #3d0000 60%, #8b0000 100%);
    position: relative;
    overflow: hidden;
}
.login-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(220, 20, 20, 0.08) 0%, transparent 50%);
    animation: pulseGlow 8s ease-in-out infinite;
}
.login-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
@keyframes pulseGlow {
    0%, 100% { opacity: .5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.login-card {
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(220, 20, 20, 0.15);
    box-shadow: 0 0 80px rgba(139, 0, 0, 0.15), 0 25px 50px rgba(0, 0, 0, 0.5);
}
.login-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all .3s;
}
.login-input:focus {
    border-color: rgba(220, 38, 38, 0.5);
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.1);
    outline: none;
    background: rgba(255, 255, 255, 0.06);
}
.login-btn {
    background: linear-gradient(135deg, #991b1b, #dc2626);
    position: relative;
    overflow: hidden;
    transition: all .3s;
}
.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.4);
}
.login-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Floating particles */
.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.3);
    animation: float linear infinite;
    pointer-events: none;
}
@keyframes float {
    0% { transform: translateY(100%) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100%) rotate(720deg); opacity: 0; }
}

/* Dashboard */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s ease, background 0.3s, border-color 0.3s;
    width: 280px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    min-height: 100vh;
    overflow: visible;
}

@media (max-width: 1023px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }
}

.sidebar.collapsed {
    width: 88px;
}

.sidebar-item {
    transition: all .2s;
    border-left: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    color: var(--text-muted);
}

.sidebar-item:hover,
.sidebar-item.active {
    background: var(--table-header-bg);
    border-left-color: #dc2626;
    color: var(--text-color);
}

.collapse-btn {
    position: absolute;
    top: 88px;
    right: -15px;
    width: 30px;
    height: 30px;
    background: #dc2626;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 60;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.35);
    transition: all 0.3s ease;
    border: 2px solid var(--bg-color);
}

.sidebar.collapsed .collapse-btn {
    transform: rotate(180deg);
}

.sidebar-header-text h1 {
    background: linear-gradient(135deg, var(--text-color), #fca5a5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
[data-theme="light"] .sidebar-header-text h1 {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.sidebar-header-text p {
    color: var(--text-muted);
}
.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .sidebar-footer-text {
    display: none;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 16px 0;
}

.sidebar.collapsed .sidebar-header {
    padding: 20px 0 16px;
    justify-content: center;
}

.sidebar.collapsed .logo-box {
    width: 36px;
    height: 36px;
}

@media (max-width: 1023px) {
    .collapse-btn {
        display: none;
    }
}

.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    transition: all .3s;
}
.dash-card:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
}

.main-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    background: var(--bg-color);
    transition: background-color 0.3s;
    width: 100%;
    overflow-x: hidden;
}

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table thead { background: var(--table-header-bg); transition: background-color 0.3s; }
.data-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 800px; }
.data-table thead { background: var(--table-header-bg); transition: background-color 0.3s; }
.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted-hover);
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    transition: color 0.3s, border-color 0.3s;
}
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--table-border);
    font-size: 13px;
    white-space: nowrap;
    transition: border-color 0.3s;
}

.btn-sm { padding: 6px 12px; border-radius: 6px; font-size: 11px; font-weight: 600; transition: all .2s; cursor: pointer; border: none; }
.btn-red { background: rgba(220, 38, 38, 0.2); color: #ef4444; }
.btn-green { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.btn-blue { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.btn-yellow { background: rgba(234, 179, 8, 0.2); color: #eab308; }

[data-theme="light"] .btn-red { background: rgba(220, 38, 38, 0.1); color: #dc2626; }
[data-theme="light"] .btn-green { background: rgba(34, 197, 94, 0.1); color: #16a34a; }
[data-theme="light"] .btn-blue { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
[data-theme="light"] .btn-yellow { background: rgba(234, 179, 8, 0.1); color: #ca8a04; }

.stat-number { font-family: 'Space Mono', monospace; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .6s ease forwards; }

@keyframes scaleIn {
    from { opacity: 0; transform: scale(.5); }
    to { opacity: 1; transform: scale(1); }
}
.scale-in { animation: scaleIn .5s ease forwards; }

/* Login Success Animation */
.login-success-overlay {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
}
.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: stroke .6s cubic-bezier(.65,0,.45,1) forwards;
}
.checkmark-check {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke .3s cubic-bezier(.65,0,.45,1) .8s forwards;
}
@keyframes stroke {
    100% { stroke-dashoffset: 0; }
}

.tab-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
    cursor: pointer;
    border: none;
    color: var(--text-muted);
    background: transparent;
}
.tab-btn.active {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
}

.modal-overlay {
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    z-index: 100;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    max-height: 90vh;
    overflow-y: auto;
    transition: background-color 0.3s, border-color 0.3s;
    width: 100%;
    max-width: 32rem; /* max-w-lg */
    padding: 1.5rem; /* p-6 */
}
@media (min-width: 768px) {
    .modal-content {
        padding: 2rem; /* md:p-8 */
    }
}
.form-input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-color);
    font-size: 14px;
    width: 100%;
    transition: all .3s;
    outline: none;
}
.form-input:focus {
    border-color: rgba(220, 38, 38, 0.5);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* Custom Select Styling */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23dc2626'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

select.form-input option {
    background-color: var(--modal-bg);
    color: var(--text-color);
    padding: 12px;
}

.progress-ring {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.mobile-header {
    display: none;
    background: var(--mobile-header-bg);
    border-bottom: 1px solid var(--sidebar-border);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    transition: background-color 0.3s, border-color 0.3s;
}
@media (max-width: 1023px) {
    .mobile-header {
        display: flex;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    z-index: 35;
    transition: background-color 0.3s;
}
.sidebar-overlay.active {
    display: block;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    color: var(--text-color);
}
.theme-toggle:hover {
    transform: scale(1.1);
    border-color: var(--card-hover-border);
}

/* DataTables Custom Styling */
.dataTables_wrapper {
    padding: 1rem;
    color: var(--text-color);
    width: 100%;
    overflow-x: auto;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background-color: var(--main-content-bg);
    color: var(--text-color);
    border: 1px solid var(--card-border);
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    outline: none;
}
.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: #3b82f6;
}
.dataTables_wrapper .dataTables_length select option {
    background-color: var(--modal-bg);
    color: var(--text-color);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-color) !important;
    border-radius: 0.375rem;
    border: 1px solid transparent;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--table-header-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--card-border);
}
.dataTables_wrapper .dataTables_info {
    color: var(--text-muted) !important;
    padding-top: 1rem;
}
.dataTables_wrapper .dataTables_paginate {
    padding-top: 1rem;
}
table.dataTable tbody tr {
    background-color: transparent;
}
table.dataTable.no-footer {
    border-bottom: 1px solid var(--card-border);
}

/* SweetAlert2 Custom Theme Overrides */
.swal2-popup {
    border: 1px solid var(--card-border) !important;
    border-radius: 16px !important;
}
.swal2-title {
    color: var(--text-color) !important;
}
.swal2-html-container {
    color: var(--text-muted) !important;
}