/* ═══════════════════════════════════════════════════
   WS Meteo Widget v2 — Stiluri
   WebSketch Agency · websketch.ro
═══════════════════════════════════════════════════ */

/* ── Reset scoped ── */
.wsm-widget *,
.wsm-widget *::before,
.wsm-widget *::after {
    box-sizing: border-box;
}

/* ── Container ── */
.wsm-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 13px;
    line-height: 1.4;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
    max-width: 540px;
    width: 100%;
    margin: 0 auto;
}

.wsm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 11px;
    background: #1a1a2e;
    gap: 8px;
}

.wsm-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wsm-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
    margin: 0;
}

.wsm-city {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    text-decoration: none;
    transition: color 0.15s;
}
.wsm-city:hover { color: #fff; }


/* ── AQI HERO ── */
.wsm-aqi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px 12px;
    transition: background 0.4s, color 0.4s;
    flex-wrap: wrap;
}

.wsm-aqi-num {
    font-size: 52px;
    font-weight: 900;
    line-height: 1;
    min-width: 70px;
    letter-spacing: -2px;
}

.wsm-aqi-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.wsm-aqi-status {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
}

.wsm-aqi-dom-inline {
    font-size: 11px;
    opacity: 0.8;
}

/* ── Scala AQI ── */
.wsm-scale-wrap {
    padding: 12px 16px 8px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.07);
}

.wsm-scale-bar {
    position: relative;
    display: flex;
    height: 9px;
    border-radius: 5px;
    overflow: visible;
    gap: 1.5px;
    margin-bottom: 4px;
}

.wsm-scale-seg {
    flex: 1;
    border-radius: 2px;
}

.wsm-scale-needle {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 17px;
    background: #1a1a2e;
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #1a1a2e;
    transition: left 0.6s cubic-bezier(.34,1.56,.64,1);
}

.wsm-scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #94a3b8;
    margin-top: 2px;
    padding: 0 1px;
}

.wsm-scale-msg {
    font-size: 12px;
    color: #334155;
    line-height: 1.45;
    margin-top: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid currentColor;
    font-style: italic;
}

/* Flash on refresh */
@keyframes wsm-flash-anim {
    0%   { opacity: 1; }
    40%  { opacity: 0.7; }
    100% { opacity: 1; }
}
.wsm-aqi.wsm-flash {
    animation: wsm-flash-anim 0.5s ease;
}

/* ── BODY ── */
.wsm-body {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* ── Period bar ── */
.wsm-period-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 7px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.wsm-period-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    margin-right: 2px;
}

.wsm-period-btn {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1.5px solid #e2e8f0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.wsm-period-btn:hover {
    border-color: #94a3b8;
    color: #334155;
}

.wsm-period-btn.active {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
}

.wsm-refresh-badge {
    margin-left: auto;
    font-size: 10px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wsm-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: wsm-pulse 2s infinite;
}

@keyframes wsm-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.wsm-countdown {
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    display: inline-block;
}

/* ── METRIC ROWS ── */
.wsm-metric-row {
    display: grid;
    grid-template-columns: 90px 1fr 36px;
    align-items: center;
    gap: 0;
    padding: 6px 12px 6px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    transition: background 0.1s;
}

.wsm-metric-row:last-child {
    border-bottom: none;
}

.wsm-metric-row:hover {
    background: #f8fafc;
}

/* Left column */
.wsm-metric-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.wsm-metric-name {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}

.wsm-metric-val {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.wsm-metric-unit {
    font-size: 9px;
    color: #94a3b8;
    font-weight: 400;
}

/* Center — chart */
.wsm-metric-chart-wrap {
    height: 44px;
    position: relative;
    padding: 0 4px;
}

.wsm-chart-canvas {
    display: block;
    width: 100% !important;
    height: 44px !important;
}

.wsm-no-data {
    display: none;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 9px;
    color: #cbd5e1;
    text-align: center;
    font-style: italic;
}

/* Right column — min/max */
.wsm-metric-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding-left: 4px;
}

.wsm-stat-max {
    font-size: 11px;
    font-weight: 700;
    color: #e53e3e;
}

.wsm-stat-min {
    font-size: 11px;
    font-weight: 700;
    color: #38a169;
}

/* ── FOOTER ── */
.wsm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
    font-size: 10px;
    color: #94a3b8;
}

.wsm-sources {
    display: flex;
    align-items: center;
    gap: 3px;
}

.wsm-attribution {
    color: #94a3b8;
    text-decoration: none;
    font-size: 10px;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.wsm-attribution:hover { opacity: 1; }

/* ── Error ── */
.wsm-error {
    padding: 14px 16px;
    background: #fff5f5;
    border-left: 4px solid #fc8181;
    color: #c53030;
    border-radius: 8px;
    font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 400px) {
    .wsm-aqi-num {
        font-size: 40px;
        min-width: 55px;
    }
    .wsm-metric-row {
        grid-template-columns: 76px 1fr 30px;
        padding: 5px 8px 5px 12px;
    }
    .wsm-metric-val {
        font-size: 17px;
    }
    .wsm-aqi-dom {
        display: none;
    }
}

/* ── Buton Legendă ── */
.wsm-legend-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    padding: 3px 9px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}
.wsm-legend-btn:hover,
.wsm-legend-btn.active {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
}

/* ── Legendă AQI ── */
.wsm-legend {
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.wsm-legend-title {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
}

.wsm-legend-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    line-height: 1.45;
}

.wsm-legend-table thead tr {
    background: #1a1a2e;
    color: #94a3b8;
}

.wsm-legend-table th {
    padding: 7px 10px;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    white-space: nowrap;
}

.wsm-legend-table td {
    padding: 8px 10px;
    vertical-align: top;
    border-top: 1px solid rgba(0,0,0,0.07);
}

.wsm-legend-table td:first-child {
    font-weight: 800;
    font-size: 12px;
    white-space: nowrap;
    min-width: 52px;
}

.wsm-legend-table td:nth-child(2) {
    white-space: nowrap;
    min-width: 100px;
}

/* Pe mobile ascundem coloanele Health + Cautionary */
@media (max-width: 480px) {
    .wsm-legend-table th:nth-child(n+3),
    .wsm-legend-table td:nth-child(n+3) { display: none; }
}

@media (max-width: 360px) {
    .wsm-period-bar { flex-wrap: wrap; row-gap: 5px; }
    .wsm-legend-btn { margin-left: 0; }
}

/* ── Trend sparkline ── */
.wsm-trend-wrap {
    position: absolute;
    top: 10px;
    right: 12px;
}

.wsm-aqi {
    position: relative; /* needed for trend-wrap */
}

.wsm-trend-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 5px 8px 4px;
    cursor: pointer;
    color: inherit;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
    font-family: inherit;
}
.wsm-trend-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.3);
}

.wsm-trend-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
}

.wsm-trend-icon {
    display: block;
    opacity: 0.9;
}

/* Popup */
.wsm-trend-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 999;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
    min-width: 240px;
    max-width: 290px;
    overflow: hidden;
    /* Pointer triangle */
}
.wsm-trend-popup::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0,0,0,0.06);
}

.wsm-trend-popup-inner {
    padding: 12px 14px 10px;
}

.wsm-trend-loading,
.wsm-trend-nodata {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    padding: 16px 8px;
    font-style: italic;
}

.wsm-spark-block {
    margin-bottom: 10px;
}
.wsm-spark-block:last-child { margin-bottom: 0; }

.wsm-spark-label {
    font-size: 10px;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
}

.wsm-spark-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wsm-spark-row canvas {
    flex: 1;
    min-width: 0;
    height: 52px !important;
}

.wsm-spark-minmax {
    font-size: 10px;
    font-weight: 700;
    color: #e53e3e;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.wsm-spark-min-lbl {
    color: #38a169;
}

/* Mobile: popup devine fixed centrat */
@media (max-width: 400px) {
    .wsm-trend-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        min-width: 260px;
        z-index: 9999;
    }
    .wsm-trend-popup::before { display: none; }
}
