/* Modern Dark Theme - Clean Professional Blue */
:root {
    --bg-body: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    /* Slate 800 */
    --bg-hover: #334155;
    /* Slate 700 */
    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 - lighter for better readability */

    /* Replaced Purple/Indigo with Professional Blue */
    --accent-primary: #3b82f6;
    /* Blue 500 */
    --accent-hover: #2563eb;
    /* Blue 600 */
    --accent-subtle: rgba(59, 130, 246, 0.15);
    /* Low opacity blue */

    --border-color: #334155;
    /* Slate 700 */

    --status-retain: #10b981;
    /* Emerald 500 */
    --status-likely: #f59e0b;
    /* Amber 500 */
    --status-certain: #ef4444;
    /* Red 500 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);

    --transition-speed: 0.2s;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-body);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-top: 0;
}

/* Navbar / Top Bar Look for Back Links */
.nav-bar {
    display: flex;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

/* REFACTORED HEADER STYLES */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 15px 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.nav-tabs {
    display: flex;
    gap: 15px;
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 8px;
    transition: all 0.2s;
}

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

.nav-tab.active {
    color: var(--accent-primary);
    background: var(--accent-subtle);
}

.header-actions {
    display: flex;
    gap: 15px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color var(--transition-speed);
}

.back-link:hover {
    color: var(--accent-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 40px;
}

/* Header Typography */
h1 {
    text-align: left;
    /* Better flow for reading */
    font-size: 2.2rem;
    color: var(--text-primary);
    /* Removed purple gradient */
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

/* Cards & Containers */
.upload-box,
.filter-box,
.table-wrapper,
.card,
.details-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    /* Increased padding for breathability */
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

/* Subtle hover lift for cards */
.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Forms & Inputs */
label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.95em;
    font-weight: 500;
}

select,
input[type="file"] {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 24px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-speed);
    font-size: 1rem;
    box-sizing: border-box;
    /* ensure padding doesn't increase width */
}

select:focus,
input[type="file"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* Buttons */
button,
.btn-view {
    cursor: pointer;
    background-color: var(--accent-primary);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color var(--transition-speed), transform 0.1s;
    text-transform: none;
    /* Removed caps for cleaner look */
    font-size: 0.95em;
    letter-spacing: 0.3px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover,
.btn-view:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-hide {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
}

.btn-hide:hover {
    background-color: #475569;
    color: white;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

.table th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.summary-row:hover td {
    background-color: var(--bg-hover);
    cursor: pointer;
}

/* Progress Bar */
#progress-container {
    display: none;
    margin: 30px 0;
    text-align: center;
}

#progress-bar {
    width: 100%;
    background-color: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    height: 30px;
    /* Thicker for text visibility */
    margin-top: 15px;
    position: relative;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
    /* Text styling inside bar */
    color: white;
    font-weight: bold;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}


/* Customer Details Area */
.details-user-cell {
    background-color: transparent !important;
    padding: 0 !important;
    border: none !important;
}

.details-box {
    background-color: #162032;
    /* Slightly darker than card */
    border: 1px solid var(--border-color);
    margin: 10px 0 20px 0;
}

/* Feature Impact Colors (SHAP) */
.shap-positive {
    color: var(--status-certain) !important;
    /* Reuse red var */
    font-weight: 600;
}

.shap-negative {
    color: var(--status-retain) !important;
    /* Reuse green var */
    font-weight: 600;
}

/* Filter Box Layout */
.filter-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group select {
    margin-bottom: 0;
    /* Remove bottom margin inside group since grid handles gap */
    width: 100%;
    box-sizing: border-box;
}


/* Dashboard Specifics */
.metric-label {
    color: var(--text-secondary) !important;
    font-size: 0.9em;
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.metric-value {
    color: var(--text-primary) !important;
    font-size: 2em !important;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.metrics-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.dashboard-actions {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .dashboard-actions .btn-view {
        flex: 1;
        min-width: 200px;
    }
}


/* Tooltip Help Icon */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 12px;
    margin-left: 8px;
    cursor: help;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.help-icon:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background-color: var(--bg-body);
}

/* Status Utilities */
.status-retain {
    color: var(--status-retain) !important;
    font-weight: 600;
}

.status-likely {
    color: var(--status-likely) !important;
    font-weight: 600;
}

.status-certain {
    color: var(--status-certain) !important;
    font-weight: 600;
}

/* Analysis Banner */
.analysis-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    /* Remove tint, keep clean */
    border-left: 4px solid var(--accent-primary);
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Enhanced Feature Details */
.feature-val-primary {
    font-weight: 600;
    font-size: 1.05em;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.feature-val-range {
    font-size: 0.85em;
    color: var(--text-secondary);
    display: block;
    font-style: italic;
    background: var(--bg-hover);
    /* cleaner background */
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}

/* Modal styles overrides to match new theme */
/* Modal styles overrides to match new theme */
@keyframes fadeInOpacity {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-overlay {
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(4px);
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.open {
    display: flex;
    animation: fadeInOpacity 0.4s ease forwards;
}

.modal-content.deck-style {
    background: var(--bg-card) !important;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color) !important;
    padding: 40px;
    position: relative;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg) !important;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 30px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--accent-primary);
}

.deck-header {
    text-align: center;
    border-bottom: 1px solid var(--border-color) !important;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.deck-header h2 {
    color: var(--text-primary);
    font-size: 1.8em;
    margin: 0;
}

.deck-header p {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.deck-slide {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.deck-slide h3 {
    color: var(--accent-primary) !important;
    font-size: 1.25em;
    margin-bottom: 10px;
}

.deck-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.dataset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dataset-btn {
    padding: 20px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.dataset-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.dataset-btn strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1.1em;
    color: var(--accent-primary);
}

.recommendation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.rec-item {
    background: var(--bg-hover);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.rec-item h3 {
    margin-top: 0;
    color: var(--accent-primary);
    font-size: 1.1em;
    margin-bottom: 12px;
}

.rec-item p,
.rec-item li {
    font-size: 0.9em;
    color: var(--text-secondary);
    line-height: 1.5;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    margin-top: 10px;
}

.simple-table th {
    text-align: left;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 4px;
}

.simple-table td {
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

a:hover {
    text-decoration: underline;
}

/* TOOLTIP STYLES */
.model-info-tooltip {
    position: relative;
    display: flex;
    align-items: center;
}

.tooltip-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    width: 320px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    margin-top: 15px;
    animation: fadeIn 0.2s ease-out;
}

.tooltip-content::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent var(--border-color) transparent;
}

.model-info-tooltip:hover .tooltip-content {
    display: block;
}

.tooltip-section {
    margin-bottom: 15px;
}

.tooltip-section:last-child {
    margin-bottom: 0;
}

.tooltip-section strong {
    display: block;
    color: var(--accent-primary);
    font-size: 0.95em;
    margin-bottom: 5px;
}

.tooltip-section p {
    margin: 0;
    font-size: 0.85em;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* RESPONSIVE MEDIA QUERIES */

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px 20px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 20px;
    }

    .nav-tabs {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions .btn-view {
        width: 100%;
    }

    .analysis-banner {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .table-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .table-wrapper {
        padding: 15px;
        overflow-x: auto;
    }

    .table th,
    .table td {
        padding: 12px 10px;
        font-size: 0.85em;
    }

    .modal-content.deck-style {
        padding: 25px 20px;
        width: 95%;
    }

    .deck-grid,
    .dataset-grid,
    .recommendation-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    .metric-value {
        font-size: 1.5em !important;
    }

    .card,
    .upload-box,
    .filter-box,
    .details-box {
        padding: 20px;
    }

    .filter-box {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }

    .nav-tab {
        font-size: 0.9em;
        padding: 6px 10px;
    }

    .card {
        padding: 20px;
    }

    .tooltip-content {
        width: 280px;
        left: 0;
        transform: none;
    }

    .tooltip-content::after {
        left: 20px;
    }
}