/* ============================================================
   WIS Analytics — global stylesheet
   Brand: Wellbore Integrity Solutions (WIS).
   Colors and typography follow the WIS Visual Brand Identity
   Guidelines (v4, Nov 2023) and Master Brand color guidelines:
   primary palette WIS Green #31b700 / WIS Gray #888b8d /
   WIS Black #231f20, secondary palette for accents and charts,
   Arial for everyday application use. Token names are unchanged
   so this file is a drop-in for the SvelteKit build.
   ============================================================ */

:root {
    /* Font Families — Arial is the WIS corporate typeface for everyday
       use (Libre Franklin is reserved for marketing collateral). */
    --font-body: Arial, 'Helvetica Neue', Helvetica, -apple-system, BlinkMacSystemFont, 'Segoe UI',
        Roboto, sans-serif;
    --font-heading: var(--font-body);
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

    /* ---- Brand green ramp (WIS Green #31b700, PMS 2421C) ---- */
    --green-50: #f0fae9;
    --green-100: #d8f3c2;
    --green-200: #b1e88c;
    --green-300: #7cd94a;
    --green-400: #31b700; /* WIS Green — official brand color */
    --green-500: #2aa000;
    --green-600: #238500; /* primary action — white text passes AA */
    --green-700: #1c6b00;
    --green-800: #155200;
    --green-900: #0e3800;

    /* ---- Ink / neutral ramp (WIS Black #231f20, Dark Gray #4d4d4d,
       Gray #888b8d, Light Gray #e8e7e8) ---- */
    --ink-900: #231f20; /* WIS Black */
    --ink-800: #383435;
    --ink-700: #4d4d4d; /* WIS Dark Gray */
    --ink-600: #636566;
    --ink-500: #737678;
    --ink-400: #888b8d; /* WIS Gray */
    --ink-300: #b3b5b6;
    --ink-200: #d6d7d8;
    --ink-100: #e8e7e8; /* WIS Light Gray — brand background color */
    --ink-50: #f4f4f4;
    --white: #ffffff;

    /* ---- WIS secondary palette (accents; charts, tables, graphs) ---- */
    --wis-yellow: #ffc629;
    --wis-orange: #ff7f30;
    --wis-blue: #2e6fb9;
    --wis-aqua: #18988b;
    --wis-red: #ea0029;

    /* Chart series colors (secondary palette per brand guidelines) */
    --chart-1: var(--green-400);
    --chart-2: var(--wis-blue);
    --chart-3: var(--wis-aqua);
    --chart-4: var(--wis-yellow);
    --chart-5: var(--wis-orange);
    --chart-6: var(--wis-red);
    --chart-7: var(--ink-400);

    /* Main Colors - Light Mode */
    --bg-main: #f4f4f4;

    /* Text Colors */
    --color-text: var(--ink-900);
    --color-text-light: var(--ink-500);

    /* Background Colors */
    --color-bg-0: var(--white); /* Cards & surfaces */
    --color-bg-1: var(--ink-100); /* Sidebar & secondary surfaces */
    --color-bg-2: var(--ink-200); /* Borders & accent areas */
    --surface-card: var(--color-bg-0);
    --surface-sunken: var(--color-bg-1);
    --border-default: var(--color-bg-2);
    --border-strong: var(--ink-300);

    /* Theme Colors - WIS brand green (deep enough for white text → AA) */
    --color-theme-1: var(--green-600);
    --color-theme-2: var(--green-700);
    --brand: var(--green-400); /* vivid logo green — highlights, large fills */
    --brand-ink: var(--ink-900);

    /* Header Colors */
    --header-text-color: var(--ink-900);
    --subheader-text-color: var(--green-700);

    /* Button Colors */
    --button-bg: var(--green-600);
    --button-bg-hover: var(--green-700);
    --button-bg-disabled: var(--ink-300);
    --button-border: var(--color-bg-2);
    --button-border-hover: var(--green-600);
    --button-text-color-common: var(--white);

    /* Radio Button Colors */
    --radio-button-active: var(--green-600);
    --radio-button-inactive: var(--ink-400);

    /* Input Colors */
    --input-bg: var(--white);
    --input-border: var(--ink-200);
    --input-border-focus: var(--green-600);
    --focus-ring: rgba(35, 133, 0, 0.28);

    /* Semantic Colors (WIS palette: brand green, WIS Yellow/Red/Blue) */
    --color-success: var(--green-600);
    --color-warning: var(--wis-yellow);
    --color-error: var(--wis-red);
    --color-error-hover: #c10022;
    --color-info: var(--wis-blue);

    /* Status tints (badges, banners) */
    --success-bg: #eaf7e0; --success-fg: #1c6b00;
    --warning-bg: #fff4d4; --warning-fg: #7a5c00;
    --error-bg: #fde5e9; --error-fg: #b80021;
    --info-bg: #e7eef8; --info-fg: #245a96;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.5rem;
    --text-2xl: 1.85rem;
    --text-3xl: 2.5rem;

    /* Weights */
    --weight-light: 300;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Tracking */
    --tracking-tight: -0.02em;
    --tracking-wide: 0.08em;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(35, 31, 32, 0.08), 0 1px 2px rgba(35, 31, 32, 0.04);
    --shadow-md: 0 4px 6px rgba(35, 31, 32, 0.07), 0 2px 4px rgba(35, 31, 32, 0.05);
    --shadow-lg: 0 10px 15px rgba(35, 31, 32, 0.1), 0 4px 6px rgba(35, 31, 32, 0.05);
    --shadow-focus: 0 0 0 3px var(--focus-ring);

    /* Layout Variables */
    --sidebar-width: 250px;
    --content-max: 1200px;
    --column-width: 42rem;
    --column-margin-top: 4rem;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --border-radius-pill: 999px;

    /* Page gradient (subtle, brand-neutral gray per WIS backgrounds) */
    --page-gradient: linear-gradient(160deg, #f8f8f7 0%, var(--bg-main) 50%, #ebebea 100%);
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-body);
    color: var(--color-text);
    background-attachment: fixed;
    background-color: var(--bg-main);
    background-size: 100vw 100vh;
    background-image: var(--page-gradient);
}

h1,
h2,
p {
    font-weight: 400;
}

p {
    line-height: 1.6;
}

a {
    color: var(--color-theme-1);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-theme-2);
    text-decoration: underline;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--header-text-color);
    letter-spacing: var(--tracking-tight);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--subheader-text-color);
    letter-spacing: var(--tracking-tight);
}

pre {
    font-size: 16px;
    font-family: var(--font-mono);
    background-color: var(--surface-sunken);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1em;
    overflow-x: auto;
    color: var(--color-text);
}

.text-column {
    display: flex;
    max-width: 60rem;
    flex: 0.6;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}

/* Input and Button Base Styles */
input,
button,
textarea,
select {
    font-size: inherit;
    font-family: inherit;
}

/* Button Styles */
button {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    background-color: var(--button-bg);
    color: var(--button-text-color-common);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background-color: var(--button-bg-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

button:disabled {
    background-color: var(--button-bg-disabled);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

button:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* Input Fields */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    background-color: var(--input-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
    border-color: var(--input-border-focus);
    outline: none;
    box-shadow: var(--shadow-focus);
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="number"]:disabled,
input[type="date"]:disabled,
input[type="time"]:disabled,
textarea:disabled,
select:disabled {
    background-color: var(--color-bg-1);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Radio Buttons */
.radio-button,
input[type="radio"] {
    appearance: none;
    /* min-width/min-height as well as width/height so a page-level rule that
       sets `width: auto` on form controls can't collapse the control to a
       sliver and push the checked dot outside it */
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    box-sizing: border-box;
    border: 2px solid var(--radio-button-inactive);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: border-color 0.3s ease;
    flex-shrink: 0;
}

.radio-button:checked,
input[type="radio"]:checked {
    border-color: var(--radio-button-active);
}

.radio-button:checked::after,
input[type="radio"]:checked::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: var(--radio-button-active);
    border-radius: 50%;
    position: absolute;
    /* centre off the control itself rather than fixed offsets, so the dot stays
       inside the ring whatever size the control ends up */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.radio-button:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Checkboxes */
input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    box-sizing: border-box;
    border: 2px solid var(--radio-button-inactive);
    border-radius: var(--border-radius-sm);
    position: relative;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

input[type="checkbox"]:checked {
    background-color: var(--radio-button-active);
    border-color: var(--radio-button-active);
}

input[type="checkbox"]:checked::after {
    content: '\2713';
    color: white;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Headers and Subheaders */
.header {
    color: var(--header-text-color);
}

.subheader {
    color: var(--subheader-text-color);
}

/* Legend Text for Charts */
.legend-text {
    fill: var(--color-text);
    font-size: 12px;
}

@media (min-width: 720px) {
    h1 {
        font-size: 2.4rem;
    }
}

.visually-hidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: auto;
    margin: 0;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
}

/* ============ DARK THEME (derived from WIS Black #231f20) ============ */
[data-theme="dark"] {
    /* Surfaces — dark neutrals anchored on WIS Black */
    --bg-main: #171516;

    /* Text Colors */
    --color-text: #e8e7e8; /* WIS Light Gray */
    --color-text-light: #9b9d9f;

    /* Background Colors */
    --color-bg-0: #211e1f; /* Cards & surfaces */
    --color-bg-1: #1b191a; /* Sidebar */
    --color-bg-2: #363233; /* Borders & accent areas */
    --border-strong: #474344;

    /* Theme Colors — WIS Green brightened for legibility on dark */
    --color-theme-1: #4bd317;
    --color-theme-2: #71e243;
    --brand: #4bd317;
    --brand-ink: #e8e7e8;

    /* Header Colors */
    --header-text-color: #f2f1f1;
    --subheader-text-color: #71e243;

    /* Button Colors — vivid WIS green reads well on dark */
    --button-bg: var(--green-500);
    --button-bg-hover: var(--green-400);
    --button-bg-disabled: #3b3738;
    --button-border: var(--color-bg-2);
    --button-border-hover: var(--green-400);
    --button-text-color-common: #0d2400;

    /* Radio Button Colors */
    --radio-button-active: #4bd317;
    --radio-button-inactive: #474344;

    /* Input Colors */
    --input-bg: #211e1f;
    --input-border: #363233;
    --input-border-focus: #4bd317;
    --focus-ring: rgba(75, 211, 23, 0.28);

    /* Semantic Colors (WIS palette, brightened for dark surfaces) */
    --color-success: #4bd317;
    --color-warning: #ffd257;
    --color-error: #ff5273;
    --color-error-hover: #ff7590;
    --color-info: #6ba3e8;

    /* Status tints */
    --success-bg: #1a2c10; --success-fg: #8ce95f;
    --warning-bg: #332a12; --warning-fg: #ffd984;
    --error-bg: #351a20; --error-fg: #ff8ba2;
    --info-bg: #182739; --info-fg: #9dc3f0;

    /* Chart series colors — brightened for dark surfaces */
    --chart-1: #4bd317;
    --chart-2: #5c96d9;
    --chart-3: #2dbcac;
    --chart-4: #ffd257;
    --chart-5: #ff9a5c;
    --chart-6: #ff5273;
    --chart-7: #9b9d9f;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.25);

    /* Page gradient */
    --page-gradient: linear-gradient(160deg, #131112 0%, #171516 50%, #1a1819 100%);
}

/* Dark Theme - Element-specific overrides */
[data-theme="dark"] a {
    color: var(--color-theme-1);
}

[data-theme="dark"] a:hover {
    color: var(--color-theme-2);
}
