/* --- VARIABLES & RESET (Estilo iOS 17) --- */
:root {
    --primary: #007AFF; 
    --primary-hover: #0055D4;
    --primary-light: #EBF3FF;
    --success: #34C759;
    --danger: #FF3B30;
    --bg-body: #F5F5F7; /* Gris sistema */
    --surface: #FFFFFF;
    --text-main: #1D1D1F;
    --text-sec: #86868B;
    --border: #E5E5EA;
    --radius: 14px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; outline: none; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh; /* Altura fija */
    overflow: hidden; /* Evita scroll global */
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.4s ease-out; }

/* --- BOTONES PREMIUM (APPLE STYLE) --- */
/* Botón Principal (Azul) */
.btn-apple {
    background: var(--primary); 
    color: white; 
    border: none;
    padding: 14px 20px; 
    border-radius: 12px; 
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer; 
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
    width: 100%;
    display: flex; justify-content: center; align-items: center; gap: 8px;
}
.btn-apple:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-apple:active { transform: scale(0.96); box-shadow: none; }

/* Botón Secundario / Opciones (Gris/Blanco) */
.option-btn {
    width: 100%;
    padding: 16px; 
    background: var(--surface); 
    border: 1px solid transparent;
    border-radius: 12px; 
    font-size: 1rem; 
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer; 
    text-align: left;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: space-between;
}
.option-btn:hover { 
    background: var(--primary-light); 
    color: var(--primary);
    transform: scale(1.01);
}
.option-btn:active { transform: scale(0.98); }

/* Botón Peligro (Logout) */
.btn-danger-soft {
    background: rgba(255, 59, 48, 0.08); 
    color: var(--danger);
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    width: 100%;
    text-align: center;
}
.btn-danger-soft:hover { background: rgba(255, 59, 48, 0.15); }
.btn-danger-soft:active { transform: scale(0.95); }

/* Botón Link (Texto) */
.btn-link {
    background: none; border: none; color: var(--text-sec);
    cursor: pointer; margin-top: 15px; font-size: 0.9rem;
}
.btn-link.highlight { color: var(--primary); font-weight: 600; margin-left: 5px; }

/* Botón Play (Temas) */
.topic-action-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: 0.2s;
}
.topic-action-btn:hover { background: var(--primary); color: white; transform: scale(1.1); border-color: var(--primary); }

/* --- LOGIN & ONBOARDING --- */
.auth-container, .onboarding-container {
    height: 100vh; width: 100vw;
    display: flex; justify-content: center; align-items: center;
    background: radial-gradient(circle at 50% 0%, #ffffff 0%, #eef1f5 100%);
    padding: 20px;
}
.auth-card, .onboarding-card {
    background: rgba(255,255,255,0.85); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    padding: 40px; border-radius: 24px; width: 100%; max-width: 420px;
    box-shadow: var(--shadow-md); text-align: center; border: 1px solid rgba(255,255,255,0.5);
}
.brand-logo { 
    font-size: 2.2rem; font-weight: 800; letter-spacing: -1px; 
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}
.apple-input {
    width: 100%; padding: 16px; background: #F2F2F7; border: 1px solid transparent;
    border-radius: 12px; margin-bottom: 16px; font-size: 1rem; color: var(--text-main);
    transition: 0.2s;
}
.apple-input:focus { background: white; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0,122,255,0.1); }

/* --- APP LAYOUT (FIXED NO SCROLL) --- */
.app-layout { 
    display: flex; 
    height: 100vh; /* Ocupa toda la pantalla */
    width: 100vw;
    overflow: hidden; /* Nada sale fuera */
}

/* Sidebar Fija */
.sidebar {
    width: 280px; 
    background: rgba(255,255,255,0.95); 
    backdrop-filter: blur(20px);
    padding: 30px 20px;
    display: flex; flex-direction: column; /* Columna Flex */
    border-right: 1px solid var(--border);
    flex-shrink: 0; /* No encoger */
    justify-content: space-between; /* Espacia contenido arriba y abajo */
}
.logo { font-size: 1.5rem; font-weight: 800; margin-bottom: 30px; padding-left: 10px; color: var(--text-main); }
.nav-links { list-style: none; flex-grow: 1; /* Ocupa el espacio central */ overflow-y: auto; }
.nav-item {
    padding: 14px; margin-bottom: 5px; border-radius: 12px;
    cursor: pointer; color: var(--text-sec); display: flex; gap: 12px; align-items: center;
    transition: 0.2s; font-weight: 500;
}
.nav-item:hover { background: #F2F2F7; color: var(--text-main); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }

/* Perfil y Logout al fondo */
.user-profile-mini {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.avatar { 
    width: 40px; height: 40px; background: var(--primary); color: white; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .name { font-size: 0.9rem; font-weight: 600; display: block; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main Content (Scroll Interno) */
.main-content { 
    flex: 1; 
    padding: 40px; 
    overflow-y: auto; /* Solo scrollea esto */
    height: 100vh;
    background: var(--bg-body);
}

/* --- DASHBOARD COMPONENTS --- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 25px; margin-top: 20px; }
.card { background: white; padding: 25px; border-radius: 20px; box-shadow: var(--shadow-sm); border: 1px solid white; }

/* Lista de Temas */
.topics-container { display: flex; flex-direction: column; gap: 12px; padding-bottom: 50px; }
.topic-row {
    display: flex; align-items: center; gap: 15px; padding: 15px 20px;
    background: white; border-radius: 16px; box-shadow: var(--shadow-sm);
    transition: 0.2s; border: 1px solid transparent;
}
.topic-row:hover { transform: translateY(-2px); border-color: var(--primary-light); }
.topic-status-dot { width: 10px; height: 10px; border-radius: 50%; background: #E5E5EA; flex-shrink: 0; }
.topic-status-dot.green { background: var(--success); box-shadow: 0 0 8px rgba(52, 199, 89, 0.4); }
.topic-status-dot.red { background: var(--danger); }
.topic-row input { 
    border: none; font-size: 1rem; width: 100%; background: transparent; 
    font-weight: 500; color: var(--text-main);
}

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-card { 
    background: white; width: 90%; max-width: 360px; padding: 30px; 
    border-radius: 24px; text-align: center; box-shadow: var(--shadow-md);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-review {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px; border: none; border-radius: 14px; font-weight: 600; cursor: pointer;
    font-size: 1rem; margin-bottom: 10px; width: 100%; transition: 0.2s;
}
.btn-review:hover { transform: scale(1.02); }
.btn-review.hard { background: #FFF0F0; color: #FF3B30; }
.btn-review.good { background: #F0F9FF; color: #007AFF; }
.btn-review.easy { background: #F0FFF4; color: #34C759; }

@keyframes popIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* MÓVIL */
.bottom-nav { display: none; }
@media (max-width: 1024px) {
    .app-layout { flex-direction: column; }
    .sidebar { display: none; }
    .bottom-nav { 
        display: flex; position: fixed; bottom: 0; width: 100%; background: rgba(255,255,255,0.9); 
        backdrop-filter: blur(20px); justify-content: space-around; padding: 12px 0; 
        border-top: 1px solid var(--border); z-index: 90; padding-bottom: env(safe-area-inset-bottom);
    }
    .main-content { padding: 20px 20px 100px 20px; height: auto; overflow-y: visible; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .nav-item { flex-direction: column; font-size: 0.7rem; gap: 4px; padding: 5px; }
}
