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

:root {
    --sidebar-width: 260px;
    --font-primary: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Light Theme Variables */
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-border: rgba(226, 232, 240, 0.8);
    --card-shadow: 0 4px 20px -2px rgba(148, 163, 184, 0.12), 0 2px 6px -1px rgba(148, 163, 184, 0.08);
    --card-shadow-hover: 0 12px 28px -4px rgba(148, 163, 184, 0.2), 0 4px 12px -2px rgba(148, 163, 184, 0.12);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    
    /* Accent Gradients & Colors */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --primary-glow: rgba(99, 102, 241, 0.25);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --info-gradient: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --danger-gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
}

[data-bs-theme="dark"] {
    --body-bg: #0b0f17;
    --card-bg: rgba(15, 23, 42, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 16px 36px -4px rgba(0, 0, 0, 0.6);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --input-bg: #1e293b;
    --input-border: rgba(255, 255, 255, 0.12);
}

body {
    font-family: var(--font-primary);
    background-color: var(--body-bg);
    color: var(--text-main);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
}

#app-shell {
    min-height: 100vh;
    width: 100%;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar Styling
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #94a3b8;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;
    overflow-y: auto;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 1.35rem 1.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px var(--primary-glow);
    position: relative;
}

.brand-status-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border: 2px solid #0f172a;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

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

.sidebar-nav {
    padding: 0.75rem 0.75rem 2rem;
}

.sidebar .nav-heading {
    padding: 1.2rem 0.9rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
}

.sidebar .nav-link {
    color: #94a3b8;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    transition: transform 0.2s ease, color 0.2s ease;
    opacity: 0.85;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #f8fafc;
    transform: translateX(3px);
}

.sidebar .nav-link:hover i {
    opacity: 1;
    color: #818cf8;
    transform: scale(1.1);
}

.sidebar .nav-link.active {
    background: var(--primary-gradient);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.sidebar .nav-link.active i {
    color: #ffffff;
    opacity: 1;
}

/* ==========================================================================
   Top Navbar Styling
   ========================================================================== */
.top-navbar {
    background-color: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--card-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background-color: var(--card-border);
    color: #6366f1;
    transform: rotate(15deg);
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.user-profile-btn:hover, .user-profile-btn:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   Page & Card Styling
   ========================================================================== */
.page-content {
    padding: 1.75rem;
    max-width: 100%;
    overflow-x: hidden;
}

.page-title-heading {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 0;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-header {
    border-bottom: 1px solid var(--card-border);
    padding: 1.1rem 1.4rem;
    font-weight: 700;
    background: transparent;
}

.card-body {
    padding: 1.4rem;
}

/* Stat Cards */
.stat-card {
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

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

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* ==========================================================================
   Form Controls & Custom Inputs
   ========================================================================== */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    font-family: var(--font-primary);
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--input-bg);
    color: var(--text-main);
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Custom Interactive Chip Selectors for Radio & Checkboxes */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip-selector {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.chip-selector input[type="radio"],
.chip-selector input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.chip-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.chip-selector input:checked + .chip-label {
    background: var(--primary-gradient);
    color: #ffffff;
    border-color: transparent;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.chip-selector:hover .chip-label {
    border-color: #6366f1;
    transform: translateY(-1px);
}

/* ==========================================================================
   Tabs & Nav Pills
   ========================================================================== */
.nav-tabs-custom {
    background-color: rgba(148, 163, 184, 0.12);
    padding: 0.38rem;
    border-radius: 12px;
    border: none;
    display: inline-flex;
    gap: 0.25rem;
}

.nav-tabs-custom .nav-link {
    border: none;
    border-radius: 9px;
    padding: 0.55rem 1.25rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.2s ease;
    background: transparent;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.3);
}

[data-bs-theme="dark"] .nav-tabs-custom .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.nav-tabs-custom .nav-link.active {
    background-color: var(--card-bg);
    color: #6366f1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .nav-tabs-custom .nav-link.active {
    color: #818cf8;
    background-color: #1e293b;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    font-family: var(--font-primary);
    font-weight: 600;
    border-radius: 10px;
    padding: 0.55rem 1.1rem;
    font-size: 0.88rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.btn-success {
    background: var(--success-gradient);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-outline-primary {
    border-color: #6366f1;
    color: #6366f1;
}

.btn-outline-primary:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--primary-glow);
}

/* ==========================================================================
   Tables & Responsiveness
   ========================================================================== */
.table-responsive {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.08);
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

.table {
    color: var(--text-main);
    vertical-align: middle;
    min-width: 1050px; /* Ensures spacious columns & enables horizontal scroll when needed */
    margin-bottom: 0;
}

.table th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background-color: rgba(148, 163, 184, 0.06);
    border-bottom: 2px solid var(--card-border);
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

[data-bs-theme="dark"] .table th {
    background-color: rgba(255, 255, 255, 0.03);
}

.table td {
    padding: 0.85rem 1rem;
    font-size: 0.86rem;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.table td.cell-wrap {
    white-space: normal;
    min-width: 200px;
    max-width: 280px;
    word-break: break-word;
}

/* Long text capped at two lines; full value lives in the title tooltip. */
.cell-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.table-hover tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.04) !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.08) !important;
}

.badge {
    padding: 0.35em 0.7em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Filter Row Styling */
.filter-row {
    background-color: rgba(148, 163, 184, 0.06);
    border: 1px dashed var(--input-border);
    padding: 0.6rem;
    border-radius: 10px;
}

/* Pagination Styling */
.pagination {
    margin-bottom: 0;
    gap: 0.3rem;
}

.pagination .page-item .page-link {
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination .page-item.active .page-link {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.pagination .page-item .page-link:hover:not(.active) {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: #6366f1;
    color: #6366f1;
}

/* Hide DataTables client-side pager and info to prevent duplicate controls */
.dataTables_wrapper .dataTables_paginate,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length {
    display: none !important;
}

/* ==========================================================================
   Auth / Login Page Styling
   ========================================================================== */
.auth-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 70%, #020617 100%);
    z-index: 9999;
    padding: 1.5rem;
    overflow-y: auto;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.22) 0%, rgba(0, 0, 0, 0) 70%);
    top: 10%;
    left: 15%;
    border-radius: 50%;
    pointer-events: none;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: 10%;
    right: 15%;
    border-radius: 50%;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    color: #f8fafc;
    position: relative;
    z-index: 10;
}

.auth-card .input-group-text {
    background-color: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.auth-card .form-control {
    background-color: rgba(15, 23, 42, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.auth-card .form-control::placeholder {
    color: #64748b;
}

.auth-card .form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
    background-color: rgba(15, 23, 42, 0.95);
    color: #ffffff;
}

/* Mobile Responsive Adjustments */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        z-index: 1040;
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .sidebar.show {
        margin-left: 0;
    }
}
