/* Nord Pool Electricity Price — Estonia
   Dark energy-dashboard aesthetic. Electric blue + status greens/reds.
   --np-status-color is injected inline by PHP on .np-hero.             */

/* ── Status colour tokens ─────────────────────────────────────────────────── */
:root {
    --np-very-cheap:     #4ade80;
    --np-cheap:          #86efac;
    --np-normal:         #94a3b8;
    --np-expensive:      #fb923c;
    --np-very-expensive: #f87171;
    --np-bg:             #0d1117;
    --np-surface:        #161b22;
    --np-border:         rgba(255,255,255,0.08);
}

/* ── Region selector ──────────────────────────────────────────────────────── */
.np-region-selector {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.np-region-btn {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--np-border);
    background: var(--np-surface);
    color: var(--color-text-2);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.np-region-btn:hover {
    border-color: rgba(255,255,255,0.2);
    color: var(--color-text-1);
}

.np-region-btn--active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #000;
}

/* ── Error state ──────────────────────────────────────────────────────────── */
.np-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.np-error__icon {
    font-size: 3rem;
    opacity: 0.5;
}

.np-error h3 {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-error);
    margin: 0;
}

.np-error p {
    color: var(--color-text-2);
    margin: 0;
    max-width: 36ch;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.np-hero {
    background: linear-gradient(145deg, #0a0f1a 0%, #0f172a 100%);
    padding: var(--space-8) var(--space-6) var(--space-6);
    border-bottom: 1px solid var(--np-border);
    position: relative;
    overflow: hidden;
}

/* Ambient glow from status color */
.np-hero::before {
    content: '';
    position: absolute;
    top: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--np-status-color, #4ade80) 0%, transparent 65%);
    opacity: 0.07;
    border-radius: 50%;
    pointer-events: none;
}

.np-hero__date {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.04em;
    margin-bottom: var(--space-4);
    font-family: var(--font-mono);
}

.np-hero__main {
    display: flex;
    align-items: flex-start;
    gap: var(--space-5);
    flex-wrap: nowrap;       /* prevent appliance block from wrapping on desktop */
    margin-bottom: var(--space-4);
    min-width: 0;            /* allow children to shrink inside flex */
}

.np-hero__price-wrap {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.np-hero__price {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--np-status-color, #4ade80);
    line-height: 1;
    letter-spacing: -2px;
    text-shadow:
        0 0 20px color-mix(in srgb, var(--np-status-color, #4ade80) 50%, transparent),
        0 0 40px color-mix(in srgb, var(--np-status-color, #4ade80) 20%, transparent);
}

.np-hero__unit {
    font-size: var(--text-base);
    color: rgba(255,255,255,0.4);
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.np-hero__price-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    min-width: 50%;
}

.np-hero__vat-note {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.04em;
}

.np-hero__status-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: 0.4rem;
}

.np-hero__hour {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.35);
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

.np-hero__now-cost {
    /* Push to right of the flex row but don't participate in baseline alignment */
    margin-left: auto;
    align-self: flex-end;
    padding-bottom: 0.35rem; /* visual baseline with the unit label */
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    /* Subtle divider from the price block */
    padding-left: var(--space-5);
    border-left: 1px solid var(--np-border);
}

.np-hero__now-item {
    /* Each appliance on a single row: icon+name left, price right */
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-2);
    line-height: 1.4;
}

.np-hero__now-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.25);
    margin-bottom: var(--space-1);
}

.np-hero__now-name {
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    flex: 1;
}

.np-hero__now-price {
    font-size: var(--text-sm);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--np-status-color, #94a3b8);
    /* Keep price right-aligned and prevent shrink */
    flex-shrink: 0;
    text-align: right;
    min-width: 4ch;
}

.np-hero__recommendation {
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.6);
    line-height: 1.6;
    /*max-width: 56ch;*/
}

/* Status badges */
.np-status-badge {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: var(--space-1);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.np-status-badge--very_cheap     { background: rgba(74,222,128,0.15); color: var(--np-very-cheap);     border-color: rgba(74,222,128,0.3); }
.np-status-badge--cheap          { background: rgba(134,239,172,0.12); color: var(--np-cheap);          border-color: rgba(134,239,172,0.25); }
.np-status-badge--normal         { background: rgba(148,163,184,0.12); color: var(--np-normal);         border-color: rgba(148,163,184,0.25); }
.np-status-badge--expensive      { background: rgba(251,146,60,0.15);  color: var(--np-expensive);      border-color: rgba(251,146,60,0.3); }
.np-status-badge--very_expensive { background: rgba(248,113,113,0.15); color: var(--np-very-expensive); border-color: rgba(248,113,113,0.3); }

/* ── Stats strip ─────────────────────────────────────────────────────────── */
.np-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--np-surface);
    border-bottom: 1px solid var(--np-border);
}

.np-stats__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3) var(--space-2);
    gap: 2px;
    border-right: 1px solid var(--np-border);
}

.np-stats__item:last-child { border-right: none; }

.np-stats__label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
}

.np-stats__value {
    font-size: var(--text-xl);
    font-weight: 800;
    font-family: var(--font-mono);
    color: rgba(255,255,255,0.85);
    line-height: 1.1;
}

.np-stats__value--min { color: var(--np-very-cheap); }
.np-stats__value--max { color: var(--np-very-expensive); }

.np-stats__unit {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.25);
    letter-spacing: 0.06em;
}

/* ── Section header ─────────────────────────────────────────────────────── */
.np-section-header {
    padding: var(--space-5) var(--space-5) var(--space-3);
    border-bottom: 1px solid var(--np-border);
}

.np-section-header--periods {
    margin-top: 0;
}

.np-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    margin: 0;
}

.np-section-desc {
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.4);
    margin: var(--space-1) 0 0;
}

/* ── Chart ────────────────────────────────────────────────────────────────── */
.np-chart-section {
    background: var(--np-bg);
    border-bottom: 1px solid var(--np-border);
}

.np-chart-wrap {
    padding: var(--space-3) var(--space-3) var(--space-2);
}

.np-chart {
    display: block;
    width: 100%;
    cursor: crosshair;
}

/* Floating tooltip rendered by JS */
.np-chart-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.9);
    font-size: var(--text-xs);
    font-family: var(--font-mono);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ── Best Periods ────────────────────────────────────────────────────────── */
.np-periods {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--np-bg);
    border-bottom: 1px solid var(--np-border);
}

.np-period {
    padding: var(--space-4) var(--space-4);
    border-right: 1px solid var(--np-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.np-period:last-child { border-right: none; }

.np-period__tag {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
}

.np-period__time {
    font-size: var(--text-lg);
    font-weight: 700;
    font-family: var(--font-mono);
    color: rgba(255,255,255,0.9);
    line-height: 1.1;
}

.np-period__price {
    font-size: var(--text-base);
    font-weight: 700;
    font-family: var(--font-mono);
}

.np-period--cheap  .np-period__price { color: var(--np-very-cheap); }
.np-period--peak   .np-period__price { color: var(--np-very-expensive); }

.np-period__price span {
    font-size: var(--text-xs);
    font-weight: 400;
    color: rgba(255,255,255,0.3);
}

.np-period__delta {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.35);
    font-family: var(--font-mono);
}

.np-period__now {
    font-size: var(--text-xs);
    color: var(--np-very-cheap);
    font-weight: 600;
}

.np-period__past {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.2);
}

.np-period__examples {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--np-border);
}

.np-period__ex-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.25);
    margin-bottom: 2px;
}

.np-period__ex {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.5);
    overflow: hidden;
}

.np-period__ex-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.np-period__ex strong {
    font-family: var(--font-mono);
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    margin-left: auto;
}

.np-period--cheap .np-period__ex { color: rgba(74,222,128,0.7); }
.np-period--cheap .np-period__ex strong { color: var(--np-very-cheap); }
.np-period--peak  .np-period__ex { color: rgba(248,113,113,0.7); }
.np-period--peak  .np-period__ex strong { color: var(--np-very-expensive); }

/* ── Savings Calculator ──────────────────────────────────────────────────── */
.np-savings-section {
    padding: var(--space-5) var(--space-5) var(--space-6);
    background: var(--np-surface);
    border-bottom: 1px solid var(--np-border);
}

.np-savings-section .np-section-header {
    padding: 0 0 var(--space-3);
    border-bottom: none;
}

.np-savings-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

/* Appliance picker spans full width, inputs row below */
.np-savings-inputs {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
    margin-top: var(--space-3);
}

.np-savings-inputs .input-group {
    max-width: 200px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.np-savings-inputs .form-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    margin: 0;
}

.np-savings-inputs .input-group__wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.np-savings-inputs .input-group__wrapper .form-input {
    flex: 1;
    padding-right: var(--space-6);
}

.np-savings-inputs .input-group__wrapper .input-suffix {
    position: absolute;
    
    pointer-events: none;
}

/* ── Appliance checkbox picker ───────────────────────────────────────────── */
.np-appliance-picker {
    border: 1px solid var(--np-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4) var(--space-4);
    margin: var(--space-3) 0 0;
    /* Reset fieldset defaults */
    min-width: 0;
}

.np-appliance-picker__legend {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    padding: 0 var(--space-2);
    /* Float legend out of border by browser default — keep it */
}

.np-appliance-picker__grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-2);
    margin-top: var(--space-2);
}

/* Each chip is a <label> wrapping a hidden <input type="checkbox"> */
.np-app-chip {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-2);
    background: var(--np-bg);
    border: 1px solid var(--np-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
    /* Prevent text selection on double-click */
    user-select: none;
    -webkit-user-select: none;
    /* Fixed height for uniform cards */
    height: 100px;
    min-height: 100px;
}

.np-app-chip:hover {
    border-color: rgba(255,255,255,0.2);
    background: var(--np-surface);
}

/* Visually-hidden checkbox — keep it accessible for keyboard/screen readers */
.np-app-chip__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Checked state: amber border + subtle amber tint background */
.np-app-chip__input:checked + .np-app-chip__icon {
    filter: none;
}

.np-app-chip:has(.np-app-chip__input:checked) {
    border-color: var(--color-accent);
    background: rgba(240, 160, 48, 0.1);
}

/* Checkmark badge in top-right corner when checked */
.np-app-chip:has(.np-app-chip__input:checked)::after {
    content: '✓';
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    font-size: 0.55rem;
    font-weight: 800;
    line-height: 1;
    color: var(--color-accent);
}

/* Focus-visible ring for keyboard navigation */
.np-app-chip__input:focus-visible + .np-app-chip__icon {
    outline: none; /* handled on the label below */
}

.np-app-chip:focus-within {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.np-app-chip__icon {
    font-size: var(--text-xl);
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s, transform 0.15s;
}

.np-app-chip:hover .np-app-chip__icon,
.np-app-chip:has(.np-app-chip__input:checked) .np-app-chip__icon {
    opacity: 1;
}

.np-app-chip:has(.np-app-chip__input:checked) .np-app-chip__icon {
    transform: scale(1.1);
}

.np-app-chip__name {
    font-size: 0.6rem;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    line-height: 1.3;
    /* Clip the wattage onto a second line naturally — no truncation */
    word-break: break-word;
    transition: color 0.15s;
}

.np-app-chip:hover .np-app-chip__name,
.np-app-chip:has(.np-app-chip__input:checked) .np-app-chip__name {
    color: rgba(255,255,255,0.8);
}

.np-savings-result {
    margin-top: var(--space-4);
    border: 1px solid var(--np-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.np-savings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--np-border);
    color: rgba(255,255,255,0.6);
}

.np-savings-row:last-child { border-bottom: none; }

.np-savings-row strong { color: rgba(255,255,255,0.9); font-family: var(--font-mono); }

.np-savings-row__value--cheap { color: var(--np-very-cheap) !important; }

.np-savings-row--highlight {
    background: rgba(74,222,128,0.06);
    color: var(--np-very-cheap);
}

.np-savings-row--highlight strong { color: var(--np-very-cheap); }

.np-savings-row--info {
    color: var(--color-text-2);
    font-style: italic;
    justify-content: flex-start;
}

/* ── Appliances ───────────────────────────────────────────────────────────── */
.np-appliances-section {
    padding: var(--space-5) var(--space-5) var(--space-6);
    background: var(--np-bg);
    border-bottom: 1px solid var(--np-border);
}

.np-appliances-section .np-section-header {
    padding: 0 0 var(--space-3);
    border-bottom: none;
}

.np-appliances {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.np-appliance {
    background: var(--np-surface);
    border: 1px solid var(--np-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    position: relative;
    min-width: 0; /* allow grid cell to shrink below content intrinsic width */
}

.np-appliance--run_now  { border-color: rgba(74,222,128,0.3); }
.np-appliance--delay    { border-color: rgba(248,113,113,0.3); }

.np-appliance__icon { font-size: var(--text-2xl); line-height: 1; }

.np-appliance__body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.np-appliance__name {
    font-size: var(--text-sm);
    font-weight: 700;
    color: rgba(255,255,255,0.85);
}

.np-appliance__detail {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.35);
    font-family: var(--font-mono);
    margin-top: auto;
    padding-top: var(--space-1);
}

.np-appliance__rec {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.55);
    margin-top: auto;
    padding-top: var(--space-2);
}

.np-appliance--run_now .np-appliance__rec { color: var(--np-very-cheap); }
.np-appliance--delay   .np-appliance__rec { color: var(--np-very-expensive); }

.np-appliance__savings {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--np-border);
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.3);
}

.np-appliance__savings strong {
    color: var(--np-very-cheap);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* ── Share ────────────────────────────────────────────────────────────────── */
.np-share {
    padding: var(--space-4) var(--space-5);
    background: var(--np-surface);
    display: flex;
    justify-content: flex-end;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .np-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .np-stats__item:nth-child(2) { border-right: none; }
    .np-stats__item:nth-child(1),
    .np-stats__item:nth-child(2) { border-bottom: 1px solid var(--np-border); }

    .np-periods {
        grid-template-columns: repeat(2, 1fr);
    }
    .np-period:nth-child(2) { border-right: none; }
    .np-period:nth-child(1),
    .np-period:nth-child(2) { border-bottom: 1px solid var(--np-border); }

    .np-appliances {
        grid-template-columns: 1fr;
    }

    .np-hero__price {
        font-size: clamp(2.5rem, 14vw, 3.5rem);
    }

    .np-savings-form {
        flex-direction: column;
        align-items: stretch;
    }

    .np-savings-form .input-group {
        max-width: 100%;
    }

    .np-savings-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .np-savings-inputs .input-group {
        max-width: 100%;
    }

    .np-appliance-picker__grid {
        grid-template-columns: repeat(5, 1fr);
    }

    /* Appliance cost block: allow wrapping and remove left divider on tablet */
    .np-hero__main {
        flex-wrap: wrap;
    }

    .np-hero__now-cost {
        /* Move below the price+status pair, full-width row */
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid var(--np-border);
        padding-top: var(--space-3);
        /* Lay the three items side-by-side horizontally */
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-3) var(--space-5);
        width: 100%;
        align-self: auto;
        padding-bottom: 0;
    }

    .np-hero__now-item {
        /* On tablet each item is still a row — just in a horizontal cluster */
        flex: 0 0 auto;
    }

    .np-hero__now-name {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .np-periods {
        grid-template-columns: 1fr 1fr;
    }

    .np-hero {
        padding: var(--space-6) var(--space-4) var(--space-5);
    }

    .np-stats__value {
        font-size: var(--text-lg);
    }

    /* On small phones: stack appliance items vertically again,
       full-width each, name+price still on same line (row) */
    .np-hero__now-cost {
        flex-direction: column;
        gap: var(--space-2);
    }

    .np-hero__now-item {
        width: 100%;
    }

    .np-hero__now-name {
        flex: 1;
    }

    /* At 480px the 5-col chip grid is too narrow — drop to 4 columns (2.5 per row) */
    .np-appliance-picker__grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .np-app-chip {
        padding: var(--space-2) var(--space-1);
    }

    .np-app-chip__icon {
        font-size: var(--text-lg);
    }
}

/* ── Unavailable state ───────────────────────────────────────────────────── */
.np-unavailable {
    padding: var(--space-6);
    text-align: center;
    color: var(--color-text-2);
    font-size: var(--text-sm);
    border: 1px solid var(--np-border);
    border-radius: var(--radius-md);
    background: var(--np-surface);
}

.np-unavailable p {
    margin: 0;
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .np-hero::before { display: none; }
}
