/* ============================================
   InvestAssist Custom Styles
   GSE Investment Intelligence System
   ============================================ */

/* --- GSE Brand Colors --- */
:root {
    --gse-primary: #b06f29;       /* Golden Bronze */
    --gse-primary-light: #c9894a;
    --gse-primary-dark: #8a571f;
    --gse-primary-rgb: 176, 111, 41;
    --gse-secondary: #1b365f;     /* Dark Navy */
    --gse-secondary-light: #2a4a7a;
    --gse-secondary-dark: #122442;
    --gse-secondary-rgb: 27, 54, 95;

    /* Override template's Bootstrap primary */
    --bs-primary: #b06f29 !important;
    --primary: #b06f29 !important;
}

/* --- Override ALL template violet/purple (#6e00ff, #370080) --- */
.sidebar {
    background: var(--gse-secondary) !important;
}

/* Template uses these for various purple elements */
[class*="bg-primary"],
.bg-primary-light {
    background-color: var(--gse-primary) !important;
}

/* Checkbox/Radio primary color */
.form-check-input:checked {
    background-color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
}

/* Dropdown active states */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--gse-primary) !important;
}

/* Nav pills/tabs active */
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background-color: var(--gse-primary) !important;
}

/* List group active */
.list-group-item.active {
    background-color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
}

/* Accordion active */
.accordion-button:not(.collapsed) {
    color: var(--gse-primary) !important;
    background-color: rgba(var(--gse-primary-rgb), 0.1) !important;
}
.accordion-button:focus {
    border-color: var(--gse-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--gse-primary-rgb), 0.25) !important;
}

/* Border primary */
.border-primary {
    border-color: var(--gse-primary) !important;
}

/* Table primary */
.table-primary {
    background-color: rgba(var(--gse-primary-rgb), 0.1) !important;
}

/* Switch/toggle */
.form-switch .form-check-input:checked {
    background-color: var(--gse-primary) !important;
}

/* --- Primary Color Overrides --- */
.btn-primary {
    background-color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
    color: #fff !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--gse-primary-dark) !important;
    border-color: var(--gse-primary-dark) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--gse-primary-rgb), 0.25) !important;
}
.btn-outline-primary {
    color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
    background-color: transparent !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
    color: #fff !important;
}

/* --- Secondary Color Overrides --- */
.btn-secondary {
    background-color: var(--gse-secondary) !important;
    border-color: var(--gse-secondary) !important;
    color: #fff !important;
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
    background-color: var(--gse-secondary-dark) !important;
    border-color: var(--gse-secondary-dark) !important;
}
.btn-outline-secondary {
    color: var(--gse-secondary) !important;
    border-color: var(--gse-secondary) !important;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background-color: var(--gse-secondary) !important;
    color: #fff !important;
}

/* --- Links --- */
a {
    color: var(--gse-primary);
}
a:hover {
    color: var(--gse-primary-dark);
}

/* --- Background utilities --- */
.bg-primary {
    background-color: var(--gse-primary) !important;
}
.bg-secondary {
    background-color: var(--gse-secondary) !important;
}
.text-primary {
    color: var(--gse-primary) !important;
}
.text-secondary {
    color: var(--gse-secondary) !important;
}

/* --- Form focus states --- */
.form-control:focus,
.form-select:focus {
    border-color: var(--gse-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--gse-primary-rgb), 0.15) !important;
}

/* --- Sidebar/Navigation --- */
.nav-header {
    background-color: var(--gse-secondary) !important;
}
.dlabnav {
    background-color: var(--gse-secondary) !important;
}
.dlabnav .metismenu > li.mm-active > a,
.dlabnav .metismenu > li:hover > a,
.dlabnav .metismenu > li:focus > a {
    color: var(--gse-primary) !important;
}
.dlabnav .metismenu > li.mm-active > a i,
.dlabnav .metismenu > li:hover > a i {
    color: var(--gse-primary) !important;
}
[data-sidebar-style="full"] .dlabnav .metismenu > li.mm-active > a,
[data-sidebar-style="mini"] .dlabnav .metismenu > li.mm-active > a {
    background: rgba(var(--gse-primary-rgb), 0.1) !important;
}

/* --- Header --- */
.header {
    background-color: #fff;
    border-bottom: 1px solid rgba(var(--gse-secondary-rgb), 0.1);
}
/* Desktop only — on mobile the theme toggle lives in the avatar menu */
@media only screen and (min-width: 768px) {
    .dark-light-toggle {
        display: block !important;
    }
}
.header-right .header-profile > a.nav-link {
    border-color: var(--gse-primary) !important;
}

/* --- Cards accent --- */
.card .card-header {
    border-bottom: 1px solid rgba(var(--gse-secondary-rgb), 0.1);
}

/* --- Pagination active state --- */
.page-item.active .page-link {
    background-color: var(--gse-primary) !important;
    border-color: var(--gse-primary) !important;
}
.page-link {
    color: var(--gse-secondary);
}
.page-link:hover {
    color: var(--gse-primary);
}

/* --- Badges --- */
.badge.bg-primary {
    background-color: var(--gse-primary) !important;
}
.badge.bg-secondary {
    background-color: var(--gse-secondary) !important;
}

/* --- Progress bars --- */
.progress-bar {
    background-color: var(--gse-primary);
}

/* --- Spinner --- */
.spinner-border.text-primary {
    color: var(--gse-primary) !important;
}

/* --- Alert primary --- */
.alert-primary {
    background-color: rgba(var(--gse-primary-rgb), 0.1);
    border-color: rgba(var(--gse-primary-rgb), 0.2);
    color: var(--gse-primary-dark);
}

/* --- Stock Background Colors (replacing crypto) --- */
.bg-gse-1 { background: var(--gse-secondary) !important; } /* Navy */
.bg-gse-2 { background: #1b5e20 !important; } /* Forest green */
.bg-gse-3 { background: var(--gse-primary) !important; } /* Golden Bronze */
.bg-gse-4 { background: #880e4f !important; } /* Dark rose */
.bg-gse-5 { background: #4a148c !important; } /* Purple */
.bg-gse-6 { background: #004d40 !important; } /* Teal */

/* --- Impact Badges (News Analysis) --- */
.badge-positive { background-color: #36B37E; color: #fff; }
.badge-neutral  { background-color: #FFAB00; color: #273444; }
.badge-negative { background-color: #FF5630; color: #fff; }

/* --- Severity Badges (AI Insights) --- */
.badge-severity-high   { background-color: #FF5630; color: #fff; }
.badge-severity-medium { background-color: #FFAB00; color: #273444; }
.badge-severity-low    { background-color: #00B8D9; color: #fff; }

/* --- Watchlist Labels --- */
.badge-rising       { background-color: #36B37E; color: #fff; }
.badge-stable       { background-color: #00B8D9; color: #fff; }
.badge-needs-review { background-color: #FFAB00; color: #273444; }
.badge-illiquid     { background-color: #8492A6; color: #fff; }

/* --- Hub Tile Cards --- */
.hub-tile {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(var(--gse-secondary-rgb), 0.1);
}
.hub-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: var(--gse-primary);
}
.hub-tile-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(var(--gse-primary-rgb), 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.hub-tile-icon i {
    font-size: 1.8rem;
    color: var(--gse-primary);
}
.hub-tile-title {
    color: var(--gse-secondary);
    font-weight: 600;
}
.dark-theme .hub-tile {
    border-color: #2b2b40;
}
.dark-theme .hub-tile:hover {
    border-color: var(--gse-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.dark-theme .hub-tile-icon {
    background: rgba(var(--gse-primary-rgb), 0.2);
}
.dark-theme .hub-tile-title {
    color: #fff;
}

/* --- AI Output Styling --- */
.ai-output-card {
    border-left: 4px solid var(--gse-primary);
}
.ai-disclaimer {
    font-size: 0.75rem;
    color: #8492A6;
    font-style: italic;
    padding: 8px 0;
}

/* --- Stock Symbol Badge --- */
.stock-badge {
    display: inline-block;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(var(--gse-primary-rgb), 0.1);
    color: var(--gse-primary);
}
.dark-theme .stock-badge {
    background: rgba(var(--gse-primary-rgb), 0.25);
    color: var(--gse-primary-light);
}

/* --- Trade Type Badges --- */
.badge-buy {
    background-color: #36B37E;
    color: #fff;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 4px;
}
.badge-sell {
    background-color: #FF5630;
    color: #fff;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 4px;
}

/* --- P/L Colors --- */
.text-profit { color: #36B37E; }
.text-loss   { color: #FF5630; }

/* --- Quick Action Cards --- */
.quick-action-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}
.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- Getting Started Checklist --- */
.checklist-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
}
.checklist-item .check-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: 0.7rem;
}
.checklist-item .check-icon.done {
    background: #36B37E;
    color: #fff;
}
.checklist-item .check-icon.pending {
    background: #EFF2F7;
    color: #8492A6;
}

/* --- Report Status Badges --- */
.badge-uploaded   { background-color: #8492A6; color: #fff; }
.badge-processing { background-color: #FFAB00; color: #273444; }
.badge-analyzed   { background-color: #36B37E; color: #fff; }
.badge-failed     { background-color: #FF5630; color: #fff; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #8492A6;
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}
.empty-state h5 {
    margin-bottom: 8px;
    color: #273444;
}
.dark-theme .empty-state h5 {
    color: #EFF2F7;
}

/* --- Sidebar Active Override for InvestAssist routes --- */
.sidebar .menu-item.active a {
    color: var(--gse-primary);
}

/* =====================================================
   MOBILE RESPONSIVE FIXES
   ===================================================== */

/* Make tables horizontally scrollable on mobile */
.table-responsive-stack {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    /* Card adjustments */
    .card-body {
        padding: 1rem;
    }

    /* Stack form filters vertically on mobile */
    .filter-form .row {
        flex-direction: column;
    }

    .filter-form .col-md-6,
    .filter-form .col-md-4,
    .filter-form .col-md-2 {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Smaller buttons on mobile */
    .btn-group-mobile .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Table improvements for mobile */
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Hide less important columns on mobile */
    .d-mobile-none {
        display: none !important;
    }

    /* Stack action buttons */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .action-buttons .btn {
        width: 100%;
    }

    /* Dashboard stat cards - 2 columns on mobile */
    .stat-card-row .col-xl-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Dashboard chart cards full width */
    .chart-card {
        margin-bottom: 1rem;
    }

    /* Smaller headings on mobile */
    .card-title {
        font-size: 1rem;
    }

    h4.card-title {
        font-size: 1.1rem;
    }

    /* Pagination centered and smaller */
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }

    .pagination .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Empty state adjustments */
    .empty-state .fa-3x {
        font-size: 2rem !important;
    }

    /* Form adjustments */
    .form-label {
        font-size: 0.9rem;
    }

    /* Header profile info */
    .header-profile .header-info {
        display: none;
    }

    /* Reduce spacing in content body */
    .content-body {
        padding: 0.5rem;
    }
}

@media (max-width: 576px) {
    /* Extra small screens */
    .stat-card-row .col-xl-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Stack all buttons vertically */
    .btn-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-toolbar .btn {
        width: 100%;
    }

    /* Smaller badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* Hide extended info */
    .d-xs-none {
        display: none !important;
    }

    /* Trade journal - show only essential columns */
    .trades-table .col-notes,
    .trades-table .col-fees {
        display: none;
    }
}

/* Sidebar overlay for mobile */
@media (max-width: 991px) {
    .dlabnav {
        position: fixed;
        z-index: 1050;
    }

    .menu-toggle .dlabnav {
        left: 0;
    }

    /* Add overlay when sidebar is open */
    .menu-toggle::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
    }

    .page-link {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .dropdown-item {
        padding: 0.75rem 1rem;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .dlabnav,
    .nav-header,
    .header,
    .btn,
    .pagination,
    .filter-form {
        display: none !important;
    }

    .content-body {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
}

/* ============================================
   Dark Theme Support
   Override template purple (#1d0042, #2c0066)
   with neutral dark tones
   ============================================ */

/* Body / main background */
.dark-theme {
    background-color: #131722 !important;
    color: #a2a5b9 !important;
}

.dark-theme .header {
    background-color: #1e1e2d !important;
    border-bottom-color: #2b2b40 !important;
}

.dark-theme .sidebar {
    background: #1e1e2d !important;
}

/* ============================================
   Privacy mode (mask all figures)
   ============================================ */
/* Blur every chart so axis labels / bars can't hint at values */
.privacy-mode .apexcharts-canvas {
    filter: blur(9px);
    pointer-events: none;
}

/* Anti-flash: keep content invisible until the mask's first pass is done */
body.privacy-mode #main-wrapper {
    visibility: hidden;
}

body.privacy-mode.privacy-ready #main-wrapper {
    visibility: visible;
}

/* Header controls: one consistent gap governs spacing at every width
   (the theme's space-between + per-item margins made it ragged) */
.header-right {
    justify-content: flex-end !important;
    gap: 14px;
}

.header-right .mode-toggle-form,
.header-right .privacy-toggle,
.header-right .dark-light-toggle,
.header-right .notification {
    margin: 0 !important;
}

/* Personal / Family mode toggle */
.mode-toggle-form {
    display: flex;
    align-items: center;
}

.mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--gse-primary, #6554C0);
    border-radius: 20px;
    background: transparent;
    color: var(--gse-primary, #6554C0);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mode-toggle:hover {
    background: #6554C015;
}

.mode-toggle--family {
    background: var(--gse-primary, #6554C0);
    color: #fff;
}

.mode-toggle--family:hover {
    background: var(--gse-primary, #6554C0);
    opacity: 0.9;
}

@media only screen and (max-width: 576px) {
    .mode-toggle span { display: none; }
    .mode-toggle { padding: 5px 9px; }
}

/* Uploaded avatar photo */
.avatar-photo {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

/* Initials avatar (replaces the theme's placeholder profile image) */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--gse-primary, #6554C0);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    user-select: none;
}

/* Header eye control — match the dark/light toggle look */
.privacy-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.privacy-toggle a {
    color: inherit;
    font-size: 20px;
    line-height: 1;
    padding: 6px;
    border-radius: 8px;
}

.privacy-toggle a:hover {
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
}

.dark-theme .privacy-toggle a:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Mobile stacked tables (jquery.basictable adds
   .bt + data-th below 768px, but ships no CSS).
   Each row becomes a separated card; each cell a
   label/value line.
   ============================================ */
@media only screen and (max-width: 767px) {
    table.bt thead { display: none; }

    table.bt,
    table.bt tbody,
    table.bt tr,
    table.bt td {
        display: block;
        width: 100%;
    }

    table.bt tbody tr {
        margin-bottom: 14px;
        padding: 6px 0;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    /* Kill the stripe backgrounds — cards handle separation now */
    table.bt.table-striped > tbody > tr:nth-of-type(odd) > * {
        --bs-table-accent-bg: transparent;
        background: transparent;
    }

    table.bt td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 16px;
        border: none;
        text-align: right;
    }

    table.bt td + td {
        border-top: 1px dashed rgba(0, 0, 0, 0.07);
    }

    table.bt td[data-th]::before {
        content: attr(data-th);
        font-weight: 600;
        font-size: 12px;
        color: #6c757d;
        text-align: left;
        flex-shrink: 0;
    }

    /* Cells without a header label (e.g. empty states) center */
    table.bt td:not([data-th]) {
        justify-content: center;
        text-align: center;
    }

    /* Compact action buttons inside stacked cards */
    table.bt td .btn {
        padding: 4px 10px;
        font-size: 13px;
        line-height: 1.4;
    }

    table.bt td form {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin: 0;
    }

    table.bt td input[type="date"].form-control-sm {
        width: 120px !important;
        padding: 3px 6px;
        font-size: 12px;
    }


    .dark-theme table.bt tbody tr {
        background: #1e1e2d;
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: none;
    }

    .dark-theme table.bt td + td {
        border-top-color: rgba(255, 255, 255, 0.06);
    }

    .dark-theme table.bt td[data-th]::before {
        color: #a2a5b9;
    }
}

/* ============================================
   Desktop sidebar rail: uniform icon spacing.
   The theme assumed ~6 icons (100px top gap,
   20px per-item margins, logout pinned absolute)
   — with 11+ items that overflows and overlaps.
   ============================================ */
@media only screen and (min-width: 768px) {
    .brand-logo {
        margin-top: 16px;
    }

    .sidebar .menu {
        margin-top: 16px;
        display: flex;
        height: calc(100% - 70px);
    }

    .sidebar .menu ul {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        flex: 1;
        width: 100%;
        margin: 0;
        padding: 0 0 8px;
        overflow-y: auto;
        scrollbar-width: none;
    }

    .sidebar .menu ul::-webkit-scrollbar {
        display: none;
    }

    .sidebar .menu ul li a {
        margin-bottom: 0;
        padding: 11px 15px;
        display: inline-block;
    }

    /* Center the icon group between the logo and the logout icon:
       auto margins above the first item and before logout split the
       leftover space evenly around the group */
    .sidebar .menu ul li:first-child {
        margin-top: auto;
    }

    /* Logout sits at the rail's foot via flex, not absolute pinning */
    .sidebar .menu ul li.logout {
        position: static;
        margin-top: auto;
    }

    /* No room for the copyright line in a tall icon rail */
    .sidebar .copyright {
        display: none;
    }
}

/* ============================================
   Mobile bottom-nav overflow ("More" menu)
   Desktop keeps every icon in the rail; below
   768px secondary items collapse behind the
   hamburger toggle.
   ============================================ */
.sidebar .nav-more-toggle {
    display: none;
}

.ia-more-menu {
    display: none;
    position: fixed;
    bottom: 62px;
    right: 10px;
    z-index: 1050;
    min-width: 210px;
    padding: 8px;
    border-radius: 12px;
    background: var(--gse-secondary, #370080);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.ia-more-menu.show {
    display: block;
}

.ia-more-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
}

.ia-more-menu a:hover,
.ia-more-menu a:focus {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.ia-more-menu a i {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.dark-theme .ia-more-menu {
    background: #1e1e2d;
}

@media only screen and (max-width: 767px) {
    .sidebar .nav-more-item {
        display: none;
    }

    .sidebar .nav-more-toggle {
        display: block;
    }

    /* Keep the chatbot bubble clear of the bottom nav bar */
    .ia-chatbot {
        bottom: 66px;
        right: 12px;
    }
}

.dark-theme .content-body {
    background-color: #131722 !important;
}

/* Cards in dark theme */
.dark-theme .card {
    background-color: #1e1e2d !important;
    border-color: #2b2b40 !important;
}

.dark-theme .card .card-header {
    border-bottom-color: #2b2b40 !important;
}

/* Dropdown menus */
.dark-theme .dropdown-menu {
    background-color: #1e1e2d !important;
    border-color: #2b2b40 !important;
}

/* Tables in dark theme */
.dark-theme .table {
    color: #a2a5b9;
}

.dark-theme .table thead th {
    background-color: #1e1e2d;
    border-color: #2b2b40;
    color: #fff;
}

.dark-theme .table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #1a1f2e !important;
    color: #a2a5b9 !important;
}

/* Form controls in dark theme */
.dark-theme .form-control,
.dark-theme .form-select {
    background-color: #1a1f2e;
    border-color: #2b2b40;
    color: #a2a5b9;
}

.dark-theme .form-control:focus,
.dark-theme .form-select:focus {
    background-color: #1a1f2e;
    border-color: var(--gse-primary);
    color: #fff;
}

/* Muted text in dark theme */
.dark-theme .text-muted {
    color: #6c757d !important;
}

/* Secondary badge in dark theme */
.dark-theme .badge.bg-secondary {
    background-color: #2b2b40 !important;
}

/* Empty state styling for dark theme */
.dark-theme .empty-state-icon {
    color: #6c757d;
}

/* Pagination dark theme */
.dark-theme .page-link {
    background-color: #1e1e2d;
    border-color: #2b2b40;
    color: #a2a5b9;
}

.dark-theme .page-item.active .page-link {
    background-color: var(--gse-primary);
    border-color: var(--gse-primary);
}

.dark-theme .page-item.disabled .page-link {
    background-color: #131722;
    border-color: #2b2b40;
    color: #565674;
}

/* Alert styling in dark theme */
.dark-theme .alert-info {
    background-color: rgba(var(--gse-secondary-rgb), 0.2);
    border-color: rgba(var(--gse-secondary-rgb), 0.3);
    color: #7da8ff;
}

.dark-theme .alert-success {
    background-color: rgba(43, 193, 85, 0.1);
    border-color: rgba(43, 193, 85, 0.2);
    color: #5dd879;
}

.dark-theme .alert-danger {
    background-color: rgba(255, 46, 46, 0.1);
    border-color: rgba(255, 46, 46, 0.2);
    color: #ff6b6b;
}

/* Welcome card and misc backgrounds */
.dark-theme .welcome-profile {
    background-color: #1e1e2d !important;
}

.dark-theme .invite-content {
    color: #a2a5b9;
}

/* Profile dropdown */
.dark-theme .profile_log .dropdown-menu .dropdown-item {
    border-top-color: #2b2b40 !important;
    color: #a2a5b9 !important;
}

.dark-theme .user-info span,
.dark-theme .user-balance span {
    color: #a2a5b9 !important;
}

/* ============================================
   Chatbot Widget
   ============================================ */
[x-cloak] { display: none !important; }

.ia-chatbot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1080;
    font-family: inherit;
}

.ia-chatbot__bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--gse-primary);
    color: #fff;
    font-size: 24px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}
.ia-chatbot__bubble:hover {
    background: var(--gse-primary-dark);
    transform: scale(1.05);
}

.ia-chatbot__drawer {
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.ia-chatbot__header {
    background: var(--gse-secondary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ia-chatbot__subtitle {
    font-size: 11px;
    opacity: 0.75;
    font-weight: 400;
}
.ia-chatbot__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.ia-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f8fa;
}

/* Typing indicator while the assistant is thinking */
.ia-chatbot__msg--loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ia-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ia-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gse-primary, #6554C0);
    opacity: 0.35;
    animation: ia-typing-bounce 1.2s infinite ease-in-out;
}

.ia-typing span:nth-child(2) { animation-delay: 0.2s; }
.ia-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ia-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.ia-chatbot__hint {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    padding: 12px 8px;
    line-height: 1.5;
}

.ia-chatbot__suggestion {
    display: block;
    width: 100%;
    margin: 0 0 6px;
    padding: 7px 10px;
    font-size: 12px;
    text-align: left;
    color: #6554C0;
    background: #6554C012;
    border: 1px solid #6554C030;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ia-chatbot__suggestion:hover {
    background: #6554C025;
}

.dark-theme .ia-chatbot__suggestion {
    color: #a99ef0;
    background: #6554C022;
    border-color: #6554C045;
}

.ia-chatbot__msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.ia-chatbot__msg--user {
    align-self: flex-end;
    background: var(--gse-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ia-chatbot__msg--assistant {
    align-self: flex-start;
    background: #fff;
    color: #2a2a2a;
    border: 1px solid #e6e8ed;
    border-bottom-left-radius: 4px;
}
.ia-chatbot__msg--loading {
    opacity: 0.65;
    font-style: italic;
}

.ia-chatbot__form {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #e6e8ed;
    background: #fff;
    flex-shrink: 0;
}
.ia-chatbot__form input {
    flex: 1;
    border: 1px solid #d0d4dc;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
}
.ia-chatbot__form input:focus {
    border-color: var(--gse-primary);
    box-shadow: 0 0 0 2px rgba(var(--gse-primary-rgb), 0.15);
}

.ia-chatbot__disclaimer {
    font-size: 10px;
    color: #8c92a0;
    text-align: center;
    padding: 4px 8px 6px;
    background: #fff;
    border-top: 1px solid #f0f1f4;
    flex-shrink: 0;
}

.dark-theme .ia-chatbot__drawer {
    background: #1f2230;
    border-color: rgba(255, 255, 255, 0.08);
}
.dark-theme .ia-chatbot__messages {
    background: #181a24;
}
.dark-theme .ia-chatbot__msg--assistant {
    background: #2a2e3d;
    color: #e2e4ec;
    border-color: rgba(255, 255, 255, 0.06);
}
.dark-theme .ia-chatbot__form,
.dark-theme .ia-chatbot__disclaimer {
    background: #1f2230;
    border-top-color: rgba(255, 255, 255, 0.08);
}
.dark-theme .ia-chatbot__form input {
    background: #2a2e3d;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e4ec;
}
.dark-theme .ia-chatbot__hint {
    color: #a2a5b9;
}

@media (max-width: 576px) {
    .ia-chatbot { bottom: 66px; right: 12px; }
    .ia-chatbot__drawer { width: 92vw; height: 70vh; }
}
