/* ================================================================
   Meteo Widget Pro — CSS
   Design: minimalista ispirato a Meteoprog
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
.mw-widget {
    --mw-font:       'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Light theme */
    --mw-bg:         #ffffff;
    --mw-bg-soft:    #f5f7fa;
    --mw-bg-card:    #f0f4f9;
    --mw-border:     #e4e9f0;
    --mw-text:       #1a2332;
    --mw-text-muted: #6b7a8d;
    --mw-text-light: #9aabb8;
    --mw-accent:     #3b7dd8;
    --mw-accent-rgb: 59,125,216;
    --mw-hot:        #e05e34;
    --mw-cold:       #4aa3d4;
    --mw-sun:        #f6b93b;
    --mw-rain:       #5fa8d3;
    --mw-shadow:     0 2px 16px rgba(0,0,0,.07);
    --mw-radius:     14px;
    --mw-radius-sm:  8px;
}

/* Dark theme */
.mw-widget.mw-theme-dark {
    --mw-bg:         #161e2e;
    --mw-bg-soft:    #1d2844;
    --mw-bg-card:    #1a2237;
    --mw-border:     #2a3550;
    --mw-text:       #e8edf5;
    --mw-text-muted: #8da0bb;
    --mw-text-light: #4e6380;
    --mw-accent:     #5b9cf6;
    --mw-shadow:     0 2px 20px rgba(0,0,0,.35);
}

/* Auto theme: follow OS */
@media (prefers-color-scheme: dark) {
    .mw-widget.mw-theme-auto {
        --mw-bg:         #161e2e;
        --mw-bg-soft:    #1d2844;
        --mw-bg-card:    #1a2237;
        --mw-border:     #2a3550;
        --mw-text:       #e8edf5;
        --mw-text-muted: #8da0bb;
        --mw-text-light: #4e6380;
        --mw-accent:     #5b9cf6;
        --mw-shadow:     0 2px 20px rgba(0,0,0,.35);
    }
}

/* ── Base Layout ────────────────────────────────────────────── */
.mw-widget {
    font-family: var(--mw-font);
    background:  var(--mw-bg);
    border:      1px solid var(--mw-border);
    border-radius: var(--mw-radius);
    box-shadow:  var(--mw-shadow);
    color:       var(--mw-text);
    overflow:    hidden;
    max-width:   420px;
    width:       100%;
    position:    relative;
    transition:  background .25s, color .25s;
}

/* Sidebar context: full width */
.widget .mw-widget,
.wp-block-widget-group .mw-widget {
    max-width: 100%;
}

/* ── Header ─────────────────────────────────────────────────── */
.mw-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         14px 18px 10px;
    border-bottom:   1px solid var(--mw-border);
}

.mw-location {
    display:     flex;
    align-items: center;
    gap:         6px;
}

.mw-pin-icon {
    width:  16px;
    height: 16px;
    color:  var(--mw-accent);
    flex-shrink: 0;
}

.mw-city, .mw-city-link {
    font-size:   14px;
    font-weight: 600;
    color:       var(--mw-text);
    letter-spacing: .01em;
}

.mw-city-link {
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
.mw-city-link:hover { border-color: var(--mw-accent); color: var(--mw-accent); }

.mw-updated {
    font-size:  11px;
    color:      var(--mw-text-light);
    white-space: nowrap;
}

/* ── Current Weather ─────────────────────────────────────────── */
.mw-current { padding: 20px 18px 14px; }

.mw-temp-block {
    display:     flex;
    align-items: center;
    gap:         12px;
    flex-wrap:   wrap;
}

.mw-icon-wrap {
    flex-shrink: 0;
    background:  var(--mw-bg-soft);
    border-radius: 50%;
    width:  68px;
    height: 68px;
    display:        flex;
    align-items:    center;
    justify-content: center;
    border: 1px solid var(--mw-border);
}

.mw-icon {
    width:  52px;
    height: 52px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}

.mw-temp-main {
    display:     flex;
    align-items: baseline;
    line-height: 1;
}

.mw-temp {
    font-size:   52px;
    font-weight: 300;
    color:       var(--mw-text);
    letter-spacing: -.03em;
}

.mw-temp-sym {
    font-size:   22px;
    font-weight: 400;
    color:       var(--mw-text-muted);
    margin-left: 3px;
    margin-bottom: 8px;
}

.mw-desc-block {
    display:       flex;
    flex-direction: column;
    gap:           4px;
}

.mw-description {
    font-size:   14px;
    font-weight: 500;
    color:       var(--mw-text);
}

.mw-minmax {
    display:  flex;
    gap:      10px;
    font-size: 12px;
}

.mw-max { color: var(--mw-hot); font-weight: 500; }
.mw-min { color: var(--mw-cold); font-weight: 500; }

/* ── Quick Stats (standard + full) ──────────────────────────── */
.mw-quick-stats {
    display:        grid;
    grid-template-columns: repeat(4, 1fr);
    gap:            1px;
    background:     var(--mw-border);
    border:         1px solid var(--mw-border);
    border-radius:  var(--mw-radius-sm);
    overflow:       hidden;
    margin-top:     16px;
}

.mw-qs-item {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    padding:        10px 6px;
    background:     var(--mw-bg-soft);
    gap:            4px;
    text-align:     center;
}

.mw-qs-label {
    font-size:  10px;
    font-weight: 500;
    color:      var(--mw-text-light);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.mw-qs-val {
    font-size:   13px;
    font-weight: 600;
    color:       var(--mw-text);
}

@media (max-width: 320px) {
    .mw-quick-stats { grid-template-columns: repeat(2,1fr); }
}

/* ── Section Title ───────────────────────────────────────────── */
.mw-section-title {
    font-size:      11px;
    font-weight:    600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color:          var(--mw-text-light);
    margin-bottom:  10px;
}

/* ── Details Grid (full) ─────────────────────────────────────── */
.mw-details-grid {
    display:        grid;
    grid-template-columns: repeat(3, 1fr);
    gap:            8px;
    padding:        0 18px 16px;
}

@media (max-width: 320px) {
    .mw-details-grid { grid-template-columns: repeat(2,1fr); }
}

.mw-detail-item {
    background:     var(--mw-bg-soft);
    border:         1px solid var(--mw-border);
    border-radius:  var(--mw-radius-sm);
    padding:        10px 10px 8px;
    display:        flex;
    flex-direction: column;
    gap:            4px;
    transition:     background .15s;
}
.mw-detail-item:hover { background: var(--mw-bg-card); }

.mw-di-icon {
    width:  18px;
    height: 18px;
    color:  var(--mw-accent);
    display: block;
}
.mw-di-icon svg {
    width:  100%;
    height: 100%;
}

.mw-di-label {
    font-size:  10px;
    color:      var(--mw-text-light);
    font-weight: 500;
}

.mw-di-val {
    font-size:   13px;
    font-weight: 600;
    color:       var(--mw-text);
}

/* ── Sun Bar (full) ──────────────────────────────────────────── */
.mw-sun-bar {
    padding:   0 18px 16px;
}

.mw-sun-label {
    display:         flex;
    justify-content: space-between;
    font-size:       11px;
    color:           var(--mw-text-muted);
    margin-bottom:   6px;
}

.mw-sun-track {
    height:        6px;
    background:    var(--mw-bg-soft);
    border-radius: 99px;
    border:        1px solid var(--mw-border);
    position:      relative;
    overflow:      visible;
}

.mw-sun-fill {
    position:      absolute;
    left:          0; top: 0; bottom: 0;
    background:    linear-gradient(90deg, var(--mw-sun) 0%, #f39c12 100%);
    border-radius: 99px;
    transition:    width .4s ease;
}

.mw-sun-dot {
    position:    absolute;
    top:         50%;
    transform:   translate(-50%, -50%);
    width:       12px;
    height:      12px;
    background:  var(--mw-sun);
    border:      2px solid var(--mw-bg);
    border-radius: 50%;
    box-shadow:  0 1px 6px rgba(246,185,59,.5);
    transition:  left .4s ease;
}

/* ── Hourly Scroll (full) ────────────────────────────────────── */
.mw-hourly {
    padding:     0 18px 16px;
}

.mw-hourly-scroll {
    display:        flex;
    gap:            6px;
    overflow-x:     auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--mw-border) transparent;
}

.mw-hourly-item {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            4px;
    min-width:      54px;
    background:     var(--mw-bg-soft);
    border:         1px solid var(--mw-border);
    border-radius:  var(--mw-radius-sm);
    padding:        8px 4px;
    flex-shrink:    0;
}

.mw-h-time {
    font-size:   10px;
    font-weight: 500;
    color:       var(--mw-text-light);
}

.mw-h-icon {
    width: 28px;
    height: 28px;
}

.mw-h-temp {
    font-size:   12px;
    font-weight: 600;
    color:       var(--mw-text);
}

.mw-h-pop {
    font-size: 10px;
    color:     var(--mw-rain);
}

/* ── 5-Day Forecast ──────────────────────────────────────────── */
.mw-forecast {
    padding:       0 18px 16px;
    border-top:    1px solid var(--mw-border);
    padding-top:   16px;
    margin-top:    4px;
}

.mw-forecast-list {
    display:        flex;
    flex-direction: column;
    gap:            4px;
}

.mw-forecast-row {
    display:         flex;
    align-items:     center;
    gap:             10px;
    padding:         8px 10px;
    border-radius:   var(--mw-radius-sm);
    transition:      background .15s;
}
.mw-forecast-row:hover { background: var(--mw-bg-soft); }

.mw-f-day {
    font-size:   13px;
    font-weight: 500;
    width:       90px;
    flex-shrink: 0;
    color:       var(--mw-text);
}

.mw-f-icon {
    width:  30px;
    height: 30px;
    flex-shrink: 0;
}

.mw-f-desc {
    font-size:   12px;
    color:       var(--mw-text-muted);
    flex:        1;
    min-width:   0;
    overflow:    hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mw-f-temps {
    display: flex;
    gap:     6px;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.mw-f-max { color: var(--mw-hot); }
.mw-f-min { color: var(--mw-cold); }

.mw-f-pop {
    font-size: 11px;
    color:     var(--mw-rain);
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Footer ──────────────────────────────────────────────────── */
.mw-footer {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         8px 18px 12px;
    border-top:      1px solid var(--mw-border);
    background:      var(--mw-bg-soft);
}

.mw-attribution {
    font-size:       10px;
    color:           var(--mw-text-light);
    text-decoration: none;
}
.mw-attribution:hover { color: var(--mw-accent); }

.mw-refresh-btn {
    background:    none;
    border:        none;
    cursor:        pointer;
    padding:       4px;
    color:         var(--mw-text-light);
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    transition:    color .2s, transform .3s;
}
.mw-refresh-btn svg { width: 14px; height: 14px; }
.mw-refresh-btn:hover { color: var(--mw-accent); }
.mw-refresh-btn.mw-spinning svg { animation: mw-spin .8s linear infinite; }

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

/* ── Loading overlay ─────────────────────────────────────────── */
.mw-loading {
    position:       absolute;
    inset:          0;
    background:     rgba(var(--mw-bg), .75);
    display:        flex;
    align-items:    center;
    justify-content: center;
    border-radius:  var(--mw-radius);
    z-index:        10;
}

.mw-spinner {
    width:  24px;
    height: 24px;
    border: 3px solid var(--mw-border);
    border-top-color: var(--mw-accent);
    border-radius: 50%;
    animation: mw-spin .7s linear infinite;
}

/* ── Error ───────────────────────────────────────────────────── */
.mw-error {
    color:       #c0392b;
    font-size:   13px;
    padding:     16px 18px;
    background:  #fdf2f2;
    border:      1px solid #f5c6c6;
    border-radius: var(--mw-radius);
}

/* ── Minimal mode: hide extras ───────────────────────────────── */
.mw-detail-minimal .mw-quick-stats,
.mw-detail-minimal .mw-details-grid,
.mw-detail-minimal .mw-sun-bar,
.mw-detail-minimal .mw-hourly,
.mw-detail-minimal .mw-forecast {
    display: none;
}

/* ── Standard mode: hide full extras ────────────────────────── */
.mw-detail-standard .mw-details-grid,
.mw-detail-standard .mw-sun-bar,
.mw-detail-standard .mw-hourly {
    display: none;
}

/* ── Admin page styles ───────────────────────────────────────── */
.mw-admin-wrap { max-width: 860px; }

.mw-admin-title {
    font-size:    24px !important;
    margin-bottom: 24px !important;
}

.mw-admin-card {
    background:    #fff;
    border:        1px solid #dde2e8;
    border-radius: 10px;
    padding:       24px;
    margin-bottom: 20px;
    box-shadow:    0 1px 4px rgba(0,0,0,.05);
}

.mw-admin-card h2 {
    font-size:    16px;
    margin-top:   0;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
}

.mw-code-block {
    background:    #f6f8fa;
    border:        1px solid #e0e4ea;
    border-radius: 8px;
    padding:       14px;
    margin-bottom: 16px;
    overflow-x:    auto;
}

.mw-code-block code {
    font-family: 'Courier New', monospace;
    font-size:   13px;
    color:       #24292e;
}

.mw-params-table th { background: #f0f4f9; }
.mw-params-table td, .mw-params-table th { padding: 8px 12px; }
.mw-params-table code { background: #f0f4f9; padding: 2px 6px; border-radius: 4px; }

/* ── Footer actions (geolocation + refresh group) ───────────── */
.mw-footer-actions {
    display:     flex;
    align-items: center;
    gap:         4px;
}

/* ── Geo button ──────────────────────────────────────────────── */
.mw-geo-btn {
    background:    none;
    border:        none;
    cursor:        pointer;
    padding:       4px;
    color:         var(--mw-text-light);
    border-radius: 50%;
    display:       flex;
    align-items:   center;
    transition:    color .2s, transform .3s;
}
.mw-geo-btn svg { width: 15px; height: 15px; }
.mw-geo-btn:hover { color: var(--mw-accent); }
.mw-geo-btn.mw-spinning svg { animation: mw-spin .8s linear infinite; }

/* ── Geo loading message ─────────────────────────────────────── */
.mw-geo-msg {
    font-size:  11px;
    color:      var(--mw-accent);
    font-style: italic;
    animation:  mw-pulse 1.2s ease-in-out infinite;
}

@keyframes mw-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}

/* ── Inline error (non-breaking) ─────────────────────────────── */
.mw-inline-error {
    margin:        0 18px 10px;
    padding:       8px 12px;
    background:    #fff0f0;
    border:        1px solid #f5c6c6;
    border-radius: var(--mw-radius-sm);
    font-size:     12px;
    color:         #c0392b;
}

.mw-theme-dark .mw-inline-error {
    background: rgba(192,57,43,.15);
    border-color: rgba(192,57,43,.4);
    color: #e74c3c;
}
