/* Modern Dark Mode Only - Improved Design System */

/* Dark Theme Color Variables */
:root,
[data-theme="dark"] {
    /* Background colors - Modern dark palette */
    --bg-primary: #0f1419;           /* Deep dark background */
    --bg-secondary: #1a1f26;         /* Card backgrounds */
    --bg-tertiary: #232931;          /* Elevated elements */
    --bg-card: #1a1f26;              /* Card background */
    --bg-card-header: #151a20;       /* Card headers */
    --bg-hover: #252d38;             /* Hover states */

    /* Text colors - High contrast for readability */
    --text-primary: #e6edf3;         /* Primary text - bright white */
    --text-secondary: #8b949e;       /* Secondary text - medium gray */
    --text-muted: #6e7681;           /* Muted text - subtle gray */
    --text-tertiary: #57606a;        /* Tertiary text - darker gray */

    /* Border colors */
    --border-color: #30363d;         /* Default borders */
    --border-light: #21262d;         /* Subtle borders */
    --border-heavy: #484f58;         /* Emphasized borders */

    /* Brand colors - Vibrant and accessible */
    --primary: #1f6feb;              /* Blue */
    --primary-hover: #388bfd;        /* Lighter blue */
    --success: #2da44e;              /* Green */
    --success-hover: #3fb950;        /* Lighter green */
    --danger: #f85149;               /* Red */
    --danger-hover: #ff6b6b;         /* Lighter red */
    --warning: #d29922;              /* Orange/yellow */
    --warning-hover: #e8b639;        /* Lighter orange */
    --info: #58a6ff;                 /* Light blue */
    --info-hover: #79c0ff;           /* Lighter cyan */

    /* Status colors for tables */
    --status-success-bg: #1b4721;    /* Dark green background */
    --status-warning-bg: #6e5f0f;    /* Dark yellow background */
    --status-danger-bg: #5c1f1f;     /* Dark red background */

    /* Shadow system */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.7);

    /* Scrollbar */
    --scrollbar-track: #1a1f26;
    --scrollbar-thumb: #484f58;
    --scrollbar-thumb-hover: #6e7681;
}

/* Base Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Links */
a {
    color: var(--info);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--info-hover);
}

/* Navbar */
.navbar {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1rem;
}

.navbar.bg-dark {
    background-color: var(--bg-secondary) !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-primary) !important;
    transition: transform 0.2s ease;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary) !important;
    background-color: var(--bg-hover);
}

.nav-link:active {
    transform: scale(0.98);
}

/* Navbar Toggler (Hamburger Menu) */
.navbar-toggler {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    transition: all 0.2s ease;
}

.navbar-toggler:hover {
    border-color: var(--border-heavy);
    background-color: var(--bg-hover);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
    outline: none;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%238b949e' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Collapsed Menu Styling */
@media (max-width: 991.98px) {
    .navbar-collapse {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .navbar-nav {
        gap: 0.5rem;
        text-align: right;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
        width: 100%;
        text-align: right;
    }
}

/* Cards */
.card {
    background-color: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--border-heavy);
}

.card-header {
    background-color: var(--bg-card-header);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 1.1rem;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background-color: var(--bg-card-header);
    border-top: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
}

/* Colored Cards - Dark text for visibility */
.card.bg-primary,
.card.bg-success,
.card.bg-danger,
.card.bg-warning,
.card.bg-info {
    color: #000 !important;
}

.card.bg-primary .card-title,
.card.bg-success .card-title,
.card.bg-danger .card-title,
.card.bg-warning .card-title,
.card.bg-info .card-title,
.card.bg-primary .card-text,
.card.bg-success .card-text,
.card.bg-danger .card-text,
.card.bg-warning .card-text,
.card.bg-info .card-text,
.card.bg-primary small,
.card.bg-success small,
.card.bg-danger small,
.card.bg-warning small,
.card.bg-info small {
    color: #000 !important;
}

/* Override text-white for better visibility */
.card.bg-primary.text-white,
.card.bg-success.text-white,
.card.bg-info.text-white {
    color: #fff !important;
}

.card.bg-primary.text-white *,
.card.bg-success.text-white *,
.card.bg-info.text-white * {
    color: #fff !important;
}

/* Colored Card Headers - Dark text */
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-danger,
.card-header.bg-warning,
.card-header.bg-info,
.card-header.bg-secondary {
    color: #000 !important;
}

.card-header.bg-primary.text-white,
.card-header.bg-success.text-white,
.card-header.bg-danger.text-white,
.card-header.bg-warning.text-dark,
.card-header.bg-info.text-white,
.card-header.bg-secondary.text-white {
    color: #fff !important;
}

.card-header.bg-primary *,
.card-header.bg-success *,
.card-header.bg-danger *,
.card-header.bg-warning *,
.card-header.bg-info *,
.card-header.bg-secondary * {
    color: #000 !important;
}

/* Tables */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
    border-radius: 8px;
    background-color: var(--bg-secondary);
}

.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table thead th {
    color: var(--text-primary) !important;
    background-color: var(--bg-card-header);
    border-bottom: 2px solid var(--border-heavy);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody td {
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-light);
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: var(--bg-hover);
    cursor: pointer;
}

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

/* Table Status Rows */
.table-warning {
    background-color: rgba(255, 193, 7, 0.35) !important;
}

.table-warning td,
.table-warning td *,
.table-warning .text-muted,
.table-warning strong {
    color: #000 !important;
}

.table-success {
    background-color: rgba(34, 197, 94, 0.35) !important;
}

.table-success td,
.table-success td *,
.table-success .text-muted,
.table-success strong {
    color: #000 !important;
}

.table-danger {
    background-color: rgba(248, 81, 73, 0.35) !important;
}

.table-danger td,
.table-danger td *,
.table-danger .text-muted,
.table-danger strong {
    color: #000 !important;
}

/* Badges */
.badge {
    font-size: 0.85rem;
    padding: 0.45em 0.75em;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.3px;
}

.badge.bg-primary {
    background-color: var(--primary) !important;
    color: #000 !important;
}

.badge.bg-success {
    background-color: var(--success) !important;
    color: #000 !important;
}

.badge.bg-danger {
    background-color: var(--danger) !important;
    color: #000 !important;
}

.badge.bg-warning {
    background-color: var(--warning) !important;
    color: #000 !important;
}

.badge.bg-info {
    background-color: var(--info) !important;
    color: #000 !important;
}

.badge.bg-secondary {
    color: var(--text-primary);
}

.badge.bg-dark {
    background-color: #343a40 !important;
    color: #fff !important;
}

.badge.bg-high-prob {
    background-color: #ffcdd2 !important; /* Light red */
    color: #000 !important; /* Black text for good contrast */
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    transition: all 0.2s ease;
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
    color: #000 !important;
}

.btn-success {
    background-color: var(--success);
    color: #000 !important;
}

.btn-success:hover {
    background-color: var(--success-hover);
    box-shadow: var(--shadow-md);
    color: #000 !important;
}

.btn-danger {
    background-color: var(--danger);
    color: #000 !important;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    box-shadow: var(--shadow-md);
    color: #000 !important;
}

.btn-warning {
    background-color: var(--warning);
    color: #000 !important;
}

.btn-warning:hover {
    background-color: var(--warning-hover);
    box-shadow: var(--shadow-md);
    color: #000 !important;
}

.btn-info {
    background-color: var(--info);
    color: #000 !important;
}

.btn-info:hover {
    background-color: var(--info-hover);
    box-shadow: var(--shadow-md);
    color: #000 !important;
}

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

.btn-secondary:hover {
    background-color: var(--bg-hover);
    box-shadow: var(--shadow-md);
}

.btn-outline-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

/* Form Controls */
.form-control, .form-select {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.625rem 1rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
    outline: none;
}

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

.form-label {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

select[multiple] {
    height: auto !important;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Alerts */
.alert {
    border-radius: 12px;
    border: none;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background-color: var(--status-success-bg);
    color: #4ade80;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background-color: var(--status-danger-bg);
    color: #fb7185;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background-color: var(--status-warning-bg);
    color: #fbbf24;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background-color: #1a3a52;
    color: var(--info);
    border-left: 4px solid var(--info);
}

/* Progress Bars */
.progress {
    border-radius: 10px;
    background-color: var(--bg-tertiary);
    height: 1.5rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.progress-bar {
    font-weight: 600;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

/* List Group */
.list-group-item {
    border-left: 3px solid var(--primary);
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.list-group-item:hover {
    background-color: var(--bg-hover);
    border-left-width: 4px;
}

/* Text Utilities */
.text-primary {
    color: var(--primary) !important;
}

.text-success {
    color: #4ade80 !important;
}

.text-danger {
    color: #fb7185 !important;
}

.text-warning {
    color: #fbbf24 !important;
}

.text-info {
    color: var(--info) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-dark {
    color: var(--text-primary) !important;
    background-color: transparent !important;
}

.text-light {
    color: var(--text-primary) !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Loading Spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
    margin: 20px auto;
    display: block;
    border-color: var(--primary);
    border-right-color: transparent;
}

/* Live Indicator */
.live-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    animation: pulse 2s infinite;
    margin-right: 0.5rem;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Container Improvements */
.container, .container-fluid {
    padding-top: 1rem;
    padding-bottom: 2rem;
}

/* Modal Overrides */
.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card-header);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card-header);
}

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

.modal-body {
    color: var(--text-primary);
}

/* Dropdown Overrides */
.dropdown-menu {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

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

.dropdown-divider {
    border-color: var(--border-color);
}

/* Tooltip Overrides */
.tooltip-inner {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

/* Pagination */
.pagination .page-link {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.pagination .page-link:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-heavy);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .navbar-text {
        display: none;
    }

    .card {
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.9rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.45rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.625rem 0.5rem;
        font-size: 0.85rem;
    }
}

@media (min-width: 1400px) {
    .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
        max-width: 1400px;
    }
}

/* Accessibility */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background-color: var(--primary);
    color: white;
}

/* Print Styles */
@media print {
    body {
        background-color: white;
        color: black;
    }

    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }
}
