/**
 * VM Forecast — Zaseban CSS za forecast stranice
 * Učitava se SAMO na /vremenska-prognoza-{slug}/ stranicama
 * @version 2.3
 */

/* ==========================================================================
   SEARCH (Autocomplete)
   ========================================================================== */

.vm-forecast-search {
    position: relative;
    max-width: 560px;
    margin: 0 auto 2rem;
}

.vm-forecast-search__input {
    width: 100%;
    padding: 0.95rem 1rem 0.95rem 3.2rem;
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-radius: var(--vm-radius, 12px);
    font-size: 1.05rem;
    background: var(--vm-card-bg, #fff);
    color: var(--vm-text-primary, #0f172a);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.vm-forecast-search__input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.vm-forecast-search__icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--vm-text-muted, #64748b);
    pointer-events: none;
}

.vm-forecast-search__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--vm-card-bg, #fff);
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-top: none;
    border-radius: 0 0 var(--vm-radius, 12px) var(--vm-radius, 12px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 50;
    max-height: 360px;
    overflow-y: auto;
    display: none;
}

.vm-forecast-search__dropdown--visible {
    display: block;
}

.vm-forecast-search__item {
    display: block;
    padding: 0.75rem 1.15rem;
    text-decoration: none;
    color: var(--vm-text-primary, #0f172a);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--vm-border-color, #cbd5e1);
    transition: background 0.1s;
}

.vm-forecast-search__item:last-child {
    border-bottom: none;
}

.vm-forecast-search__item:hover,
.vm-forecast-search__item--active {
    background: rgba(59,130,246,0.06);
    color: #2563eb;
}

.vm-forecast-search__item-region {
    float: right;
    font-size: 0.8rem;
    color: var(--vm-text-muted, #64748b);
}

/* ==========================================================================
   SECTIONS
   ========================================================================== */

.vm-forecast-section {
    margin-top: 2.5rem;
}

.vm-forecast-section:first-of-type {
    margin-top: 1.5rem;
}

.vm-forecast-section__title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--vm-text-primary, #0f172a);
    margin: 0 0 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid;
    border-image: linear-gradient(135deg, #3b82f6, #6366f1) 1;
}

/* ==========================================================================
   DAILY CARDS
   ========================================================================== */

.vm-forecast-daily-cards {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0 1rem;
    scrollbar-width: thin;
}

/* Scroll hint for daily cards — mobile only */
.vm-forecast-daily-hint {
    display: none;
    text-align: right;
    font-size: 0.75rem;
    color: var(--vm-text-muted, #64748b);
    padding: 0.15rem 0.5rem 0.5rem;
    animation: vm-hint-nudge 1.5s ease-in-out 2;
}

.vm-forecast-day-card {
    flex: 0 0 auto;
    min-width: 90px;
    background: var(--vm-card-bg, #fff);
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-radius: var(--vm-radius-small, 8px);
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.vm-forecast-day-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #3b82f6;
}

.vm-forecast-day-card--today { border-color: #3b82f6; background: rgba(59,130,246,0.04); }
.vm-forecast-day-card__date { font-size: 0.75rem; font-weight: 600; color: var(--vm-text-secondary, #475569); margin-bottom: 0.25rem; }
.vm-forecast-day-card__icon { width: 48px; height: 48px; margin: 0.25rem auto; display: block; }
.vm-forecast-day-card__temps { display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.25rem; }
.vm-forecast-day-card__tmax { color: #ef4444; font-weight: 700; font-size: 0.9rem; }
.vm-forecast-day-card__tmin { color: #3b82f6; font-weight: 600; font-size: 0.85rem; }
.vm-forecast-day-card__precip { font-size: 0.72rem; color: #3b82f6; margin-top: 0.15rem; min-height: 1em; }
.vm-forecast-day-card__label { font-size: 0.68rem; color: var(--vm-text-muted, #64748b); margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   PERIOD TOGGLE
   ========================================================================== */

.vm-forecast-period-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
}

.vm-forecast-period-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--vm-border-color, #cbd5e1);
    background: var(--vm-card-bg, #fff);
    color: var(--vm-text-secondary, #475569);
    cursor: pointer;
    transition: all 0.15s;
}

.vm-forecast-period-btn:first-child { border-radius: var(--vm-radius-small, 8px) 0 0 var(--vm-radius-small, 8px); }
.vm-forecast-period-btn:last-child { border-radius: 0 var(--vm-radius-small, 8px) var(--vm-radius-small, 8px) 0; border-left: none; }
.vm-forecast-period-btn--active { background: #3b82f6 !important; color: #fff !important; border-color: #3b82f6 !important; }

/* ==========================================================================
   CHARTS
   ========================================================================== */

.vm-forecast-chart-card {
    background: var(--vm-card-bg, #fff);
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-radius: var(--vm-radius, 12px);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.vm-forecast-chart-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--vm-text-primary, #0f172a);
    margin: 0 0 0.75rem;
}

.vm-forecast-chart-wrap { position: relative; height: 280px; }
.vm-forecast-chart-wrap--main { height: 340px; }
.vm-forecast-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.vm-forecast-chart-card--half .vm-forecast-chart-wrap { height: 240px; }

.vm-forecast-chart-icons { margin-bottom: 0.25rem; overflow-x: auto; }
.vm-forecast-chart-icons__row { display: flex; gap: 0; justify-content: space-around; min-width: 100%; }
.vm-forecast-chart-icons__row img { flex-shrink: 0; }

.vm-forecast-no-data { text-align: center; padding: 3rem 1rem; color: var(--vm-text-muted, #64748b); }

/* ==========================================================================
   FULL TABLE
   ========================================================================== */

.vm-forecast-full-table__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--vm-text-primary, #0f172a);
    margin: 0 0 1rem;
}

/* View toggle */
.vm-forecast-view-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
}

.vm-forecast-view-btn {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--vm-border-color, #cbd5e1);
    background: var(--vm-card-bg, #fff);
    color: var(--vm-text-secondary, #475569);
    cursor: pointer;
    transition: all 0.15s;
}

.vm-forecast-view-btn:first-child { border-radius: var(--vm-radius-small, 8px) 0 0 var(--vm-radius-small, 8px); }
.vm-forecast-view-btn:last-child { border-radius: 0 var(--vm-radius-small, 8px) var(--vm-radius-small, 8px) 0; border-left: none; }
.vm-forecast-view-btn--active { background: #3b82f6 !important; color: #fff !important; border-color: #3b82f6 !important; }

/* Day group */
.vm-forecast-day-group { margin-bottom: 1.5rem; }
.vm-forecast-day-group--today { border-left: 3px solid #3b82f6; padding-left: 0.75rem; }
.vm-forecast-day-group--highlight { animation: vm-day-flash 0.6s ease-out 2; }
@keyframes vm-day-flash { 0%,100% { background: transparent; } 50% { background: rgba(59,130,246,0.08); } }

.vm-forecast-day-group__header {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--vm-bg-secondary, #f1f5f9);
    border-radius: var(--vm-radius-small, 8px) var(--vm-radius-small, 8px) 0 0;
}

.vm-forecast-day-group__date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--vm-text-primary, #0f172a);
}

.vm-forecast-day-group__sun {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
}

.vm-forecast-day-group__sun span {
    font-size: 0.95rem;
}

/* Table */
.vm-forecast-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.vm-forecast-tbl {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.vm-forecast-tbl th {
    background: var(--vm-bg-secondary, #f1f5f9);
    padding: 0.5rem 0.4rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--vm-text-secondary, #475569);
    border-bottom: 2px solid var(--vm-border-color, #cbd5e1);
    white-space: nowrap;
}

.vm-forecast-tbl td {
    padding: 0.4rem;
    border-bottom: 1px solid var(--vm-border-color, #cbd5e1);
    color: var(--vm-text-primary, #0f172a);
    text-align: center;
    vertical-align: middle;
}

.vm-forecast-tbl td img {
    display: block;
    margin: 0 auto;
    width: 72px;
    height: 72px;
}

.vm-forecast-tbl tr:hover td { background: rgba(59,130,246,0.03); }

/* Temperature color in table (font-weight set inline) */
.vm-forecast-tbl td.vm-td-temp { font-weight: 700; }

/* UV index colored cell */
.vm-forecast-tbl td.vm-td-uv { border-radius: 4px; font-weight: 600; }

/* Scroll hint mobile */
.vm-forecast-scroll-hint {
    display: none;
    text-align: right;
    font-size: 0.72rem;
    color: var(--vm-text-muted, #64748b);
    padding: 0.25rem 0.5rem;
    animation: vm-hint-nudge 1.5s ease-in-out 2;
}

@keyframes vm-hint-nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(8px); } }

/* Cards view — hidden by default via JS inline style, shown as grid */
.vm-forecast-cards-view {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}
.vm-forecast-cards-view--visible {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.vm-forecast-hour-card {
    background: var(--vm-card-bg, #fff);
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-radius: var(--vm-radius-small, 8px);
    padding: 0.6rem;
    text-align: center;
}

.vm-forecast-hour-card__time { font-size: 0.78rem; font-weight: 700; color: var(--vm-text-primary, #0f172a); margin-bottom: 0.25rem; }
.vm-forecast-hour-card__icon { width: 48px; height: 48px; margin: 0 auto; display: block; }
.vm-forecast-hour-card__temp { font-size: 1rem; font-weight: 700; color: #ef4444; margin: 0.25rem 0; }
.vm-forecast-hour-card__wind { font-size: 0.72rem; color: var(--vm-text-secondary, #475569); }
.vm-forecast-hour-card__precip { font-size: 0.72rem; color: #3b82f6; font-weight: 600; }

/* ==========================================================================
   UPDATE / FRESHNESS
   ========================================================================== */

.vm-forecast-updated {
    text-align: center;
    padding: 1rem 1.25rem;
    font-size: 0.88rem;
    color: var(--vm-text-secondary, #475569);
    border: 1px solid var(--vm-border-color, #cbd5e1);
    border-radius: var(--vm-radius-small, 8px);
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.vm-forecast-updated__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.vm-forecast-updated--fresh .vm-forecast-updated__dot { background: #22c55e; }
.vm-forecast-updated--stale .vm-forecast-updated__dot { background: #f59e0b; }
.vm-forecast-updated--old .vm-forecast-updated__dot { background: #ef4444; }
.vm-forecast-updated--fresh { border-color: #22c55e; background: rgba(34,197,94,0.04); }
.vm-forecast-updated--stale { border-color: #f59e0b; background: rgba(245,158,11,0.04); }
.vm-forecast-updated--old { border-color: #ef4444; background: rgba(239,68,68,0.04); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .vm-forecast-charts-row { grid-template-columns: 1fr; }
    .vm-forecast-chart-wrap { height: 220px; }
    .vm-forecast-chart-wrap--main { height: 280px; }
    .vm-forecast-chart-card--half .vm-forecast-chart-wrap { height: 200px; }
    .vm-forecast-day-card { min-width: 80px; padding: 0.5rem 0.4rem; }
    .vm-forecast-day-card__icon { width: 36px; height: 36px; }
    .vm-forecast-day-group__header { position: sticky; top: 0; z-index: 5; }
    .vm-forecast-tbl { font-size: 0.75rem; }
    .vm-forecast-tbl td img { width: 48px; height: 48px; }
    .vm-forecast-scroll-hint { display: block; }
    .vm-forecast-daily-hint { display: block; }
    .vm-forecast-section__title { font-size: 1.05rem; }
}

@media (max-width: 480px) {
    .vm-forecast-day-card { min-width: 72px; }
    .vm-forecast-tbl td img { width: 36px; height: 36px; }
    .vm-forecast-day-group__sun { font-size: 0.85rem; }
    .vm-forecast-day-group__sun span { font-size: 0.82rem; }
    .vm-forecast-cards-view--visible { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
