/* 
 * EstateNexus Core Styles v4.5
 * Base + Layout + Mobile + Components (DatePicker & CRM)
 */

/* 1. ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg-main: #f8fafc;
    --sidebar-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-xl: 1.5rem; /* 24px */
    --radius-lg: 1rem;   /* 16px */
}

/* 2. СБРОС И БАЗА */
* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    overflow: hidden; /* Важно: предотвращает двойной скролл */
    -webkit-font-smoothing: antialiased;
}

/* Шрифты для цифр (как в Excel/Bloomberg) */
.font-terminal {
    font-family: 'Inter', monospace;
    font-variant-numeric: tabular-nums;
}

/* 3. ГЛАВНАЯ СЕТКА (LAYOUT) */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* САЙДБАР */
#sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 50;
    transition: width 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar: Compact mode (64px, lg:w-16) — только иконки */
@media (min-width: 1024px) {
    #sidebar.lg\:w-16 .sidebar-logo-text,
    #sidebar.lg\:w-16 .sidebar-footer-content { display: none; }
    #sidebar.lg\:w-16 .menu-group a {
        justify-content: center;
        padding: 10px 0;
    }
    #sidebar.lg\:w-16 > div:first-child {
        padding: 12px 8px;
        justify-content: center;
    }
}

/* Sidebar: Icons-only mode (48px) — минимальные иконки */
@media (min-width: 1024px) {
    #sidebar.sidebar-icons-only {
        width: 48px !important;
        overflow: hidden;
    }
    #sidebar.sidebar-icons-only .nav-item-text,
    #sidebar.sidebar-icons-only .sidebar-logo-text,
    #sidebar.sidebar-icons-only .sidebar-footer-content,
    #sidebar.sidebar-icons-only .sidebar-toggle-btn { display: none; }
    #sidebar.sidebar-icons-only .menu-group a {
        justify-content: center;
        padding: 8px 0;
    }
    #sidebar.sidebar-icons-only > div:first-child {
        padding: 8px;
        justify-content: center;
    }
}

/* ОСНОВНОЙ КОНТЕНТ */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Важно для адаптивности внутренних таблиц */
    position: relative;
}

/* ОБЛАСТЬ СКРОЛЛА СТРАНИЦЫ */
#content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0; /* Паддинги задаются внутри модулей JS */
    background: white;
}

/* 4. МОБИЛЬНАЯ АДАПТАЦИЯ */
@media (max-width: 1024px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    #sidebar.translate-x-0 {
        transform: translateX(0);
    }

    #sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        z-index: 40;
        display: none;
    }

    #sidebar-overlay.active {
        display: block;
    }

    /* На мобилках убираем скругления основной части */
    main { margin: 0 !important; border-radius: 0 !important; }
}

/* 5. ЭЛЕМЕНТЫ МЕНЮ (SIDEBAR NAV) */
.nav-item-active {
    background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.2);
    color: white !important;
}

.nav-item-active span { color: white !important; }

.nav-item-text {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* 6. ТАБЛИЦЫ (EXCEL DENSE STYLE) */
table { border-spacing: 0; width: 100%; }

thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 10;
}

tr.group:hover td {
    background-color: #eff6ff; /* blue-50 */
}

/* 7. DATERANGEPICKER (CUSTOM COMPONENT) */
.drp-container {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 100;
    flex-direction: row;
    overflow: hidden;
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.drp-presets {
    width: 180px;
    background: #f1f5f9;
    border-right: 1px solid var(--border-color);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drp-preset-btn {
    padding: 10px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    border-radius: 8px;
    transition: all 0.2s;
    border: none;
    background: transparent;
    cursor: pointer;
}

.drp-preset-btn:hover { background: #e2e8f0; color: var(--text-main); }
.drp-preset-btn.active { background: var(--primary); color: white; }

.drp-calendars { padding: 24px; display: flex; gap: 24px; }

.calendar-month { width: 260px; }

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.1em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day-head {
    text-align: center;
    font-size: 9px;
    font-weight: 900;
    color: #cbd5e1;
    padding-bottom: 10px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.1s;
}

.calendar-day:hover:not(.empty) { background: #f1f5f9; color: var(--primary); }
.calendar-day.selected { background: var(--primary) !important; color: white; }
.calendar-day.in-range { background: #eff6ff; color: var(--primary); border-radius: 0; }
.calendar-day.empty { cursor: default; }

/* 8. СКРОЛЛБАРЫ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 9. АНИМАЦИИ ВХОДА */
.animate-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Фикс DatePicker для мобилок */
@media (max-width: 768px) {
    .drp-container {
        flex-direction: column; /* Пресеты над календарем */
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 24px 24px 0 0;
        margin-top: 0;
    }

    .drp-presets {
        width: 100%;
        flex-direction: row;
        overflow-x: auto; /* Скролл пресетов по горизонтали */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 8px;
    }

    .drp-preset-btn {
        white-space: nowrap;
        padding: 6px 12px;
    }

    .drp-calendars {
        padding: 16px;
        justify-content: center;
    }
    
    /* Скрываем второй календарь на узких экранах, если их два */
    .calendar-month:nth-child(n+2) {
        display: none;
    }
}

/* Фикс хедера CRM/FB на мобилках */
.bg-slate-900.p-6.flex.justify-between {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start !important;
}

#datepicker-root {
    width: 100%;
}

#datepicker-root button {
    width: 100%;
    justify-content: space-between;
}

/* Стили гармошки (подменю) */
.menu-group .animate-in {
    animation: slideDown 0.2s ease-out forwards;
    overflow: hidden;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 200px; }
}

/* Фикс оверлея для мобилок */
#sidebar-overlay {
    display: none;
}
#sidebar-overlay.active {
    display: block !important;
}

/* Принудительный фикс для кнопки гармошки */
.nav-item-active svg, .nav-item-active span {
    color: white !important;
}
/* Выносим календарь на самый верх */
.drp-container {
    z-index: 9999 !important;
    position: absolute;
    top: 100%;
    right: 0;
}

/* Разрешаем заголовку показывать выпадающий календарь */
.bg-slate-900 {
    overflow: visible !important;
}

/* Компактная "Терминальная" таблица */
.terminal-table {
    border-spacing: 0;
    width: 100%;
}

.terminal-table th {
    padding: 8px 12px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #f1f5f9;
    color: #94a3b8;
}

.terminal-table td {
    padding: 6px 12px;
    font-size: 11px;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f1f5f9;
    white-space: nowrap;
}

.terminal-table tr:hover td {
    background-color: #f1f5f9;
}

/* Индикатор активной вкладки */
.fb-tab-btn.active {
    background: white !important;
    color: #2563eb !important;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Календарь всегда сверху */
#datepicker-root {
    position: relative;
    z-index: 1001; /* Выше липкого хедера */
}

.drp-container {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 9999 !important; /* Максимальный приоритет */
    background: white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    display: none;
    margin-top: 10px;
}
.drp-container.active { display: flex; }

/* Компактная таблица (Excel Style) */
.compact-table th {
    padding: 10px 12px !important;
    font-size: 9px !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.compact-table td {
    padding: 8px 12px !important;
    font-size: 11px !important;
    border-bottom: 1px solid #f1f5f9;
}
/* =========================================
   DATEPICKER DROPDOWN STYLES (Google Ads Style)
   ========================================= */

/* Контейнер выпадающего окна */
#drp-dropdown {
    position: absolute;
    top: 100%; /* Сразу под инпутом */
    left: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 9999 !important; /* Поверх всего */
    display: flex;
    overflow: hidden;
    min-width: 320px;
    font-family: 'Inter', sans-serif;
}

/* Анимация появления */
#drp-dropdown.animate-in {
    animation: drpFadeIn 0.2s ease-out;
}

@keyframes drpFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Сайдбар с пресетами (Сегодня, Вчера...) */
.drp-presets {
    background-color: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.drp-presets button {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.drp-presets button:hover {
    background-color: #ffffff;
    color: #2563eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Сетка календаря */
.drp-calendar-container {
    padding: 16px;
    flex: 1;
}

/* Заголовок (Месяц Год) и стрелки */
.drp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.drp-header span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1e293b;
}

.drp-header button {
    padding: 4px 8px;
    border-radius: 4px;
    color: #94a3b8;
    background: transparent;
    border: none;
    cursor: pointer;
}

.drp-header button:hover {
    background-color: #f1f5f9;
    color: #475569;
}

/* Дни недели (Пн, Вт...) */
.drp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 8px;
}

.drp-weekdays div {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #cbd5e1;
    text-transform: uppercase;
}

/* Сетка дней */
.drp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

/* Ячейка дня */
.drp-day {
    height: 32px;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s;
}

.drp-day:hover {
    background-color: #f1f5f9;
    color: #2563eb;
}

/* Выбранные дни и диапазон */
.drp-day.selected {
    background-color: #2563eb !important;
    color: white !important;
}

.drp-day.in-range {
    background-color: #eff6ff;
    color: #2563eb;
    border-radius: 0;
}

/* Custom Scrollbar for Kanban Columns */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* COSMIC CALENDAR OVERRIDES */

/* Сетка календаря */
.fc-theme-standard td, .fc-theme-standard th {
    border-color: #f1f5f9 !important; /* Очень светлый серый */
}

/* Заголовки дней (пн, вт...) */
.fc-col-header-cell-cushion {
    color: #64748b; /* slate-500 */
    font-weight: 500;
    text-transform: lowercase;
    padding: 10px 0 !important;
}

/* Номера дней */
.fc-daygrid-day-number {
    color: #334155; /* slate-700 */
    font-size: 14px;
    font-weight: 500;
    padding: 8px !important;
}

/* Сегодняшний день (кружок) */
.fc-day-today {
    background: transparent !important;
}
.fc-day-today .fc-daygrid-day-number {
    background: #3b82f6; /* blue-500 */
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px;
}

/* Убираем синюю рамку при фокусе */
.fc-scroller {
    overflow: auto !important;
}
.fc .fc-button-primary:focus {
    box-shadow: none !important;
}

/* Event styling */
.fc-event {
    cursor: pointer !important;
    padding: 2px 6px !important;
    margin: 1px 2px !important;
    transition: transform 0.1s, box-shadow 0.1s;
}
.fc-event:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10 !important;
}

/* Time grid (Day/Week) event styling */
.fc-timegrid-event {
    border-radius: 8px !important;
    padding: 4px 8px !important;
}
.fc-timegrid-slot {
    height: 40px !important;
}
.fc-timegrid-slot-label {
    font-size: 11px;
    color: #94a3b8;
}

/* Now indicator line */
.fc-timegrid-now-indicator-line {
    border-color: #ef4444 !important;
    border-width: 2px !important;
}
.fc-timegrid-now-indicator-arrow {
    border-color: #ef4444 !important;
}

/* List view (Schedule) */
.fc-list-event:hover td {
    background: #f1f5f9 !important;
}
.fc-list-day-cushion {
    background: #f8fafc !important;
    font-weight: 600;
}

/* More link */
.fc-daygrid-more-link {
    color: #3b82f6 !important;
    font-weight: 600;
    font-size: 11px;
}

/* Calendar modals */
#event-modal .bg-white,
#event-detail .bg-white {
    animation: modalSlideUp 0.2s ease-out;
}
body:has(#event-modal:not(.hidden)),
body:has(#event-detail:not(.hidden)) {
    overflow: hidden;
}

/* Selectable highlight */
.fc-highlight {
    background: rgba(59, 130, 246, 0.1) !important;
    border: 1px dashed #3b82f6 !important;
}
/* Скругление краев диапазона */
.drp-day.in-range:first-of-type { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.drp-day.in-range:last-of-type { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }

/* ===== CLIENT CARD MODAL ===== */
#client-card-modal .modal-container {
    animation: modalSlideUp 0.25s ease-out;
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
body:has(#client-card-modal) {
    overflow: hidden;
}
.timeline-date-sep {
    position: relative;
    text-align: center;
    margin: 12px 0 6px;
}
.timeline-date-sep::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #e2e8f0;
}
.timeline-date-sep span {
    position: relative;
    background: white;
    padding: 0 8px;
    font-size: 9px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =============================================
   INVESTMENT: Clean iBizz HTML descriptions
   ============================================= */
.invest-desc-clean {
    white-space: normal !important;
}
.invest-desc-clean div,
.invest-desc-clean p {
    margin: 0 0 0.5em 0 !important;
    padding: 0 !important;
}
.invest-desc-clean br + br {
    display: none;
}
.invest-desc-clean .col-md-9,
.invest-desc-clean .col-md-8,
.invest-desc-clean .offset-md-1,
.invest-desc-clean .wysiwyg-content,
.invest-desc-clean .investment-about__content,
.invest-desc-clean .investment-about__content--large {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
}
.invest-desc-clean img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.5em 0;
}

/* =============================================
   DARK THEME: CSS Custom Properties
   ============================================= */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --bg-main: #0f172a;
    --sidebar-bg: #0c1222;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --card-bg: #1e293b;
    --card-bg-hover: #334155;
    --crm-board-bg: #0f172a;
}
:root {
    --crm-board-bg: #eef2f4;
}

/* =============================================
   DARK THEME: Tailwind Class Overrides
   ============================================= */

/* --- Backgrounds --- */
[data-theme="dark"] .bg-white            { background-color: #1e293b !important; }
[data-theme="dark"] .bg-slate-50         { background-color: #0f172a !important; }
[data-theme="dark"] .bg-slate-100        { background-color: #1e293b !important; }
[data-theme="dark"] .bg-gray-50          { background-color: #0f172a !important; }
[data-theme="dark"] .bg-gray-100         { background-color: #1e293b !important; }
[data-theme="dark"] .bg-\[\#f8f9fa\]     { background-color: #0f172a !important; }
[data-theme="dark"] .bg-\[\#f8fafc\]     { background-color: #0f172a !important; }

/* --- Text Colors --- */
[data-theme="dark"] .text-slate-900      { color: #f1f5f9 !important; }
[data-theme="dark"] .text-slate-800      { color: #e2e8f0 !important; }
[data-theme="dark"] .text-slate-700      { color: #cbd5e1 !important; }
[data-theme="dark"] .text-slate-600      { color: #94a3b8 !important; }
[data-theme="dark"] .text-slate-500      { color: #94a3b8 !important; }
[data-theme="dark"] .text-gray-900       { color: #f1f5f9 !important; }
[data-theme="dark"] .text-gray-800       { color: #e2e8f0 !important; }
[data-theme="dark"] .text-gray-700       { color: #cbd5e1 !important; }
[data-theme="dark"] .text-gray-600       { color: #94a3b8 !important; }

/* --- Border Colors --- */
[data-theme="dark"] .border-slate-50     { border-color: #1e293b !important; }
[data-theme="dark"] .border-slate-100    { border-color: #334155 !important; }
[data-theme="dark"] .border-slate-200    { border-color: #334155 !important; }
[data-theme="dark"] .border-slate-300    { border-color: #475569 !important; }
[data-theme="dark"] .border-gray-100     { border-color: #334155 !important; }
[data-theme="dark"] .border-gray-200     { border-color: #334155 !important; }

/* --- Divide Colors --- */
[data-theme="dark"] .divide-slate-100 > * + * { border-color: #334155 !important; }
[data-theme="dark"] .divide-slate-200 > * + * { border-color: #334155 !important; }

/* --- Ring Colors --- */
[data-theme="dark"] .ring-slate-200      { --tw-ring-color: #334155 !important; }

/* --- Hover States --- */
[data-theme="dark"] .hover\:bg-slate-50:hover    { background-color: #334155 !important; }
[data-theme="dark"] .hover\:bg-slate-100:hover   { background-color: #334155 !important; }
[data-theme="dark"] .hover\:bg-white:hover       { background-color: #334155 !important; }
[data-theme="dark"] .hover\:bg-blue-50:hover     { background-color: rgba(59,130,246,0.15) !important; }
[data-theme="dark"] .hover\:bg-rose-50:hover     { background-color: rgba(244,63,94,0.15) !important; }
[data-theme="dark"] .hover\:bg-emerald-50:hover  { background-color: rgba(16,185,129,0.15) !important; }
[data-theme="dark"] .hover\:text-slate-600:hover  { color: #e2e8f0 !important; }
[data-theme="dark"] .hover\:text-slate-900:hover  { color: #f1f5f9 !important; }
[data-theme="dark"] .hover\:border-blue-300:hover { border-color: #3b82f6 !important; }
[data-theme="dark"] .hover\:border-slate-300:hover { border-color: #475569 !important; }

/* --- Colored Backgrounds (translucent in dark) --- */
[data-theme="dark"] .bg-blue-50          { background-color: rgba(59,130,246,0.15) !important; }
[data-theme="dark"] .bg-emerald-50       { background-color: rgba(16,185,129,0.15) !important; }
[data-theme="dark"] .bg-rose-50          { background-color: rgba(244,63,94,0.15) !important; }
[data-theme="dark"] .bg-amber-50         { background-color: rgba(245,158,11,0.15) !important; }
[data-theme="dark"] .bg-purple-50        { background-color: rgba(139,92,246,0.15) !important; }
[data-theme="dark"] .bg-cyan-50          { background-color: rgba(6,182,212,0.15) !important; }
[data-theme="dark"] .bg-orange-50        { background-color: rgba(249,115,22,0.15) !important; }
[data-theme="dark"] .bg-blue-100         { background-color: rgba(59,130,246,0.2) !important; }
[data-theme="dark"] .bg-emerald-100      { background-color: rgba(16,185,129,0.2) !important; }
[data-theme="dark"] .bg-rose-100         { background-color: rgba(244,63,94,0.2) !important; }
[data-theme="dark"] .bg-amber-100        { background-color: rgba(245,158,11,0.2) !important; }
[data-theme="dark"] .bg-purple-100       { background-color: rgba(139,92,246,0.2) !important; }
[data-theme="dark"] .bg-slate-200        { background-color: #334155 !important; }
[data-theme="dark"] .bg-amber-100        { background-color: rgba(245,158,11,0.2) !important; }
[data-theme="dark"] .bg-violet-50        { background-color: rgba(139,92,246,0.15) !important; }
[data-theme="dark"] .bg-slate-50\/50     { background-color: rgba(15,23,42,0.5) !important; }

/* --- Text Colors (colored) --- */
[data-theme="dark"] .text-blue-800       { color: #93c5fd !important; }
[data-theme="dark"] .text-violet-700     { color: #a78bfa !important; }

/* --- Notification Shadow --- */
[data-theme="dark"] .shadow-slate-300\/50 { --tw-shadow-color: rgba(0,0,0,0.3) !important; }

/* --- Form Inputs --- */
[data-theme="dark"] input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #475569 !important;
}
[data-theme="dark"] option {
    background-color: #1e293b;
    color: #e2e8f0;
}

/* --- Shadows (darken in dark mode) --- */
[data-theme="dark"] .shadow-sm  { box-shadow: 0 1px 2px rgba(0,0,0,0.3) !important; }
[data-theme="dark"] .shadow-md  { box-shadow: 0 4px 6px -1px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] .shadow-lg  { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] .shadow-xl  { box-shadow: 0 20px 25px -5px rgba(0,0,0,0.5) !important; }
[data-theme="dark"] .shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6) !important; }

/* --- Body & Content Area --- */
[data-theme="dark"] body        { background-color: #0f172a !important; color: #e2e8f0 !important; }
[data-theme="dark"] #content-area { background-color: #0f172a !important; }

/* --- Tables --- */
[data-theme="dark"] thead th                    { background: #1e293b !important; color: #94a3b8 !important; }
[data-theme="dark"] .terminal-table th          { background: #1e293b !important; border-color: #334155 !important; color: #64748b !important; }
[data-theme="dark"] .terminal-table td          { border-color: #334155 !important; color: #cbd5e1 !important; }
[data-theme="dark"] .terminal-table tr:hover td { background-color: #334155 !important; }
[data-theme="dark"] .compact-table td           { border-color: #334155 !important; }
[data-theme="dark"] tr.group:hover td           { background-color: rgba(59,130,246,0.1) !important; }

/* --- Scrollbars --- */
[data-theme="dark"] ::-webkit-scrollbar-thumb       { background: #475569 !important; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover  { background: #64748b !important; }

/* --- DatePicker (drp) --- */
[data-theme="dark"] #drp-dropdown            { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .drp-container           { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .drp-presets             { background-color: #0f172a !important; border-color: #334155 !important; }
[data-theme="dark"] .drp-presets button      { color: #94a3b8 !important; }
[data-theme="dark"] .drp-presets button:hover { background: #334155 !important; color: #e2e8f0 !important; }
[data-theme="dark"] .drp-header span         { color: #e2e8f0 !important; }
[data-theme="dark"] .drp-header button:hover { background-color: #334155 !important; }
[data-theme="dark"] .drp-day                 { color: #cbd5e1 !important; }
[data-theme="dark"] .drp-day:hover           { background-color: #334155 !important; }
[data-theme="dark"] .drp-day.in-range        { background-color: rgba(59,130,246,0.15) !important; color: #3b82f6 !important; }
[data-theme="dark"] .drp-weekdays div        { color: #475569 !important; }
[data-theme="dark"] .calendar-day:hover:not(.empty) { background: #334155 !important; }
[data-theme="dark"] .calendar-day.in-range   { background: rgba(59,130,246,0.15) !important; }
[data-theme="dark"] .calendar-day-head       { color: #475569 !important; }

/* --- FullCalendar --- */
[data-theme="dark"] .fc-theme-standard td,
[data-theme="dark"] .fc-theme-standard th    { border-color: #334155 !important; }
[data-theme="dark"] .fc-col-header-cell-cushion { color: #64748b !important; }
[data-theme="dark"] .fc-daygrid-day-number   { color: #e2e8f0 !important; }
[data-theme="dark"] .fc-list-day-cushion     { background: #1e293b !important; color: #94a3b8 !important; }
[data-theme="dark"] .fc-list-event:hover td  { background: #334155 !important; }

/* --- Tab active state --- */
[data-theme="dark"] .fb-tab-btn.active       { background: #1e293b !important; color: #3b82f6 !important; }

/* --- Timeline date separator --- */
[data-theme="dark"] .timeline-date-sep::before { background: #334155 !important; }
[data-theme="dark"] .timeline-date-sep span    { background: #1e293b !important; }

/* =============================================
   GLASS SIDEBAR (both themes)
   ============================================= */
#sidebar {
    background: rgba(12, 18, 34, 0.65) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    transition: background 0.3s ease, backdrop-filter 0.3s ease;
}
/* Solid fallback when glass is disabled */
[data-sidebar-glass="off"] #sidebar {
    background: #0c1222 !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-right-color: #1e293b !important;
}
#sidebar .sidebar-logo-text {
    color: #f1f5f9 !important;
}
#sidebar .text-slate-400 {
    color: #94a3b8 !important;
}
#sidebar .border-slate-100,
#sidebar .border-slate-200 {
    border-color: rgba(255, 255, 255, 0.06) !important;
}
#sidebar .bg-white,
#sidebar .bg-slate-50 {
    background-color: transparent !important;
}
/* Glass hover on menu items */
#sidebar .hover\:bg-slate-100:hover,
#sidebar .hover\:bg-slate-50:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-radius: 0.75rem;
    transition: background-color 0.2s ease;
}
#sidebar .sidebar-footer-content {
    border-color: rgba(255, 255, 255, 0.06) !important;
}
#sidebar .sidebar-footer-content button {
    color: #94a3b8 !important;
}
#sidebar .sidebar-footer-content button:hover {
    color: #60a5fa !important;
}

/* =============================================
   GLASSMORPHISM UTILITY
   ============================================= */
.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
}
[data-theme="dark"] .glass-card {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(148, 163, 184, 0.08);
}

/* =============================================
   BACKGROUND / WALLPAPER ON WRAPPER
   ============================================= */
#app-wrapper {
    position: relative;
    background-color: var(--bg-main, #f8fafc);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background 0.5s ease;
}
#app-wrapper[data-bg-type="image"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 0;
}
#app-wrapper[data-bg-type="image"] > * {
    position: relative;
    z-index: 1;
}
/* Make main transparent when wrapper has background */
#app-wrapper[data-bg-type="image"] main,
#app-wrapper[data-bg-type="gradient"] main,
#app-wrapper[data-bg-type="solid"] main {
    background: transparent !important;
}

/* =============================================
   THEME TOGGLE BUTTON
   ============================================= */
#theme-toggle-btn {
    transition: all 0.3s ease;
}
#theme-toggle-btn:hover {
    transform: rotate(15deg);
}
[data-theme="dark"] #theme-toggle-btn {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
[data-theme="dark"] #theme-toggle-btn svg {
    color: #fbbf24 !important;
}