/* ============================================================
   OrcaMet Portal — Stylesheet
   Deep ocean blues, professional meteorological aesthetic
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ocean-dark: #0a1628;
    --ocean-mid: #132743;
    --ocean-light: #1a3a5c;
    --teal: #0ea5e9;
    --teal-bright: #38bdf8;
    --green-go: #22c55e;
    --amber-caution: #f59e0b;
    --red-cancel: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dark: #1e293b;
    --surface: #1e293b;
    --surface-light: #334155;
    --border: #334155;
    --white: #ffffff;
    --radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--ocean-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--teal-bright); text-decoration: none; }
a:hover { color: var(--teal); text-decoration: underline; }

/* --- Navbar --- */
.navbar {
    background: var(--ocean-mid);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.nav-logo { font-size: 1.5rem; }

.nav-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.5px;
}

.nav-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    display: none;
}

@media (min-width: 768px) {
    .nav-subtitle { display: inline; }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--white);
    background: var(--surface-light);
    text-decoration: none;
}

.nav-login, .nav-logout {
    background: var(--teal);
    color: var(--white);
}

.nav-login:hover, .nav-logout:hover {
    background: var(--teal-bright);
    color: var(--white);
}

.nav-user {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* --- Landing Page --- */
.landing { text-align: center; }

.landing-hero {
    padding: 4rem 1rem;
}

.landing-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--white);
}

.landing-tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
}

.feature-icon { font-size: 2rem; margin-bottom: 1rem; }

.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--white);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    /* A secondary look by default, so a bare .btn (Cancel, Edit Site) is
       visible. .btn-primary and .btn-danger override these below. */
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    border-color: var(--surface-light);
    color: var(--white);
    text-decoration: none;
}

.btn-primary {
    background: var(--teal);
    color: var(--white);
    border-color: var(--teal);
}

.btn-primary:hover {
    background: var(--teal-bright);
    color: var(--white);
    text-decoration: none;
}

.btn-large {
    padding: 0.8rem 2.5rem;
    font-size: 1.1rem;
}

/* --- Dashboard --- */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    color: var(--white);
}

.dashboard-role {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--teal-bright);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* --- Sections --- */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.3rem;
    color: var(--white);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th {
    background: var(--ocean-mid);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.8rem 1rem;
    text-align: left;
}

.data-table td {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: var(--surface-light);
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-active { background: rgba(34, 197, 94, 0.15); color: var(--green-go); }
.badge-caution { background: rgba(245, 158, 11, 0.15); color: var(--amber-caution); }
.badge-cancel { background: rgba(239, 68, 68, 0.15); color: var(--red-cancel); }
.badge-muted { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }
.badge-pending { background: rgba(14, 165, 233, 0.15); color: var(--teal); }

/* --- Empty States --- */
.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.map-cta {
    display: block;
    text-decoration: none;
}

.map-cta:hover .empty-state {
    background: var(--surface-light);
    border-color: var(--teal);
    color: var(--text-primary);
}

/* --- Error Pages --- */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--amber-caution);
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Alerts --- */
.messages { margin-bottom: 1.5rem; }

.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.alert-success { background: rgba(34, 197, 94, 0.15); color: var(--green-go); border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: var(--amber-caution); border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.15); color: var(--red-cancel); border: 1px solid rgba(239, 68, 68, 0.3); }

/* --- Footer --- */
.footer {
    background: var(--ocean-mid);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
    margin-top: auto;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ============================================================
   SITE DETAIL PAGE
   These classes were in the template but had no rules at all,
   so the whole page rendered as an unstyled stack of text.
   ============================================================ */

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.breadcrumb-sep { color: var(--border); }

/* --- Site header --- */
.site-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.site-header-info { min-width: 0; }

.site-header-info h1 {
    font-size: 1.6rem;
    color: var(--white);
    line-height: 1.2;
}

.site-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.site-header-status {
    text-align: right;
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    border: 1px solid transparent;
}

.status-go {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green-go);
    border-color: rgba(34, 197, 94, 0.4);
}

.status-caution {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber-caution);
    border-color: rgba(245, 158, 11, 0.4);
}

.status-cancel {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red-cancel);
    border-color: rgba(239, 68, 68, 0.4);
}

.status-detail {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* --- Daily outlook table --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.forecast-table {
    min-width: 720px;
}

.forecast-table td {
    vertical-align: middle;
}

/* A left edge in the verdict colour: the row's status is then readable
   without parsing the badge, and survives being skimmed at speed. */
.forecast-row td:first-child {
    border-left: 3px solid transparent;
}

.row-go td:first-child { border-left-color: var(--green-go); }
.row-caution td:first-child { border-left-color: var(--amber-caution); }
.row-cancel td:first-child { border-left-color: var(--red-cancel); }

.row-today {
    background: rgba(14, 165, 233, 0.06);
}

.forecast-table .col-day { white-space: nowrap; }

.day-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.row-today .day-label { color: var(--teal-bright); }

.day-full-date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.forecast-table .col-num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.forecast-table th.col-num { text-align: right; }

/* Units sit smaller and dimmer so the eye lands on the number, and the
   decimal points still line up down the column. */
.unit {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: 0.3rem;
}

.risk-meter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 130px;
}

.risk-meter-track {
    flex: 1;
    height: 6px;
    background: var(--ocean-dark);
    border-radius: 999px;
    overflow: hidden;
}

.risk-meter-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--green-go);
}

.row-caution .risk-meter-fill { background: var(--amber-caution); }
.row-cancel .risk-meter-fill { background: var(--red-cancel); }

.risk-meter-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 2.6rem;
    text-align: right;
}

/* What drove the verdict, and what drove the probability. Both are the
   "why" behind a number, so they share a quiet, secondary treatment. */
.limiting {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.cause-note {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.model-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px dotted var(--border);
    cursor: help;
}

/* --- Chart tabs --- */
.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chart-tab {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.chart-tab:hover {
    color: var(--text-primary);
    border-color: var(--surface-light);
}

.chart-tab.active {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--white);
}

.chart-container {
    position: relative;
    height: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.section-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

/* --- Hourly breakdown --- */
.hourly-table { min-width: 640px; }

.hourly-table td {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.hourly-table .work-hour { background: rgba(14, 165, 233, 0.07); }
.hourly-table .off-hour { color: var(--text-secondary); }

.loading-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* --- Threshold panel --- */
.threshold-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.threshold-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}

.threshold-var {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.threshold-vals {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.threshold-caution { color: var(--amber-caution); }
.threshold-cancel { color: var(--red-cancel); }

/* --- Site form (sandbox self-service) --- */
.site-form { max-width: 560px; }

.form-row { margin-bottom: 1.1rem; }

.form-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
    width: 100%;
    background: var(--ocean-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--red-cancel);
    margin-top: 0.3rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red-cancel);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* --- Narrow screens --- */
@media (max-width: 640px) {
    .site-header {
        flex-direction: column;
        padding: 1.1rem;
    }

    .site-header-status { text-align: left; }

    .chart-container { height: 260px; }
}
