/**
 * Стили для виджетов API (погода и курсы валют)
 * 
 * @package SlonimMedia
 * @since 2.0.0
 */

/* ==========================================================================
   Общие стили для API виджетов
   ========================================================================== */

.top-bar__weather,
.top-bar__currency {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    position: relative;
}

.top-bar__weather:hover,
.top-bar__currency:hover {
    color: var(--text-primary);
    background-color: var(--hover-bg);
}

/* Темная тема */
.dark-mode .top-bar__weather,
.dark-mode .top-bar__currency {
    color: var(--dark-text-secondary);
}

.dark-mode .top-bar__weather:hover,
.dark-mode .top-bar__currency:hover {
    color: var(--dark-text-primary);
    background-color: var(--dark-bg-secondary);
}

/* ==========================================================================
   Виджет погоды
   ========================================================================== */

.top-bar__weather {
    gap: 6px;
}

.top-bar__weather .weather-icon {
    font-size: 18px;
    line-height: 1;
}

.top-bar__weather .weather-temp {
    font-variant-numeric: tabular-nums;
}

/* Индикатор обновления погоды */
.top-bar__weather.is-updated .weather-icon {
    animation: weather-pulse 0.6s ease-out;
}

@keyframes weather-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ==========================================================================
   Виджет курсов валют
   ========================================================================== */

.top-bar__currency {
    gap: 12px;
    font-variant-numeric: tabular-nums;
}

.top-bar__currency .currency-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.top-bar__currency .currency-symbol {
    font-weight: 600;
    color: var(--text-tertiary);
}

.dark-mode .top-bar__currency .currency-symbol {
    color: var(--dark-text-tertiary);
}

/* ==========================================================================
   Состояния загрузки
   ========================================================================== */

.top-bar__weather.is-loading,
.top-bar__currency.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.top-bar__weather.is-loading::after,
.top-bar__currency.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -20px;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Состояние ошибки
   ========================================================================== */

.top-bar__weather.has-error,
.top-bar__currency.has-error {
    color: #dc2626;
}

.top-bar__weather.has-error::before,
.top-bar__currency.has-error::before {
    content: '⚠️';
    margin-right: 4px;
    font-size: 14px;
}

/* ==========================================================================
   Время и локация
   ========================================================================== */

.top-bar__time {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.top-bar__location {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-bar__location::before {
    content: '📍';
    font-size: 12px;
}

.top-bar__location-time {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Мобильная адаптация
   ========================================================================== */

@media (max-width: 768px) {
    /* Компактный вид для мобильных */
    .top-bar__weather {
        font-size: 13px;
        padding: 2px 6px;
    }
    
    .top-bar__weather .weather-icon {
        font-size: 16px;
    }
    
    .top-bar__currency {
        font-size: 13px;
        padding: 2px 6px;
    }
    
    /* Показываем только USD на мобильных */
    .top-bar__currency .currency-item:not(:first-child) {
        display: none;
    }
    
    /* Убираем индикатор загрузки на мобильных */
    .top-bar__weather.is-loading::after,
    .top-bar__currency.is-loading::after {
        display: none;
    }
    
    .top-bar__location-time {
        gap: 4px;
    }
}

@media (max-width: 480px) {
    /* Еще более компактный вид */
    .top-bar__weather,
    .top-bar__currency {
        font-size: 12px;
        gap: 4px;
    }
    
    .top-bar__time {
        font-size: 13px;
    }
    
    .top-bar__location {
        display: none;
    }
}

/* ==========================================================================
   Тултипы (для десктопа)
   ========================================================================== */

@media (hover: hover) {
    .top-bar__weather[title],
    .top-bar__currency[title] {
        position: relative;
    }
    
    .top-bar__weather[title]:hover::after,
    .top-bar__currency[title]:hover::after {
        content: attr(title);
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 8px;
        padding: 8px 12px;
        background: var(--bg-card);
        color: var(--text-primary);
        font-size: 12px;
        font-weight: 400;
        white-space: nowrap;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        pointer-events: none;
        opacity: 0;
        animation: tooltip-fade-in 0.2s ease-out forwards;
    }
    
    .dark-mode .top-bar__weather[title]:hover::after,
    .dark-mode .top-bar__currency[title]:hover::after {
        background: var(--dark-bg-card);
        color: var(--dark-text-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    @keyframes tooltip-fade-in {
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}

/* ==========================================================================
   Разделители
   ========================================================================== */

.top-bar__divider {
    width: 1px;
    height: 16px;
    background-color: var(--border-color);
    margin: 0 12px;
    opacity: 0.5;
}

.dark-mode .top-bar__divider {
    background-color: var(--dark-border-color);
}

@media (max-width: 768px) {
    .top-bar__divider {
        margin: 0 8px;
        height: 14px;
    }
}

/* ==========================================================================
   Анимация обновления данных
   ========================================================================== */

.top-bar__weather.is-updated,
.top-bar__currency.is-updated {
    animation: data-update 0.5s ease-out;
}

@keyframes data-update {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: var(--accent-color);
        color: white;
    }
    100% {
        background-color: transparent;
    }
}

/* ==========================================================================
   Интеграция с верхней панелью
   ========================================================================== */

.top-bar__info {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 14px;
}

.top-bar__info > * {
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .top-bar__info {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .top-bar__info {
        justify-content: center;
        width: 100%;
    }
}

/* ==========================================================================
   Печать
   ========================================================================== */

@media print {
    .top-bar__weather,
    .top-bar__currency,
    .top-bar__divider {
        display: none;
    }
}