/*
 * Copyright 2026 Wageningen University & Research (WUR)
 * Author: Bart van Stratum
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
:root {
    --color-accent:      #ff4b4b;
    --color-accent-dark: #e03030;
    --color-bg:          #f5f5f5;
    --color-surface:     #fff;
    --color-border:      #ddd;
    --color-border-mid:  #ccc;
    --color-text:        #222;
    --color-text-muted:  #555;
    --color-text-faint:  #888;
    --color-text-dim:    #aaa;
}
*/

:root {
    --color-accent:      #0D9146;
    --color-accent-dark: #CA177C;
    --color-bg:          #f5f5f5;
    --color-surface:     #fff;
    --color-border:      #ddd;
    --color-border-mid:  #ccc;
    --color-text:        #002F57;
    --color-text-muted:  #555;
    --color-text-faint:  #888;
    --color-text-dim:    #aaa;
}

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

body {
    font-family: Roboto, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
}

a.theme-link,
a.theme-link:visited {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--color-accent);
}

header {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--color-accent);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    max-width: 1600px;
    width: 100%;
    align-self: center;
}

main {
    flex: 1;
    display: flex;
    min-height: 0;
    max-width: 1600px;
    width: 100%;
    align-self: center;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    padding: 1.25rem;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar.right {
    border-right: none;
    border-left: 1px solid var(--color-border);
}

.sidebar h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-faint);
}

.sidebar label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.sidebar label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.sidebar select {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border-mid);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    width: 100%;
    background: var(--color-surface);
    cursor: pointer;
}

.sidebar select:disabled {
    background: var(--color-bg);
    color: var(--color-text-dim);
    cursor: default;
}

.sidebar button:disabled {
    background: var(--color-border-mid);
    cursor: default;
}

.sidebar input[type="file"] {
    font-size: 0.875rem;
    font-family: inherit;
    width: 100%;
    cursor: pointer;
}

.sidebar input[type="text"],
.sidebar input[type="date"] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border-mid);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    width: 100%;
}

.sidebar input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border-mid);
    border-radius: 3px;
    background: var(--color-surface);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

.sidebar input[type="checkbox"]:checked {
    background: var(--color-accent);
    border-color: var(--color-accent);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px;
}

.sidebar input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: default;
}

.sidebar input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--color-border);
    outline: none;
    cursor: pointer;
}

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

.sidebar input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.sidebar input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
}

.sidebar input[type="range"]::-moz-range-progress {
    background: var(--color-accent);
    height: 4px;
    border-radius: 2px;
}

.sidebar button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: 4px;
    background: var(--color-accent);
    color: var(--color-surface);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar button:hover {
    background: var(--color-accent-dark);
}

.sidebar button .material-icons {
    font-size: 1rem;
}

/* ── Collapsible sections ────────────────────────────── */
.section {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    overflow: hidden;
}

.section summary {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.section summary .material-icons {
    font-size: 1rem;
    color: #333;
}

.section summary::-webkit-details-marker { display: none; }

.section summary::after {
    content: '▾';
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--color-text-faint);
    transition: transform 0.15s;
}

.section[open] summary::after {
    transform: rotate(-180deg);
}

.section-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--color-border);
}

.plot {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    padding: 1rem;
    position: relative;
}

.plot-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.plot-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.plot-toolbar button {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.plot-toolbar button:hover {
    background: var(--color-bg);
}

.plot-toolbar button .material-icons {
    font-size: 1rem;
}

.plot-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.85);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.sidebar-logo-link {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    justify-content: center;
}

.sidebar-logo {
    width: 85%;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--color-accent);
    margin: 0;
}

/* stack on narrow screens */
@media (max-width: 900px) {
    main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .sidebar.right {
        border-left: none;
        border-top: 1px solid var(--color-border);
        border-bottom: none;
    }

    .plot {
        min-height: 400px;
    }
}
