/* style.css */

:root {
    /* Tema Claro (por defecto) */
    --bg-body: #f4f6f9;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc; /* Fondos de contenedores secundarios */
    --bg-hover: #f0f2f5;
    --text-main: #1f2933;
    --text-muted: #7b8794;
    --border-color: #e4e7eb;
    --input-bg: #ffffff;
    
    /* Variables para SweetAlert2 */
    --swal-bg: #ffffff;
    --swal-text: #1f2933;

    /* Colores de Marca / Estados */
    --active-bg: #e8eef9;
    --active-text: #1a4f9c;
    --brand-bg: #1f2933;
    --brand-text: #ffffff;
}

[data-theme="dark"] {
    /* Tema Oscuro (Gris neutro, sin azul) */
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-subtle: #252525;
    --bg-hover: #2e2e2e; /* Hover sutil */
    --text-main: #e0e0e0; /* Blanco roto, no brilla */
    --text-muted: #a0a0a0;
    --border-color: #333333;
    --input-bg: #121212;
    
    /* Variables para SweetAlert2 */
    --swal-bg: #1e1e1e;
    --swal-text: #e0e0e0;

    /* Colores de Marca / Estados adaptados */
    --active-bg: #2e2e2e;
    --active-text: #e0e0e0;
    --brand-bg: #333333;
    --brand-text: #ffffff;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.5;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.muted { color: var(--text-muted); font-size: 0.9rem; }

/* ============================================
   Marca
   ============================================ */
.brand-mark {
    background: var(--brand-bg);
    color: var(--brand-text);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}
.brand-mark-lg { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; }

/* ============================================
   Login (auth pages)
   ============================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
}
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.subtitle { color: var(--text-muted); margin-bottom: 28px; }

.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}
.google-btn:hover { background: var(--bg-hover); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* ============================================
   App shell (layout con sidebar)
   ============================================ */
.app-body { min-height: 100vh; }

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
    height: 100vh; 
    height: 100dvh; 
    overflow: hidden; 
    transition: grid-template-columns 0.2s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: 0 1fr; }

/* --- Topbar --- */
.topbar {
    grid-area: topbar;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg-hover); }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
}

/* --- Menú de perfil --- */
.profile-menu { position: relative; }

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    color: inherit;
    font-size: 14px;
}
.profile-trigger:hover { background: var(--bg-hover); }

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.profile-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #3e4c59;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}
.profile-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chevron { transition: transform 0.15s ease; }
.profile-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 8px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 60;
}
.profile-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.profile-header {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.profile-header strong { font-size: 14px; }
.profile-header small  { color: var(--text-muted); font-size: 12px; }
.profile-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 6px 0;
}
.dropdown-item {
    display: block;
    padding: 9px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 14px;
    transition: background 0.12s ease;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item-danger { color: #ef4444; }
.dropdown-item-danger:hover { background: rgba(239, 68, 68, 0.1); }

/* --- Sidebar --- */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 20px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: padding 0.2s ease;
    height: 100%;
}
.app-shell.sidebar-collapsed .sidebar {
    padding: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 8px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 14px;
    transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--active-bg); color: var(--active-text); font-weight: 500; }
.nav-item.active svg { stroke: var(--active-text); }

.nav-item.disabled { opacity: 0.55; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }

.badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--border-color);
    color: var(--text-main);
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 500;
}

.sidebar-backdrop { display: none; }

/* --- Main content --- */
.main {
    grid-area: main;
    padding: 32px;
    overflow-y: auto;
    width: 100%;
    height: 100%; 
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Títulos y subtítulos perfectamente centrados */
.page-header {
    width: 100%;
    max-width: 1100px; 
    display: flex;
    flex-direction: column;
    align-items: center; 
    text-align: center;
    margin: 0 auto 32px auto;
    gap: 8px; 
}

.page-header h1 { 
    font-size: 1.8rem; 
    color: var(--text-main); 
    margin: 0;
}

.page-header .muted {
    margin: 0;
    font-size: 1rem;
}

/* Tarjeta principal unificada */
.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 1100px;
    margin: 0 auto; 
    box-sizing: border-box;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.module-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Lista de tareas */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-item {
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--bg-subtle); /* Usa fondo sutil */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 900px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    
    .app-shell .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        width: 260px;
        padding: 20px 12px;
        border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 40;
        box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }

    .sidebar-backdrop {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5); /* Un poco más oscuro */
        z-index: 35;
    }
    .app-shell.sidebar-open .sidebar-backdrop { display: block; }

    .profile-name { display: none; }
    
    .main { 
        padding: 16px; 
    }
    
    .module-card {
        padding: 20px; 
    }
}

/* ============================================
   Formularios y botones
   ============================================ */
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
.input-row { display: flex; gap: 10px; }
.input-row .form-control { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.05s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary  { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover:not(:disabled)   { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: var(--bg-hover); color: var(--text-main); border-color: var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--border-color); }
.btn-success  { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; border-color: #15803d; }

.mt-3 { margin-top: 12px; }

/* ============================================
   Preview multimedia + formatos
   ============================================ */
.media-preview {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.media-thumb {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--border-color);
    flex-shrink: 0;
}
.media-meta h3 { font-size: 15px; margin-bottom: 4px; line-height: 1.3; }
.format-grid { display: flex; flex-wrap: wrap; gap: 10px; }

/* ============================================
   Barra de progreso
   ============================================ */
.progress-wrap { margin-top: 14px; }
.progress-bar {
    height: 12px;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    border-radius: 999px;
    transition: width 0.3s ease;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.progress-info #progressPercent { font-weight: 600; color: var(--text-main); }