/* Willowdale Companion Site - Main Stylesheet */

:root {
    /* Core backgrounds */
    --bg-primary: #0f1117;
    --bg-secondary: #1a1f2e;
    --bg-tertiary: #242b3d;

    /* Text colors */
    --text-primary: #e8e8e8;
    --text-secondary: #b0b8c4;
    --text-muted: #9ca3b4;

    /* Accent colors */
    --accent-primary: #8b9dc3;
    --accent-success: #4ade80;
    --accent-warning: #fbbf24;
    --accent-danger: #f87171;
    --accent-info: #60a5fa;

    /* Shorthand aliases for convenience */
    --accent: var(--accent-primary);
    --accent-light: #a3b5d1;
    --accent-secondary: #6366f1;
    --success: var(--accent-success);
    --warning: var(--accent-warning);
    --danger: var(--accent-danger);
    --info: var(--accent-info);

    /* Border */
    --border-color: rgba(255, 255, 255, 0.1);

    /* Override Bootstrap's CSS variables for dark theme */
    --bs-body-color: var(--text-primary);
    --bs-body-bg: var(--bg-primary);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-muted);
    --bs-border-color: var(--border-color);
    --bs-card-bg: var(--bg-secondary);
    --bs-card-border-color: var(--border-color);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; font-weight: 600; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 500; }

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.stat-change.positive { color: var(--accent-success); }
.stat-change.negative { color: var(--accent-danger); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
}

.badge-class-elite { background: #f59e0b; color: #000; }
.badge-class-upper { background: #8b5cf6; color: #fff; }
.badge-class-middle { background: #3b82f6; color: #fff; }
.badge-class-working { background: #10b981; color: #fff; }
.badge-class-poor { background: #6b7280; color: #fff; }
.badge-class-destitute { background: #374151; color: #d1d5db; }

.badge-success { background: var(--accent-success); color: #000; }
.badge-warning { background: var(--accent-warning); color: #000; }
.badge-danger { background: var(--accent-danger); color: #000; }
.badge-info { background: var(--accent-info); color: #000; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Make all cards with tables scrollable on mobile */
.card:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-primary);
    color: #000;
}

.btn-primary:hover {
    background: #a3b5d1;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Progress Bars */
.progress {
    height: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 0.25rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* NPC List Item */
.npc-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.375rem;
    transition: background 0.2s ease;
}

.npc-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.npc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.npc-info {
    flex: 1;
}

.npc-name {
    font-weight: 500;
    color: var(--text-primary);
}

.npc-occupation {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    margin: 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state .oi {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   LAYOUT
   ========================================== */

.page-wrapper {
    display: flex !important;
    min-height: 100vh !important;
}

.sidebar {
    width: 280px !important;
    background: linear-gradient(180deg, #1a1f2e 0%, #151922 100%) !important;
    color: #e0e0e0 !important;
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    height: 100vh !important;
    overflow-y: auto !important;
    z-index: 1000 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
    left: 0 !important;
    top: 0 !important;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #8b9dc3;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

.connection-status {
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
}

.connection-status.connected {
    color: #4ade80;
}

.connection-status.disconnected {
    color: #f87171;
}

.game-time {
    color: #b0b8c4;
    margin-top: 0.25rem;
}

.main-content {
    flex: 1 !important;
    margin-left: 280px !important;
    background: #0f1117 !important;
    min-height: 100vh !important;
}

.top-bar {
    display: none;
    padding: 0.75rem 1rem;
    background: #1a1f2e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar .brand {
    font-weight: 600;
    color: #8b9dc3;
}

.top-bar .btn-link {
    color: var(--text-primary);
    font-size: 1.5rem;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(139, 157, 195, 0.3);
}

.top-bar .btn-link:hover,
.top-bar .btn-link:active {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

.content-area {
    padding: 2rem;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Mobile Responsive - Tablets */
@media (max-width: 768px) {
    .sidebar {
        left: -280px !important;
        visibility: hidden !important;
        -webkit-transition: left 0.3s ease, visibility 0.3s ease !important;
        transition: left 0.3s ease, visibility 0.3s ease !important;
    }

    .sidebar.open {
        left: 0 !important;
        visibility: visible !important;
    }

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

    .top-bar {
        display: flex !important;
    }

    /* d-md-none utility - hide on desktop, show on mobile */
    .d-md-none {
        display: flex !important;
    }

    .content-area {
        padding: 1rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }

    .page-header {
        margin-bottom: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

/* Mobile Responsive - iPhones (375px-428px) */
@media (max-width: 480px) {
    .content-area {
        padding: 0.75rem;
    }

    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }
    h3 { font-size: 1rem; }

    .page-header {
        margin-bottom: 1rem;
    }

    .page-header p {
        font-size: 0.85rem;
    }

    /* Stat Cards - 2 column on mobile */
    .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    /* Cards */
    .card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .card-title {
        font-size: 0.9rem;
    }

    /* Tables - horizontal scroll */
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    .table {
        min-width: 500px;
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }

    /* Filter Tabs - horizontal scroll */
    .filter-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin: 0 -0.75rem 1rem -0.75rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        gap: 0.375rem;
    }

    .filter-tab {
        flex-shrink: 0;
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Badges */
    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }

    /* Buttons */
    .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* NPC Items */
    .npc-item {
        padding: 0.5rem;
    }

    .npc-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .npc-name {
        font-size: 0.9rem;
    }

    .npc-occupation {
        font-size: 0.75rem;
    }

    /* Progress bars */
    .progress {
        height: 0.375rem;
    }

    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state .oi {
        font-size: 2rem;
    }

    /* LLM Interactions */
    .llm-interaction {
        padding: 0.75rem;
    }

    .llm-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .llm-prompt, .llm-response {
        padding: 0.5rem;
        font-size: 0.8rem;
    }

    .llm-meta {
        flex-wrap: wrap;
        font-size: 0.7rem;
    }

    /* Gossip items */
    .gossip-item {
        padding: 0.75rem;
    }

    .gossip-meta {
        font-size: 0.7rem;
    }

    /* Guild cards */
    .guild-card {
        padding: 0.75rem;
    }

    .guild-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .guild-stat-value {
        font-size: 1rem;
    }

    .guild-stat-label {
        font-size: 0.65rem;
    }

    /* Timeline */
    .timeline-item {
        padding-left: 1.5rem;
    }

    /* Conversation cards */
    .conversation-card {
        padding: 0.75rem;
    }

    .conversation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .conversation-participants {
        flex-wrap: wrap;
    }

    .participant-name {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .conversation-meta {
        font-size: 0.75rem;
    }

    .message-item {
        padding: 0.5rem;
    }

    .message-content {
        font-size: 0.85rem;
    }

    /* Network graph */
    #npc-network-graph {
        height: 350px;
    }

    /* Feud items */
    .feud-parties {
        flex-wrap: wrap;
    }

    /* Law items */
    .law-penalties {
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Sidebar footer */
    .sidebar-footer {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    /* Top bar */
    .top-bar {
        padding: 0.75rem 1rem;
    }

    .top-bar .btn-link {
        padding: 0.25rem;
    }

    /* Utilities for mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* ==========================================
   NAV CATEGORY
   ========================================== */

.nav-category {
    margin: 0.25rem 0;
}

.nav-category-header {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0.75rem 1.5rem !important;
    background: transparent !important;
    border: none !important;
    color: #b0b8c4 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: left !important;
}

.nav-category-header:hover {
    color: #e0e0e0;
    background: rgba(255, 255, 255, 0.05);
}

.nav-category.expanded .nav-category-header {
    color: #8b9dc3;
}

.nav-category-content {
    padding: 0.25rem 0;
}

.nav-category-content .nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.5rem 0.5rem 2.5rem;
    color: #b0b8c4;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-category-content .nav-link:hover {
    color: #e0e0e0;
    background: rgba(255, 255, 255, 0.05);
    border-left-color: rgba(139, 157, 195, 0.3);
}

.nav-category-content .nav-link.active {
    color: #8b9dc3;
    background: rgba(139, 157, 195, 0.1);
    border-left-color: #8b9dc3;
}

.chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

/* ==========================================
   FILTER TABS
   ========================================== */

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

/* ==========================================
   UTILITIES
   ========================================== */

.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--accent-success); }
.text-warning { color: var(--accent-warning); }
.text-danger { color: var(--accent-danger); }
.text-right { text-align: right; }

.d-flex { display: flex; }
.d-block { display: block; }
.d-none { display: none; }
.d-md-none { display: none; }

.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.flex-wrap { flex-wrap: wrap; }

.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-auto { margin-left: auto; }
.p-3 { padding: 1rem; }

.fw-bold { font-weight: 700; }

/* ==========================================
   BOOTSTRAP DARK THEME OVERRIDES
   These ensure Bootstrap components use our dark theme colors
   ========================================== */

/* Force all text to use our colors by default */
body, .card, .card-body, .list-group-item, .modal-content,
.dropdown-menu, .popover, .tooltip, .toast, div, span, p, li, td, th {
    color: var(--text-primary);
}

/* Override Bootstrap's muted text - it's too dark for our theme */
.text-muted, .text-secondary, .text-body-secondary {
    color: var(--text-muted) !important;
}

/* Bootstrap tables - force dark theme */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-hover-color: var(--text-primary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text-primary);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Bootstrap cards - force dark backgrounds */
.card {
    --bs-card-bg: var(--bg-secondary);
    --bs-card-color: var(--text-primary);
    --bs-card-border-color: var(--border-color);
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.card-header, .card-footer {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.card-title, .card-text {
    color: var(--text-primary);
}

/* Bootstrap list groups */
.list-group-item {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.list-group-item:hover {
    background-color: var(--bg-tertiary);
}

/* Bootstrap forms */
.form-control, .form-select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem rgba(139, 157, 195, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    color: var(--text-primary);
}

/* Bootstrap alerts */
.alert {
    border: 1px solid var(--border-color);
}

.alert-info {
    background-color: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
    color: var(--accent-info);
}

.alert-success {
    background-color: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--accent-success);
}

.alert-warning {
    background-color: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--accent-warning);
}

.alert-danger {
    background-color: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--accent-danger);
}

/* Bootstrap modals */
.modal-content {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.modal-header, .modal-footer {
    border-color: var(--border-color);
}

/* Bootstrap dropdowns */
.dropdown-menu {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Bootstrap nav */
.nav-link {
    color: var(--text-secondary);
}

.nav-link:hover, .nav-link:focus {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--accent-primary);
}

/* Bootstrap accordion */
.accordion-item {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
}

.accordion-button {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.accordion-button:not(.collapsed) {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
}

.accordion-body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Ensure all small/muted helper text is readable */
small, .small, .form-text, figcaption, caption {
    color: var(--text-muted) !important;
}

/* Override any remaining Bootstrap gray text colors */
[class*="text-body"], [class*="text-dark"], [class*="text-black"] {
    color: var(--text-primary) !important;
}

/* Ensure borders use our color */
[class*="border"] {
    border-color: var(--border-color) !important;
}

/* Fix any white backgrounds that might slip through */
.bg-white, .bg-light, .bg-body {
    background-color: var(--bg-secondary) !important;
}

.bg-body-secondary, .bg-body-tertiary {
    background-color: var(--bg-tertiary) !important;
}

/* ==========================================
   BOOTSTRAP BADGE DARK THEME OVERRIDES
   ========================================== */

/* Ensure all Bootstrap badge variants have readable text */
.badge-primary, .badge.bg-primary { background-color: var(--accent-primary) !important; color: #000 !important; }
.badge-secondary, .badge.bg-secondary { background-color: #6b7280 !important; color: #fff !important; }
.badge-success, .badge.bg-success { background-color: var(--accent-success) !important; color: #000 !important; }
.badge-danger, .badge.bg-danger { background-color: var(--accent-danger) !important; color: #000 !important; }
.badge-warning, .badge.bg-warning { background-color: var(--accent-warning) !important; color: #000 !important; }
.badge-info, .badge.bg-info { background-color: var(--accent-info) !important; color: #000 !important; }
.badge-light, .badge.bg-light { background-color: var(--bg-tertiary) !important; color: var(--text-primary) !important; }
.badge-dark, .badge.bg-dark { background-color: #374151 !important; color: #e5e7eb !important; }

/* ==========================================
   BOOTSTRAP BUTTON DARK THEME OVERRIDES
   ========================================== */

.btn-outline-primary {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-outline-primary:hover {
    background-color: var(--accent-primary);
    color: #000;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* ==========================================
   ENSURE ALL TEXT INHERITS PROPERLY
   ========================================== */

/* Paragraphs and generic text */
p, li, dd, dt {
    color: var(--text-primary);
}

/* Strong/bold text */
strong, b {
    color: inherit;
}

/* Ensure card-content areas have proper text color */
.card-content, .card-body {
    color: var(--text-primary);
}

/* Table cells explicitly */
td, th {
    color: var(--text-primary);
}

/* Links in tables */
td a, th a {
    color: var(--accent-primary);
}

/* Override Bootstrap's default border on tables */
.table, .table > :not(caption) > * > * {
    border-color: var(--border-color);
}

/* Card content padding helper */
.card-content {
    padding: 1rem;
}
