/* 
  PRiSM Nomogram - Global Styles 
  Aesthetic: Clean, Premium Medical/Scientific (NEJM inspired)
*/

:root {
    /* Color Palette */
    --primary-color: #004b87;
    /* NEJM Dark Blue */
    --primary-light: #e6f0f9;
    --accent-color: #a30000;
    /* Secondary Dark Red */
    --accent-light: #fbe5e5;

    --bg-color: #f7f9fc;
    --surface-color: #ffffff;

    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;

    --input-bg: #f9fafb;
    --input-border: #d1d5db;
    --input-focus: #3b82f6;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 8px;
    --radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll, handle scroll in panels */
}

/* Header containing Banner */
.app-header {
    background-color: #f6f6fa;
    background-image: url('banner.png?v=2');
    background-size: auto 100%;
    background-position: right center;
    background-repeat: no-repeat;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    letter-spacing: -0.025em;
}

.app-header .subtitle {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    background-color: var(--primary-light);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-select {
    appearance: none;
    padding: 6px 32px 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    transition: all 0.2s;
}

.header-select:hover {
    border-color: #94a3b8;
    background-color: #e2e8f0;
}

.header-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 75, 135, 0.2);
}

/* Main Layout Grid */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Panel - Inputs */
.panel-left {
    width: 400px;
    min-width: 400px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.panel-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: #fff;
    z-index: 2;
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.panel-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.input-controls-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Scrollbar styling for input panel */
.input-controls-container::-webkit-scrollbar {
    width: 6px;
}

.input-controls-container::-webkit-scrollbar-track {
    background: transparent;
}

.input-controls-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* Individual Control Group Styling */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.control-label label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.control-value-display {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Slider (Continuous variables) */
.range-slider {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--input-border);
    border-radius: 3px;
    outline: none;
    transition: background 0.2s;
}

.range-slider:active {
    background: #9ca3af;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
    transition: transform 0.1s, box-shadow 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Select (Categorical variables) */
.select-input {
    appearance: none;
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-main);
    background-color: var(--surface-color);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-input:hover {
    border-color: #9ca3af;
}

.select-input:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Risk Summary Card at Bottom Left */
.risk-summary-card {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
    z-index: 2;
}

.risk-metrics {
    display: flex;
    gap: 16px;
}

.metric {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.metric.highlight {
    background: var(--accent-light);
    border-color: #fca5a5;
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.metric.highlight .metric-label {
    color: var(--accent-color);
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.metric.highlight .metric-value {
    color: var(--accent-color);
}

/* Right Panel - Visualization */
.panel-right {
    flex: 1;
    background-color: #fff;
    overflow: auto;
    position: relative;
    padding: 32px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.canvas-container {
    width: 100%;
    max-width: 900px;
    background: #fff;
    /* Optional: subtle shadow to make it look like a paper page */
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 20px;
    min-height: 800px;
    /* Will be driven by JS mostly */
}

.loading-state {
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 40px;
}

/* D3 SVG Styles */
.axis-line {
    stroke: #000;
    stroke-width: 1px;
}

.tick-line {
    stroke: #000;
    stroke-width: 1px;
}

.tick-text {
    font-family: var(--font-family);
    font-size: 9px;
    fill: #000;
}

.axis-label {
    font-family: var(--font-family);
    font-size: 11px;
    font-weight: bold;
    fill: #000;
}

.curve-path {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 2.5px;
}

.cat-point {
    fill: var(--primary-color);
}

/* Patient Overlay Elements */
.patient-marker {
    fill: var(--accent-color);
}

.patient-connection {
    stroke: var(--accent-color);
    stroke-width: 1.5px;
    stroke-dasharray: 2, 2;
    fill: none;
}

.patient-overlay {
    pointer-events: none;
}

.grid-line {
    stroke: #94a3b8;
    stroke-width: 1px;
    stroke-dasharray: 4, 4;
}

.y-axis path,
.y-axis line {
    stroke: #cbd5e1;
    stroke-width: 1px;
}

.y-axis.horizontal-grid line {
    stroke: #e2e8f0;
    stroke-width: 0.5px;
}

.y-axis.horizontal-grid path.domain {
    display: none;
}

.y-axis text {
    fill: #64748b;
    font-size: 11px;
    font-family: inherit;
}

.y-axis-right {
    font-family: inherit;
    font-weight: 500;
}

.patient-text {
    font-family: var(--font-family);
    font-size: 10px;
    fill: var(--accent-color);
}

.title-text {
    font-family: var(--font-family);
    font-size: 18px;
    font-weight: bold;
    fill: #000;
}

/* Footer & Licensing */
.app-footer {
    background-color: #f1f5f9;
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
    z-index: 10;
}

.app-footer strong {
    color: #475569;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        overflow-y: auto;
        /* allow vertical scrolling of entire layout on phones */
    }

    .panel-left {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 10;
        /* Don't let inputs take up entire infinite scroll, cap it so SVG is reachable */
        max-height: 45vh;
        display: flex;
        flex-direction: column;
    }

    .input-controls-container {
        overflow-y: auto;
    }

    .nomogram-container {
        width: 100%;
        min-width: 0;
        padding: 0;
        flex: 1;
        /* No scroll on mobile, let the SVG scale down to fit */
    }

    .app-footer {
        padding: 16px;
        font-size: 0.7rem;
    }

    .nomogram-container svg {
        width: 100%;
        height: auto;
    }

    .header-content h1 {
        font-size: 1rem;
    }

    .app-header .subtitle {
        font-size: 0.8rem;
    }
}