/* ============================================
   BPC Buddy — Dark Theme
   Complete dark mode styles
   ============================================ */

/* === Tutorial Overlay === */
#tutorial-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
}
#tutorial-overlay.active { display: block; }
#tutorial-spotlight {
    position: fixed;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    border: 2px solid #60a5fa;
    z-index: 10001;
    pointer-events: none;
    transition: all 0.35s ease;
}
#tutorial-tooltip {
    position: fixed;
    z-index: 10002;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    max-width: 420px;
    min-width: 280px;
}
#tutorial-tooltip-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #60a5fa;
    margin-bottom: 0.5rem;
}
#tutorial-tooltip-text {
    font-size: 0.92rem;
    line-height: 1.55;
    color: #cbd5e1;
    margin-bottom: 1rem;
}
#tutorial-tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#tutorial-step-counter {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
}

/* === Base / Body === */
body {
    background-color: #1a1a2e;
    color: #e2e8f0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}
.list-group-item {
    color: #e2e8f0;
    background-color: transparent;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 { color: #e2e8f0; }
p { color: #cbd5e1; }
a { color: #60a5fa; }
a:hover { color: #93c5fd; }
span { color: #e2e8f0; }
label { color: #cbd5e1; }
small { color: #94a3b8; }

/* === Top Navigation Bar === */
.top-navbar {
    background-color: #16213e;
    border-bottom: 1px solid #334155;
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.navbar-brand { color: #e2e8f0 !important; }
.app-name { color: #e2e8f0; font-weight: 600; }
.logo-icon { color: #3b82f6; }
.nav-icon-btn {
    color: #94a3b8 !important;
    font-size: 1.2rem;
    text-decoration: none;
    border: none;
    padding: 0.25rem 0.5rem;
}
.nav-icon-btn:hover { color: #e2e8f0 !important; }
.user-email { color: #94a3b8; font-size: 0.9rem; }

/* === Dropdowns === */
.dropdown-menu {
    background-color: #1e293b;
    border: 1px solid #334155;
}
.dropdown-item {
    color: #e2e8f0;
}
.dropdown-item:hover, .dropdown-item:focus {
    background-color: #334155;
    color: #ffffff;
}
.dropdown-divider {
    border-color: #334155;
}

/* === Authentication Pages === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    padding: 2rem;
}
.auth-card {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.auth-link {
    color: #60a5fa;
    text-decoration: none;
}
.auth-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

/* === Forms === */
.form-control {
    background-color: #334155;
    border: 1px solid #475569;
    color: #e2e8f0;
}
.form-control:focus {
    background-color: #334155;
    border-color: #3b82f6;
    color: #e2e8f0;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}
.form-control::placeholder { color: #64748b; }
.form-select {
    background-color: #334155;
    border: 1px solid #475569;
    color: #e2e8f0;
}
.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}
textarea.form-control {
    background-color: #334155;
    border: 1px solid #475569;
    color: #e2e8f0;
}
.input-group-text {
    background-color: #475569;
    border: 1px solid #475569;
    color: #94a3b8;
}
.form-label { color: #cbd5e1; }
.form-check-input {
    background-color: #475569;
    border-color: #64748b;
}
.form-check-input:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* === Buttons === */
.btn-primary {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}
.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}
.btn-secondary {
    background-color: #475569;
    border-color: #475569;
    color: #e2e8f0;
}
.btn-secondary:hover {
    background-color: #64748b;
    border-color: #64748b;
}
.btn-success {
    background-color: #22c55e;
    border-color: #22c55e;
    color: #ffffff;
}
.btn-success:hover {
    background-color: #16a34a;
    border-color: #16a34a;
}
.btn-danger {
    background-color: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}
.btn-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}
.btn-warning {
    background-color: #f59e0b;
    border-color: #f59e0b;
    color: #000000;
}
.btn-warning:hover {
    background-color: #d97706;
    border-color: #d97706;
}
.btn-link { text-decoration: none; }

/* === Admin Layout === */
.admin-layout {
    display: flex;
    height: calc(100vh - 90px);
    overflow: hidden;
}

/* === Admin Sidebar === */
.admin-sidebar {
    width: 260px;
    min-width: 260px;
    background-color: #16213e;
    border-right: 1px solid #334155;
    overflow-y: auto;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
}
.admin-sidebar.sidebar-collapsed {
    width: 42px;
    min-width: 42px;
    overflow: hidden;
    padding-bottom: 0;
}
.admin-sidebar.sidebar-collapsed .sidebar-header span,
.admin-sidebar.sidebar-collapsed .tree-nav,
.admin-sidebar.sidebar-collapsed #sidebar-pdf-btn {
    display: none;
}
.admin-sidebar.sidebar-collapsed .sidebar-header {
    padding: 0.75rem 0.5rem;
    border-bottom: none;
    justify-content: center;
}
.sidebar-header {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #e2e8f0;
    border-bottom: 1px solid #334155;
}

/* === Tree Navigation === */
.tree-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}
.tree-parent {
    margin-bottom: 0.25rem;
}
.tree-toggle {
    display: block;
    padding: 0.6rem 1.25rem;
    color: #94a3b8;
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    transition: color 0.15s;
}
.tree-toggle:hover {
    color: #e2e8f0;
}
.tree-arrow {
    font-size: 0.7rem;
    margin-right: 0.25rem;
    transition: transform 0.2s;
}
.tree-toggle.collapsed .tree-arrow {
    transform: rotate(-90deg);
}
.tree-children {
    list-style: none;
    padding: 0;
    margin: 0;
}
.tree-children.collapsed {
    display: none;
}
.tree-child {
    padding: 0.5rem 1.25rem 0.5rem 2.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    position: relative;
}
.tree-child:hover {
    background-color: #1e293b;
    color: #e2e8f0;
}
.tree-child.active {
    background-color: #1e293b;
    color: #3b82f6;
    border-left-color: #3b82f6;
    font-weight: 500;
}

/* Sidebar action icons (fav star + home icon on each tree-child) */
.sidebar-actions {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
}
.sidebar-actions .sa-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.72rem;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}
.sidebar-actions .sa-btn:hover { opacity: 1; color: #60a5fa; }
.sidebar-actions .sa-btn.sa-fav-active { color: #f59e0b; opacity: 1; }
.sidebar-actions .sa-btn.sa-home-active { color: #60a5fa; opacity: 1; }

/* === Content Actions Bar (unified strip) === */
.content-actions-bar {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* === Favorite Star === */
.fav-star-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #475569;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    opacity: 0.5;
    transition: color 0.2s, opacity 0.2s, transform 0.2s;
}
.fav-star-btn:hover {
    opacity: 1;
    transform: scale(1.15);
    color: #94a3b8;
}
.fav-star-btn.favorited {
    color: #f59e0b;
    opacity: 1;
}
.fav-star-btn.favorited:hover {
    color: #d97706;
}

/* === Section Help Button === */
.section-help-btn {
    color: #60a5fa !important;
    opacity: 0.6;
}
.section-help-btn:hover {
    opacity: 1;
    transform: scale(1.15);
    color: #93c5fd !important;
}

/* === Feedback Thumbs (content header) === */
.fb-content-wrap {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}
.fb-thumb-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.7;
    transition: color 0.2s, opacity 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.fb-thumb-up  { color: #4ade80; }
.fb-thumb-down { color: #f87171; }
.fb-thumb-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}
.fb-thumb-btn.fb-thumb-up:hover {
    color: #86efac;
}
.fb-thumb-btn.fb-thumb-down:hover {
    color: #fca5a5;
}
.fb-thumb-btn sup {
    font-size: 0.55rem;
    font-weight: 700;
    margin-left: 1px;
    opacity: 0.8;
}

/* === AI Review Button === */
.ai-review-wrap {
    display: flex;
    align-items: center;
}
.ai-review-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 1;
    transition: transform 0.2s, filter 0.2s;
}
.ai-review-btn:hover {
    transform: scale(1.12);
    filter: brightness(1.2);
}
.ai-btn-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #fff;
    background: linear-gradient(135deg, #818cf8, #6366f1);
    border-radius: 0.3rem;
    padding: 0.15rem 0.4rem;
    line-height: 1;
}
.ai-review-md {
    font-size: 0.88rem;
    line-height: 1.65;
}
.ai-review-md h5, .ai-review-md h6 {
    color: #93c5fd;
}
.ai-review-md ul {
    padding-left: 1.2rem;
}
.ai-review-md li {
    margin-bottom: 0.15rem;
}
.ai-review-md hr {
    border-color: #334155;
}
/* User Settings Modal */
.settings-nav .list-group-item {
    background: transparent;
    color: #94a3b8;
    border: none;
    font-size: 0.82rem;
    padding: 0.55rem 1rem;
    transition: background 0.15s, color 0.15s;
}
.settings-nav .list-group-item:hover {
    background: rgba(255,255,255,0.05);
    color: #e2e8f0;
}
.settings-nav .list-group-item.active {
    background: rgba(99,102,241,0.15);
    color: #818cf8;
    font-weight: 600;
}
.provider-option {
    border-color: #334155 !important;
    transition: border-color 0.15s, background 0.15s;
}
.provider-option:has(input:checked) {
    border-color: #818cf8 !important;
    background: rgba(99,102,241,0.08);
}
.fav-item {
    display: flex !important;
    align-items: center;
    gap: 0.25rem;
}
.fav-item .fav-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.fav-item .fav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}
.fav-item .fav-subtitle {
    font-size: 0.68rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fav-delete-btn {
    padding: 0 0.15rem !important;
    line-height: 1;
    font-size: 0.7rem;
    color: #475569;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.fav-edit-btn {
    padding: 0 0.15rem !important;
    line-height: 1;
    font-size: 0.65rem;
    color: #475569;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.fav-item:hover .fav-delete-btn,
.fav-item:hover .fav-edit-btn {
    opacity: 1;
}
.fav-delete-btn:hover {
    color: #ef4444 !important;
}
.fav-edit-btn:hover {
    color: #3b82f6 !important;
}

/* === Admin Content Area === */
.admin-content {
    flex: 1;
    padding: 1.5rem 1.5rem 60px 1rem;
    background-color: #1a1a2e;
    overflow-y: auto;
}
.content-section {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 1.5rem;
}
.dash-nav-tile {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1px solid #334155;
}
.dash-nav-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    border-color: var(--bs-primary);
}
.section-title {
    color: #e2e8f0;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #334155;
}
.subsection-title {
    color: #cbd5e1;
}
.mt-section-hdr {
    background-color: #1a2744 !important;
    color: #94a3b8 !important;
}
.sidebar-popover {
    max-width: 320px;
    font-size: 0.82rem;
}
.sidebar-popover .popover-header {
    background-color: #1e3a5f;
    color: #e2e8f0;
    font-weight: 600;
    border-bottom: 1px solid #334155;
}
.sidebar-popover .popover-body {
    background-color: #1e293b;
    color: #cbd5e1;
    line-height: 1.45;
}
.sidebar-popover .popover-arrow::after {
    border-right-color: #1e293b;
}
.sidebar-help-icon {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-left: 4px;
    cursor: help;
    vertical-align: middle;
    transition: opacity 0.15s;
}
.sidebar-help-icon:hover {
    opacity: 0.9;
}

/* === Data Grid / Tables === */
.table {
    color: #e2e8f0;
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-table-border-color: #334155;
}
.table thead th {
    background-color: #16213e;
    color: #94a3b8;
    border-bottom: 2px solid #334155;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}
/* Package comparison: section header rows (26-28) match thead */
.cmp-section-header td {
    background-color: #16213e !important;
    color: #94a3b8 !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.82rem;
}
/* Package comparison: active tab contrast */
#cmp-main-tabs .nav-link.active {
    background-color: #1e293b;
    color: #e2e8f0 !important;
    border-color: #334155 #334155 #1e293b;
}
#cmp-main-tabs .nav-link:not(.active) {
    color: #94a3b8;
}
#cmp-main-tabs .nav-link:not(.active):hover {
    color: #e2e8f0;
    border-color: #475569 #475569 transparent;
}
.table tbody tr {
    border-bottom: 1px solid #334155;
    transition: background-color 0.15s;
}
.table tbody tr:hover {
    background-color: #334155 !important;
}
.table tbody tr:nth-child(even) {
    background-color: rgba(30, 41, 59, 0.5);
}
.sortable { cursor: pointer; }
.sortable:hover { color: #3b82f6; }

/* Pending user row */
.pending-row {
    background-color: rgba(245, 158, 11, 0.1) !important;
    border-left: 3px solid #f59e0b;
}
.pending-row:hover {
    background-color: rgba(245, 158, 11, 0.2) !important;
}

/* === Status Bar === */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background-color: #16213e;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 0.8rem;
    color: #94a3b8;
    z-index: 1040;
}
.status-bar-left { display: flex; align-items: center; }
.status-bar-center { display: flex; align-items: center; position: absolute; left: 50%; transform: translateX(-50%); }
.status-bar-right { display: flex; align-items: center; }

/* === Dashboard === */
.dashboard-container {
    padding: 1rem;
}
.dashboard-welcome { color: #e2e8f0; }

/* === User Guide TOC === */
.ug-toc {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #cbd5e1;
}
.ug-toc h5 { color: #e2e8f0; }
.ug-toc a { color: #93c5fd; }
.ug-toc a:hover { color: #bfdbfe; }
.ug-toc ol { color: #94a3b8; }

.dashboard-card {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* === Cards / Panels === */
.card {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}
.card .text-muted { color: #94a3b8 !important; }
.card a.text-decoration-none { color: #93c5fd; }

/* === Feature Board === */
.feature-board-card { color: #e2e8f0; }
.feature-board-card strong { color: #f1f5f9; }
.feature-board-card .small.text-muted { color: #94a3b8 !important; }
.feature-board-card .fr-vote-btn { color: #94a3b8; }
.feature-board-card .fr-vote-btn.text-success { color: #4ade80 !important; }
.feature-board-card .fr-vote-btn.text-danger  { color: #f87171 !important; }
.feature-board-card .fw-bold { color: #e2e8f0; }

/* === Modals / Dialogs === */
.modal-content {
    background-color: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
}
.modal-header {
    border-bottom: 1px solid #334155;
}
.modal-footer {
    border-top: 1px solid #334155;
}
.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* === Alerts / Notifications === */
.alert-success {
    background-color: rgba(34, 197, 94, 0.15);
    border-color: #22c55e;
    color: #4ade80;
}
.alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fbbf24;
}
.alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
}
.alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #60a5fa;
}

/* === Badges === */
.badge.bg-warning { color: #000 !important; }

/* === Text Colors === */
.text-secondary { color: #94a3b8 !important; }
.text-danger { color: #ef4444 !important; }
.text-success { color: #22c55e !important; }
.text-primary { color: #3b82f6 !important; }
.text-warning { color: #f59e0b !important; }

/* === Scrollbar (Webkit) === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* === Focus / Outline === */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* === Disabled States === */
.btn:disabled, .form-control:disabled, .form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Tooltips === */
.tooltip-inner {
    background-color: #334155;
    color: #e2e8f0;
}
.tooltip .tooltip-arrow::before {
    border-top-color: #334155;
}

/* === Placeholder Content === */
.placeholder-content {
    opacity: 0.7;
}

/* === SVG/Icon fill === */
.bi { color: inherit; }

/* === Multi-BU Comparison Heat Map === */
.mbu-heat-good    { background: rgba(34,197,94,.2);  color: #4ade80; font-weight: 600; }
.mbu-heat-bad     { background: rgba(239,68,68,.2);  color: #f87171; font-weight: 600; }
.mbu-heat-neutral { background: rgba(234,179,8,.15); color: #facc15; }
#mbu-bu-panel { border-color: #334155 !important; }
#mbu-bu-panel .form-check-label { color: #cbd5e1; }

/* === Reports Grid === */
.rpt-card {
    border: 1px solid #334155;
    border-radius: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.rpt-card-available:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,.25);
    transform: translateY(-2px);
    cursor: pointer;
}
.rpt-card-disabled {
    opacity: 0.55;
}
.rpt-icon-wrap {
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.4rem;
    background: rgba(59,130,246,.15);
    color: #60a5fa;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* === AI Chat Widget — Dark Theme === */
:root {
    --chat-bg: #1a1a2e;
    --chat-text: #e2e8f0;
    --chat-text-secondary: #94a3b8;
    --chat-border: rgba(255,255,255,.10);
    --chat-bubble-assistant: rgba(255,255,255,.08);
    --chat-hover: rgba(255,255,255,.06);
    --chat-surface: rgba(255,255,255,.05);
    --chat-accent: #3b82f6;
    --chat-shadow: rgba(0,0,0,.35);
    --chat-grip: rgba(255,255,255,.18);
    --chat-grip-hover: rgba(255,255,255,.4);
    --chat-input-bg: #2a2a3d;
}