/* SofíaTube - Estilos modernos y amigables para niños */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@400;600;800&display=swap');

:root {
    --primary: #ff4d6d;
    --primary-hover: #ff2a51;
    --secondary: #4ea8de;
    --accent: #ffd166;
    --bg: #f8faff;
    --card-bg: #ffffff;
    --text-dark: #2b2d42;
    --text-muted: #6c757d;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 16px 32px rgba(255, 77, 109, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, #ff5e7e, #ff3366);
    color: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.25);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-volver {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.btn-volver:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateX(-3px);
}

.logo {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-box {
    flex: 1;
    max-width: 360px;
    position: relative;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 18px;
    padding-left: 40px;
    border-radius: 30px;
    border: none;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    background: white;
    color: var(--text-dark);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    transform: scale(1.02);
    box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #999;
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-fuente {
    background: rgba(255, 255, 255, 0.2);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-icon {
    background: white;
    color: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s, background-color 0.2s;
}

.btn-icon:hover {
    transform: rotate(15deg) scale(1.08);
    background: #fff0f3;
}

/* Banner de Estado / Notificación */
.status-bar {
    background: #eef4ff;
    color: #3b5998;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #dbe6fb;
}

/* Contenedor Principal de Videos */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    justify-content: center;
}

/* Tarjeta de Video */
.video-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
    border-color: #ffd6e0;
}

.thumbnail-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #e9ecef;
    overflow: hidden;
}

.thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover .thumbnail-img {
    transform: scale(1.05);
}

.play-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.play-badge span {
    background: var(--primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    padding-left: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.video-card:hover .play-badge {
    opacity: 1;
}

.video-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-info {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.video-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.35;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-tag {
    font-size: 12px;
    color: var(--secondary);
    font-weight: 600;
    background: #e3f2fd;
    padding: 2px 10px;
    border-radius: 12px;
    align-self: flex-start;
}

/* Estado de Carga y Vacío */
.loading-state, .empty-state {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
}

.loading-spinner {
    font-size: 42px;
    animation: spin 1s infinite linear;
    display: inline-block;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state h3 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 16px;
}

/* Reproductor Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.activo {
    display: flex;
    opacity: 1;
}

.modal-player-container {
    width: 100%;
    max-width: 960px;
    background: #111;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: #1e1e24;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.btn-close-modal {
    background: #ff4d6d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-close-modal:hover {
    background: #e63956;
}

.player-frame-box {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: black;
}

.player-frame-box iframe,
.player-frame-box video {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Modal de Ajustes / Configuración de Fuentes */
.settings-modal {
    background: white;
    max-width: 520px;
    width: 90%;
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.settings-modal h2 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-modal p.desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    color: #333;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input:focus {
    border-color: var(--secondary);
}

.help-text {
    font-size: 12px;
    color: #777;
    margin-top: 4px;
    line-height: 1.3;
}

.settings-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.btn-secondary {
    background: #e9ecef;
    border: none;
    padding: 10px 18px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 22px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Responsividad */
@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }
    .logo {
        font-size: 22px;
    }
    .search-box {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 8px;
    }
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 16px;
    }
}
