/* General Body and Theme */
@font-face {
    font-family: 'IBM Plex Serif Custom';
    src: url('../IBMPlexSerif-Medium.ttf') format('truetype');
    font-style: normal;
    font-weight: 500;
}

@font-face {
    font-family: 'Lobster Custom';
    src: url('../Lobster-Regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 400;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --border-color: #30363d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent-primary: #7287fd;
    --accent-secondary: #1A73E8;
    --accent-red: #d20f39;
    --accent-green: #22c55e;
    --highlight-bg: #222b38;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'IBM Plex Serif Custom', Georgia, serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

main {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- Loading Overlay Styles --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}
.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.loading-content {
    text-align: center;
}
.loading-svg {
    width: 200px;
    height: 80px;
    stroke: var(--accent-primary);
}

#loading-animation path {
    filter: drop-shadow(0 0 5px var(--accent-primary));
}

.loading-text {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Card component style */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: all 0.2s ease-in-out;
}

/* Header Styles */
.header-title {
    font-family: 'Lobster Custom', cursive;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

.header-subtitle {
    color: var(--text-secondary);
}

/* --- NEW: Stock Selector Dropdown Styles --- */
.stock-selector {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 100%;
    padding: 0.65rem;
    border-radius: 0.5rem;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23c9d1d9%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 0.65em auto;
    padding-right: 2.5rem; /* Make space for the arrow */
}

.stock-selector:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 30%, transparent);
}

/* --- NEW: Time Range Button Styles --- */
.time-range-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.22rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.2;
    transition: all 0.2s ease-in-out;
}

.time-range-btn:hover {
    background-color: var(--highlight-bg);
    color: var(--text-primary);
}

.time-range-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    font-weight: 500;
}

.action-btn {
    background-color: var(--accent-secondary);
    border: 1px solid transparent;
    color: white;
    padding: 0.42rem 0.8rem;
    border-radius: 0.65rem;
    font-size: 0.8rem;
    line-height: 1.2;
    transition: all 0.2s ease-in-out;
}

.action-btn:hover {
    filter: brightness(1.08);
}

.action-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.action-btn-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.chart-panel {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.chart-reset-btn {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    width: min(100%, 960px);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.metric-chip {
    border: 1px solid var(--border-color);
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.9rem 1rem;
}

.metric-chip-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.metric-chip-value {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
}

/* Loader animation */
.loader {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Custom Scrollbar */
#side-panel::-webkit-scrollbar { width: 8px; }
#side-panel::-webkit-scrollbar-track { background: var(--bg-secondary); }
#side-panel::-webkit-scrollbar-thumb {
    background-color: var(--accent-primary);
    border-radius: 10px;
    border: 2px solid var(--bg-secondary);
}
#side-panel::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent-secondary);
}

@media (max-width: 1024px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    main {
        overflow: visible;
    }

    .chart-panel {
        min-height: 430px;
    }

    #side-panel {
        overflow-y: visible;
        max-height: none;
        padding-right: 0;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 2rem);
        padding: 1.25rem;
    }
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    .header-title {
        line-height: 1.1;
    }

    .header-subtitle {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .card {
        border-radius: 0.9rem;
    }

    .chart-panel {
        min-height: 360px;
    }

    .chart-reset-btn {
        top: 0.65rem;
        left: 0.65rem;
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
    }

    .action-btn,
    .time-range-btn {
        min-height: 42px;
    }

    #forecastHorizonButtons,
    #timeRangeButtons {
        width: 100%;
        justify-content: stretch;
    }

    #forecastHorizonButtons button,
    #timeRangeButtons button {
        flex: 1 1 0;
        text-align: center;
    }

    .metric-chip {
        padding: 0.8rem 0.9rem;
    }

    .metric-chip-value {
        font-size: 1rem;
    }

    #predictionChart,
    #backtestChart {
        min-height: 320px;
    }
}

@media (min-width: 1025px) {
    .chart-panel {
        min-height: 620px;
    }

    #predictionChart {
        min-height: 560px;
    }
}
