/* Seismic Travel Time Visualizer - Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header .subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

.header-links a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.2s;
}

.header-links a:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

/* Controls Panel */
.controls-panel {
    background: var(--surface-color);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.control-section:last-of-type {
    border-bottom: none;
}

.control-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.slider-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.slider-input-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.slider-input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.slider-input-group input[type="number"] {
    width: 70px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    text-align: center;
}

input[type="text"],
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--surface-color);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Radio and Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.375rem 0;
}

.radio-label input,
.checkbox-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.btn {
    flex: 1;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

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

/* Visualization Area */
.visualization-area {
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.plot-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: 100%;
    min-height: 500px;
}

.plot-container.single-plot {
    grid-template-columns: 1fr;
}

.plot-container.single-plot .plot-panel:last-child {
    display: none;
}

.plot-panel {
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.plot-3d-container {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

.hidden {
    display: none !important;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results Panel */
.results-panel {
    background: var(--surface-color);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.results-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

#results-table th,
#results-table td {
    padding: 0.5rem 0.625rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

#results-table th {
    background: var(--background-color);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

#results-table tbody tr:hover {
    background: var(--background-color);
}

#results-table .angle-col {
    font-size: 0.75rem;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

/* Info Panel */
.info-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.info-panel h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.375rem;
}

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

/* Footer */
.footer {
    background: var(--surface-color);
    padding: 0.75rem 2rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

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

.footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .main-container {
        grid-template-columns: 260px 1fr 280px;
    }
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 240px 1fr;
        grid-template-rows: 1fr auto;
    }

    .results-panel {
        grid-column: 1 / -1;
        max-height: 250px;
    }

    .plot-container {
        grid-template-columns: 1fr;
    }

    .plot-panel {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .main-container {
        grid-template-columns: 1fr;
        padding: 0.5rem;
    }

    .controls-panel {
        order: 1;
    }

    .visualization-area {
        order: 2;
        min-height: 400px;
    }

    .results-panel {
        order: 3;
        max-height: 200px;
    }
}

/* Plotly overrides */
.js-plotly-plot .plotly .modebar {
    right: 10px !important;
}

/* Phase colors for table rows */
.phase-P { color: #1f77b4; }
.phase-S { color: #ff7f0e; }
.phase-PP { color: #2ca02c; }
.phase-SS { color: #d62728; }
.phase-PcP { color: #9467bd; }
.phase-ScS { color: #8c564b; }
.phase-PKP { color: #e377c2; }
.phase-SKS { color: #7f7f7f; }
