/* ============================================================================
   Dark Mode — Global Overrides
   Activated via: <html data-bs-theme="dark">
   Bootstrap 5.3 handles most of its own components; this file covers the
   custom styles that use hardcoded light colors.
   ============================================================================ */

/* ── Body ── */
[data-bs-theme="dark"] body {
    background-color: #0f172a !important;
    color: #e2e8f0;
}

/* ── Utility overrides ── */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light {
    background-color: #1e293b !important;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .border {
    border-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #64748b !important;
}

/* ── Footer ── */
[data-bs-theme="dark"] .site-footer {
    background: rgba(255, 255, 255, .03) !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .site-footer .text-muted {
    color: #64748b !important;
}

/* ── Cards (Bootstrap + custom) ── */
[data-bs-theme="dark"] .card {
    background-color: #1e293b !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .card-header {
    background-color: #162032 !important;
    border-color: rgba(255, 255, 255, .08) !important;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #162032 !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .card_doc_search {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

/* ── Tables ── */
[data-bs-theme="dark"] .table {
    color: #e2e8f0;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255, 255, 255, .08);
}

[data-bs-theme="dark"] .table-secondary,
[data-bs-theme="dark"] #docTable thead th {
    background-color: #162032 !important;
    color: #94a3b8 !important;
    border-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] #docTable tbody tr:hover {
    background-color: #1a2744 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .table-bordered td,
[data-bs-theme="dark"] .table-bordered th {
    border-color: rgba(255, 255, 255, .08) !important;
}

/* ── Forms ── */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, .15);
    color: #e2e8f0;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #667eea;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #475569;
}

[data-bs-theme="dark"] .form-control[readonly] {
    background-color: #162032;
    color: #64748b;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #162032;
    border-color: rgba(255, 255, 255, .15);
    color: #94a3b8;
}

/* ── Alerts ── */
[data-bs-theme="dark"] .alert-info {
    background-color: #1e3a5f !important;
    color: #93c5fd !important;
    border-left-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .alert-danger {
    background: #3f1a1a !important;
    color: #fca5a5 !important;
    border-left-color: #ef4444 !important;
}

[data-bs-theme="dark"] .alert-warning {
    background: #3d2a0a !important;
    color: #fcd34d !important;
    border-left-color: #f59e0b !important;
}

[data-bs-theme="dark"] .alert-success {
    background: #0d2e1c !important;
    color: #86efac !important;
    border-left-color: #10b981 !important;
}

/* ── Dropdown menus ── */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, .1);
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #162032;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: rgba(255, 255, 255, .1);
}

/* ── Modals ── */
[data-bs-theme="dark"] .modal-content {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, .08);
}

[data-bs-theme="dark"] .modal-header {
    border-color: rgba(255, 255, 255, .08);
}

[data-bs-theme="dark"] .modal-footer {
    border-color: rgba(255, 255, 255, .08);
    background-color: #162032;
}

[data-bs-theme="dark"] #imgPreviewModal .modal-body {
    background: #0f172a;
}

[data-bs-theme="dark"] .modal-title,
[data-bs-theme="dark"] .modal-body,
[data-bs-theme="dark"] .modal-body label,
[data-bs-theme="dark"] .modal-body p {
    color: #e2e8f0;
}

/* ── Login page ── */
[data-bs-theme="dark"] .login-container {
    background: #1e293b;
    border-color: rgba(255, 255, 255, .08);
}

[data-bs-theme="dark"] .login-header h3 {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .login-header p {
    color: #94a3b8;
}

/* ── User profile ── */
[data-bs-theme="dark"] .profile-info-section {
    background: #162032 !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .profile-field-label {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .profile-field-value {
    color: #e2e8f0 !important;
}

/* ── Home page — startup landing ── */
[data-bs-theme="dark"] .vis-hero__headline {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .vis-hero__badge {
    background: rgba(6, 182, 212, .15);
    border-color: rgba(6, 182, 212, .3);
    color: #22d3ee;
}

[data-bs-theme="dark"] .vis-hero__sub {
    color: #94a3b8;
}

[data-bs-theme="dark"] .vis-feature-card {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .07) !important;
}

[data-bs-theme="dark"] .vis-feature-card__title {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .vis-feature-card__text {
    color: #94a3b8;
}

/* ── Scrollbar in dark mode ── */
[data-bs-theme="dark"] ::-webkit-scrollbar-track {
    background: #1e293b;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .2);
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .35);
}

/* ── Bulk-actions bar (doc list) ── */
[data-bs-theme="dark"] #bulk-actions-bar {
    background-color: #1a2744 !important;
    border-color: rgba(255, 255, 255, .1) !important;
    color: #e2e8f0;
}

/* ============================================================================
   CHAT PAGE
   The inline <style> block in chat_page.html uses hardcoded light colours,
   so every override here uses !important.
   ============================================================================ */

[data-bs-theme="dark"] .main-card {
    background: #1e293b !important;
}

[data-bs-theme="dark"] .chat-messages {
    background: #0f172a !important;
    border-color: rgba(255, 255, 255, .1) !important;
    color: #e2e8f0 !important;
}

/* ── User message — gradient already works fine in dark ── */

/* ── Assistant message ── */
[data-bs-theme="dark"] .message.assistant {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .12) !important;
    color: #e2e8f0 !important;
}

/* All plain text inside assistant bubble */
[data-bs-theme="dark"] .message.assistant p,
[data-bs-theme="dark"] .message.assistant li,
[data-bs-theme="dark"] .message.assistant ul,
[data-bs-theme="dark"] .message.assistant ol,
[data-bs-theme="dark"] .message.assistant span,
[data-bs-theme="dark"] .message.assistant dt,
[data-bs-theme="dark"] .message.assistant dd {
    color: #e2e8f0 !important;
}

/* Headings inside LLM response */
[data-bs-theme="dark"] .message.assistant h1,
[data-bs-theme="dark"] .message.assistant h2,
[data-bs-theme="dark"] .message.assistant h3,
[data-bs-theme="dark"] .message.assistant h4,
[data-bs-theme="dark"] .message.assistant h5,
[data-bs-theme="dark"] .message.assistant h6 {
    color: #f1f5f9 !important;
    border-bottom-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .message.assistant strong,
[data-bs-theme="dark"] .message.assistant b {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .message.assistant em,
[data-bs-theme="dark"] .message.assistant i {
    color: #cbd5e1 !important;
}

/* Links */
[data-bs-theme="dark"] .message.assistant a {
    color: #7dd3fc !important;
    text-decoration: underline;
}

[data-bs-theme="dark"] .message.assistant a:hover {
    color: #38bdf8 !important;
}

/* Inline code */
[data-bs-theme="dark"] .message.assistant code {
    background: #0d1b2e !important;
    color: #93c5fd !important;
    border: 1px solid rgba(255, 255, 255, .1) !important;
    border-radius: 4px;
    padding: .15em .45em;
}

/* Code blocks */
[data-bs-theme="dark"] .message.assistant pre {
    background: #0d1b2e !important;
    border: 1px solid rgba(255, 255, 255, .12) !important;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
}

[data-bs-theme="dark"] .message.assistant pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: #93c5fd !important;
}

/* Tables inside LLM response */
[data-bs-theme="dark"] .message.assistant table th,
[data-bs-theme="dark"] .message.assistant table td {
    border: 1px solid rgba(255, 255, 255, .15) !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .message.assistant table thead th {
    background: #162032 !important;
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .message.assistant table tbody tr:nth-child(odd) {
    background: #1e293b !important;
}

[data-bs-theme="dark"] .message.assistant table tbody tr:nth-child(even) {
    background: #162032 !important;
}

/* Blockquotes */
[data-bs-theme="dark"] .message.assistant blockquote {
    border-left: 4px solid #667eea;
    color: #94a3b8 !important;
    background: rgba(102, 126, 234, .08) !important;
    padding: .75rem 1rem;
    border-radius: 0 6px 6px 0;
}

/* Loading bubble */
[data-bs-theme="dark"] .message.loading {
    background: #1e2d4a !important;
    border-color: #667eea !important;
    color: #a5b4fc !important;
}

/* Input area */
[data-bs-theme="dark"] .input-container {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .query-textarea {
    background: #0f172a !important;
    border-color: rgba(255, 255, 255, .12) !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .query-textarea::placeholder {
    color: #475569;
}

[data-bs-theme="dark"] .query-textarea:focus {
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #667eea !important;
}

/* Filter bar */
[data-bs-theme="dark"] .filter-section {
    background: #162032 !important;
}

[data-bs-theme="dark"] .filter-separator {
    background: rgba(255, 255, 255, .12) !important;
}

[data-bs-theme="dark"] .filter-chip {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .15) !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .filter-chip.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: transparent !important;
    color: white !important;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(102, 126, 234, .45);
}

[data-bs-theme="dark"] .filter-chip:hover {
    border-color: #667eea !important;
    background: #1e2d4a !important;
}

[data-bs-theme="dark"] .filter-chip.active:hover {
    background: linear-gradient(135deg, #7c8ef5 0%, #8a55b8 100%) !important;
}

[data-bs-theme="dark"] .reset-btn {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .2) !important;
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .reset-btn:hover {
    background: #475569 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .upload-zone {
    background: #162032 !important;
    border-color: rgba(255, 255, 255, .15) !important;
}

[data-bs-theme="dark"] .upload-zone:hover {
    background: #1a2744 !important;
}

[data-bs-theme="dark"] .product-thumb {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .12) !important;
}

[data-bs-theme="dark"] .form-check {
    border-bottom-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .form-check-label {
    color: #e2e8f0 !important;
}

/* ============================================================================
   INTELIGENTNE NOTATNIKI (detail + list views)
   Both templates use inline <style> with hardcoded light backgrounds.
   ============================================================================ */

/* Section panels & cards */
[data-bs-theme="dark"] .notatnik-section,
[data-bs-theme="dark"] .notatnik-card {
    background: #1e293b !important;
    border-color: rgba(255, 255, 255, .08) !important;
    color: #e2e8f0;
}

[data-bs-theme="dark"] .notatnik-section h3,
[data-bs-theme="dark"] .notatnik-card h4,
[data-bs-theme="dark"] .notatnik-card h4 a {
    color: #38bdf8 !important;
}

[data-bs-theme="dark"] .notatnik-section h3 {
    border-bottom-color: rgba(56, 189, 248, .3) !important;
}

/* Individual document row inside detail view */
[data-bs-theme="dark"] .document-card {
    background: #162032 !important;
    border-color: rgba(255, 255, 255, .08) !important;
}

[data-bs-theme="dark"] .document-card:hover {
    border-color: #06b6d4 !important;
}

/* Metadata row text */
[data-bs-theme="dark"] .notatnik-meta {
    color: #94a3b8 !important;
}

/* Tag badges */
[data-bs-theme="dark"] .tag-badge {
    background: rgba(6, 182, 212, .15) !important;
    color: #22d3ee !important;
}

/* Status badges */
[data-bs-theme="dark"] .status-NEW {
    background: rgba(59, 130, 246, .2) !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .status-IN_PROGRESS {
    background: rgba(245, 158, 11, .2) !important;
    color: #fcd34d !important;
}

[data-bs-theme="dark"] .status-COMPLETED {
    background: rgba(16, 185, 129, .2) !important;
    color: #6ee7b7 !important;
}

/* Markdown content rendered inside notatnik */
[data-bs-theme="dark"] .markdown-content {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .markdown-content h1,
[data-bs-theme="dark"] .markdown-content h2,
[data-bs-theme="dark"] .markdown-content h3,
[data-bs-theme="dark"] .markdown-content h4,
[data-bs-theme="dark"] .markdown-content h5,
[data-bs-theme="dark"] .markdown-content h6 {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .markdown-content p,
[data-bs-theme="dark"] .markdown-content li,
[data-bs-theme="dark"] .markdown-content td,
[data-bs-theme="dark"] .markdown-content th {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .markdown-content a {
    color: #7dd3fc !important;
}

[data-bs-theme="dark"] .markdown-content code {
    background: #0d1b2e !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .markdown-content blockquote {
    border-left-color: #667eea;
    background: rgba(102, 126, 234, .08) !important;
    color: #94a3b8 !important;
}

/* Empty state placeholder */
[data-bs-theme="dark"] .empty-state {
    color: #475569 !important;
}

[data-bs-theme="dark"] .empty-state i {
    color: #334155 !important;
}

/* ── Dark mode toggle button (in navbar) ── */
#darkModeToggle {
    background: rgba(255, 255, 255, .1);
    border: 1.5px solid rgba(255, 255, 255, .25);
    color: white;
    border-radius: 20px;
    padding: .32rem .9rem;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .15s ease;
    display: flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    letter-spacing: .01em;
}

#darkModeToggle:hover {
    background: rgba(255, 255, 255, .22);
    border-color: rgba(255, 255, 255, .55);
    transform: translateY(-1px);
}

#darkModeToggle:active {
    transform: translateY(0);
}

#darkModeToggle #darkModeIcon.fa-moon {
    color: #fcd34d;
}

#darkModeToggle #darkModeIcon.fa-sun {
    color: #fbbf24;
}

/* ============================================================================
   MODERNIZATION ELEMENTS (search-panel, card left accent, page-hero)
   ============================================================================ */

/* Search panel */
[data-bs-theme="dark"] .search-panel {
    background: #1e293b !important;
    border-color: rgba(255,255,255,.08) !important;
}

/* search-panel__header already has gradient — renders fine in dark */

/* Document search card — override light bg and adjust left accent */
[data-bs-theme="dark"] .card_doc_search {
    background: #1e293b !important;
    border-color: rgba(255,255,255,.08) !important;
    border-left-color: var(--bs-primary, #0891b2) !important;
}

/* Nav action pill buttons in dark mode */
[data-bs-theme="dark"] .navbar .nav-action-btn {
    background: rgba(255,255,255,.08) !important;
    border-color: rgba(255,255,255,.18) !important;
}

[data-bs-theme="dark"] .navbar .nav-action-btn:hover,
[data-bs-theme="dark"] .navbar .nav-action-btn:focus {
    background: rgba(255,255,255,.18) !important;
    border-color: rgba(255,255,255,.35) !important;
}

/* ============================================================================
   CHAT PAGE – SIDEBAR (session history)
   ============================================================================ */

[data-bs-theme="dark"] .chat-sidebar {
    background: #0f172a !important;
    border-right-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .sidebar-header {
    border-bottom-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .sidebar-list {
    background: #0f172a !important;
}

[data-bs-theme="dark"] .session-item {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .session-item:hover {
    background: #1e293b !important;
}

[data-bs-theme="dark"] .session-item.active {
    background: linear-gradient(135deg, rgba(102,126,234,.25) 0%, rgba(118,75,162,.25) 100%) !important;
}

[data-bs-theme="dark"] .session-title {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .session-time {
    color: #64748b !important;
}

[data-bs-theme="dark"] .session-delete-btn {
    color: #64748b !important;
}

[data-bs-theme="dark"] .session-delete-btn:hover {
    color: #f87171 !important;
    background: rgba(248, 113, 113, .12) !important;
}

/* ── Feedback bar ── */
[data-bs-theme="dark"] .feedback-bar {
    border-top-color: rgba(255, 255, 255, .1) !important;
}

[data-bs-theme="dark"] .feedback-label {
    color: #64748b !important;
}

[data-bs-theme="dark"] .feedback-btn {
    border-color: rgba(255, 255, 255, .15) !important;
    color: #64748b !important;
}

[data-bs-theme="dark"] .like-btn:hover:not(:disabled) {
    border-color: #4ade80 !important;
    color: #4ade80 !important;
    background: rgba(74, 222, 128, .1) !important;
}

[data-bs-theme="dark"] .dislike-btn:hover:not(:disabled) {
    border-color: #f87171 !important;
    color: #f87171 !important;
    background: rgba(248, 113, 113, .1) !important;
}

[data-bs-theme="dark"] .feedback-thanks {
    color: #64748b !important;
}
