/* ===== НАСТРОЙКИ (меняются через settings.json) ===== */
:root {
    /* Базовые fallback-значения — переопределяются JS из settings.json */
    --bg-color: #000;
    --text-color: #fff;
    --accent-bg: #1a1a1a;
    --accent-hover: #333;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --video-max-height: 85vh;
    --video-max-height-mobile: 60vh;
    --video-max-width: 400px;
    --side-panel-width: 340px;
    --border-radius: 12px;
}

/* ===== СБРОС И БАЗА ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image: var(--bg-image);
    background-position: var(--bg-image-position);
    background-size: var(--bg-image-size);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-color);
    height: 100vh;
    overflow: auto;
}

/* ===== ГЛАВНЫЙ КОНТЕЙНЕР ===== */
.app-container {
    display: flex;
    height: 100vh;
    justify-content: center;
    align-items: center;
    gap: 0;
}

/* ===== ВИДЕО-ОБЛАСТЬ ===== */
.video-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.video-wrapper {
    position: relative;
    max-width: var(--video-max-width);
    max-height: var(--video-max-height);
    width: 100%;
    height: 100%;
}

.video-container {
    width: 100%;
    height: 100%;
    max-height: var(--video-max-height);
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

.video-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== ЛОАДЕР ===== */
.loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.8);
    color: #ccc;
    font-size: 14px;
    gap: 12px;
    z-index: 10;
    border-radius: var(--border-radius);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #444;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== КНОПКА FAB (стрелка вниз) ===== */
.next-btn-fab {
    position: absolute;
    right: 10px;
    bottom: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-bg);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s, opacity 0.2s;
    z-index: 20;
    backdrop-filter: blur(4px);
}

.next-btn-fab:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.next-btn-fab:disabled {
    cursor: not-allowed;
}

/* ===== ПОДПИСЬ К ВИДЕО ===== */
.video-caption {
    width: 100%;
    max-width: var(--video-max-width);
    margin-top: 12px;
    padding: 0 4px 60px 4px;  /* отступ снизу, чтобы FAB не перекрывал */
    font-size: 15px;
    line-height: 1.5;
}

.video-caption #video-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.video-date {
    font-size: 13px;
    color: #888;
    margin-top: 2px;
}

/* ===== ПРАВАЯ ПАНЕЛЬ ===== */
.side-panel {
    flex: 0 0 var(--side-panel-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--accent-bg);
    padding: 20px;
    gap: 24px;
    overflow-y: auto;
}

/* Соцсети в панели — вертикально */
.social-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.social-links a {
    color: #ccc;
    text-decoration: none;
    padding: 10px 14px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    font-size: 15px;
    transition: background 0.2s;
}

.social-links a:hover {
    background: var(--accent-hover);
}

/* Переключатель темы */
.theme-toggle {
    font-size: 13px;
    color: #888;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background 0.2s;
    text-align: center;
}
.theme-toggle:hover {
    background: var(--accent-hover);
    color: #ccc;
}

/* Блок комментариев */
.comments-block {
    flex-grow: 1;
    min-height: 400px;
    overflow-y: auto;
}

/* ===== АДАПТИВ: планшеты ≤ 768px ===== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .video-area {
        height: 60vh;
        padding: 8px;
    }

    .side-panel {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        min-height: 300px;
        flex-direction: column;
    }

    .next-btn-fab {
        right: 8px;
        bottom: 12px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* ===== АДАПТИВ: телефоны ≤ 480px ===== */
@media (max-width: 480px) {
    .app-container {
        flex-direction: column;
    }

    .video-area {
        height: var(--video-max-height-mobile);  /* 60vh по умолчанию */
        padding: 4px;
    }

    .video-wrapper {
        max-width: 100%;
    }

    .video-container {
        border-radius: 0;
    }

    /* Боковая панель — вниз */
    .side-panel {
        width: 100%;
        flex: 0 0 auto;
        height: auto;
        min-height: 280px;
        flex-direction: column;
        padding: 12px;
        gap: 16px;
    }

    /* Соцсети и комментарии — колонка */
    .social-links {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .social-links a {
        flex: 1 1 auto;
        text-align: center;
        font-size: 13px;
        padding: 8px 10px;
    }

    .comments-block {
        min-height: 300px;
    }

    /* FAB не перекрывает субтитры */
    .next-btn-fab {
        right: 6px;
        bottom: 8px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .video-caption {
        padding: 0 4px 50px 4px;
        font-size: 14px;
    }

    .video-caption #video-title {
        font-size: 15px;
    }
}
