/* Black Gold ITAM — Glassmorphism Material Design */

/* Base */
body { font-family: 'Inter', 'Cairo', system-ui, sans-serif; }
html[dir="rtl"] body { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.5); border-radius: 3px; }

/* ===== GLASS CARDS ===== */
.glass-card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    border-radius: 1rem;
}

.glass-card-strong {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.03);
    border-radius: 1rem;
}

/* ===== GLASS SIDEBAR ===== */
.glass-sidebar {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

html[dir="rtl"] .glass-sidebar {
    border-right: none;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== COLLAPSIBLE SIDEBAR ===== */
#appSidebar {
    width: 256px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#appSidebar.collapsed {
    width: 72px;
}

/* Text labels — hidden in collapsed */
.sidebar-text {
    opacity: 1;
    transition: opacity 0.2s ease 0.08s;
    white-space: nowrap;
}

#appSidebar.collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.12s ease;
}

/* Section titles */
.sidebar-section-title {
    opacity: 1;
    transition: opacity 0.2s ease 0.08s;
}

#appSidebar.collapsed .sidebar-section-title {
    opacity: 0;
    height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    transition: opacity 0.12s ease;
}

/* Brand text */
.sidebar-brand-text {
    opacity: 1;
    transition: opacity 0.2s ease 0.08s;
}

#appSidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.12s ease;
}

/* Tooltips — only visible in collapsed mode */
.sidebar-tooltip {
    display: none;
}

#appSidebar.collapsed .sidebar-tooltip {
    display: block;
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 0.4rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

html[dir="rtl"] #appSidebar.collapsed .sidebar-tooltip {
    left: auto;
    right: calc(100% + 10px);
}

#appSidebar.collapsed a:hover .sidebar-tooltip,
#appSidebar.collapsed button:hover .sidebar-tooltip {
    opacity: 1;
}

/* Brand row in collapsed */
#appSidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
}

/* Nav in collapsed */
#appSidebar.collapsed nav {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

#appSidebar.collapsed nav a,
#appSidebar.collapsed nav button {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

#appSidebar.collapsed .sidebar-badge {
    display: none;
}

/* ===== SIDEBAR OFFSET — controlled by JS in applySidebarOffset() ===== */
/* padding-inline-start is set inline via JS to avoid CSS specificity issues */

/* Sidebar toggle button */
.sidebar-toggle {
    opacity: 0.5;
    transition: opacity 0.2s;
    margin-left: 0.5rem;
}

.sidebar-toggle:hover {
    opacity: 1;
}

/* ===== GLASS HEADER ===== */
.glass-header {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* ===== GLASS TABLE ===== */
.glass-table {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    border-radius: 1rem;
    overflow: hidden;
}

/* ===== GLASS BUTTONS ===== */
.glass-btn {
    background: rgba(59, 130, 246, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.glass-btn:hover {
    background: rgba(37, 99, 235, 0.95);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.glass-btn-secondary {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.glass-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ===== GLASS INPUTS ===== */
.glass-input {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(203, 213, 225, 0.6);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* ===== GLASS STAT CARD ===== */
.glass-stat {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.glass-stat:hover {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* ===== GLASS MODAL / DROPDOWN ===== */
.glass-dropdown {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12);
    border-radius: 1rem;
}

/* ===== DATA TABLES ===== */
table.dataTable tbody td { padding: 0.75rem 1rem !important; font-size: 0.8125rem !important; vertical-align: middle !important; }
table.dataTable thead th { padding: 0.875rem 1rem !important; font-weight: 600 !important; font-size: 0.6875rem !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; color: #475569 !important; border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important; }
table.dataTable thead th::after { font-size: 0.6rem !important; bottom: 0.5rem !important; }
table.dataTable thead th.sorting::before, table.dataTable thead th.sorting::after { opacity: 0.3; }
table.dataTable thead th.sorting_asc::after, table.dataTable thead th.sorting_desc::after { opacity: 1; color: #3b82f6; }

/* DataTables wrapper */
.dataTables_wrapper { padding: 0 !important; }
.dataTables_wrapper .dataTables_filter { float: right; margin: 0 !important; }
.dataTables_wrapper .dataTables_filter input {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(203, 213, 225, 0.6);
    border-radius: 0.75rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}
.dataTables_wrapper .dataTables_filter input:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.dataTables_wrapper .dataTables_length { float: left; margin: 0 !important; }
.dataTables_wrapper .dataTables_length select {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(203, 213, 225, 0.6);
    border-radius: 0.75rem;
    padding: 0.5rem 1.5rem 0.5rem 0.75rem;
    font-size: 0.8125rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Export buttons as icon toolbar */
.dt-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 !important;
}

.dt-buttons .dt-button.dt-btn-icon {
    border-radius: 0.625rem !important;
    padding: 0.4rem 0.65rem !important;
    font-size: 0.875rem !important;
    border: 1px solid rgba(203, 213, 225, 0.7) !important;
    background: rgba(255, 255, 255, 0.65) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    color: #64748b !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.15s ease !important;
    min-width: auto !important;
    line-height: 1 !important;
}

.dt-buttons .dt-button.dt-btn-icon:hover {
    background: rgba(59, 130, 246, 0.9) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25) !important;
    transform: translateY(-1px);
}

/* Responsive: wrap buttons on small screens */
@media (max-width: 640px) {
    .dt-buttons .dt-button.dt-btn-icon {
        padding: 0.35rem 0.55rem !important;
        font-size: 0.8rem !important;
    }
    .dt-toolbar {
        padding: 0.625rem 0.75rem !important;
    }
}

/* Toolbar */
.dt-toolbar {
    padding: 0.875rem 1.25rem !important;
    background: rgba(248, 250, 252, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 1rem 1rem 0 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Bottom pagination area */
.dataTables_wrapper .bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(248, 250, 252, 0.6);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(226, 232, 240, 0.5);
    border-radius: 0 0 1rem 1rem;
}
.dataTables_wrapper .dataTables_length { padding: 0 !important; }
.dataTables_wrapper .dataTables_info { font-size: 0.75rem; color: #94a3b8; padding: 0 !important; }
.dataTables_wrapper .dataTables_paginate { padding: 0 !important; margin: 0 !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.625rem !important;
    margin: 0 2px !important;
    padding: 0.4rem 0.7rem !important;
    font-size: 0.8125rem !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    background: rgba(255, 255, 255, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    color: #475569 !important;
    transition: all 0.15s ease !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: rgba(59, 130, 246, 0.9) !important;
    border-color: rgba(59, 130, 246, 0.5) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: rgba(255, 255, 255, 0.8) !important;
    border-color: rgba(203, 213, 225, 0.9) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
}

/* Table container */
.table-container {
    position: relative;
    overflow: visible;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.table-container .overflow-x-auto { overflow-x: auto; }

/* Print overrides */
@media print {
    #appSidebar, header, #sidebarOverlay, .actions-cell { display: none !important; }
    main { margin-left: 0 !important; padding-top: 0 !important; }
}

/* ===== AMBIENT BACKGROUND ===== */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 10% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.03) 0%, transparent 60%);
    pointer-events: none;
}

/* ===== LOGIN / GUEST PAGES ===== */
/* No sidebar offset needed — JS only runs for authenticated users */

/* ===== RESPONSIVE GLASS STAT CARDS ===== */
@media (max-width: 640px) {
    .glass-stat {
        padding: 0.75rem !important;
    }
    .glass-stat .text-2xl {
        font-size: 1.125rem;
    }
}

/* ===== MOBILE SIDEBAR: always full overlay ===== */
@media (max-width: 1023px) {
    #appSidebar {
        transform: translateX(-100%);
    }
    html[dir="rtl"] #appSidebar {
        transform: translateX(100%);
    }
    #appSidebar.mobile-open {
        transform: translateX(0) !important;
    }
    html[dir="rtl"] #appSidebar.mobile-open {
        transform: translateX(0) !important;
    }
}
