/* ── Reset y base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #F7F8FA;
    --surface:     #FFFFFF;
    --border:      #E4E7ED;
    --text-main:   #1A1D23;
    --text-sub:    #6B7280;
    --accent:      #3B5BDB;
    --accent-dim:  #EEF2FF;
    --green:       #1A7F5A;
    --green-dim:   #E6F4EF;
    --locked:      #9CA3AF;
    --locked-dim:  #F3F4F6;

    --radius-card: 14px;
    --shadow-card: 0 2px 8px rgba(0,0,0,.07), 0 0 0 1px var(--border);
    --shadow-hover: 0 8px 24px rgba(59,91,219,.12), 0 0 0 1px #c7d2fb;

    --font-display: 'Georgia', serif;
    --font-body:    'Arial', sans-serif;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: bold;
    color: var(--accent);
    text-decoration: none;
}

.logo-icon { font-size: 22px; }

.logo-img {
    height: 38px;
    width: auto;
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bienvenida {
    font-size: 13px;
    color: var(--text-sub);
}

.btn-salir {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.btn-salir:hover {
    background: var(--bg);
    border-color: var(--locked);
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #3B5BDB 0%, #5E81F4 100%);
    color: #fff;
    padding: 52px 24px 48px;
}

.hero-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.hero-eyebrow {
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: .75;
    margin-bottom: 10px;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 4vw, 42px);
    font-weight: normal;
    line-height: 1.15;
    margin-bottom: 10px;
}

.hero-sub {
    font-size: 20px;
    opacity: .8;
}

/* ── Filtros ─────────────────────────────────────────────────────────────── */
.filtros-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.filtros-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 4px;
    height: 48px;
    align-items: center;
}

.filtro {
    padding: 5px 16px;
    border: 1px solid transparent;
    border-radius: 20px;
    background: none;
    font-size: 13px;
    color: var(--text-sub);
    cursor: pointer;
    transition: all .15s;
}

.filtro:hover   { background: var(--bg); color: var(--text-main); }
.filtro.activo  { background: var(--accent-dim); color: var(--accent); border-color: #c7d2fb; font-weight: bold; }

/* ── Main / grid ─────────────────────────────────────────────────────────── */
.main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    padding: 36px 24px 60px;
}

.cursos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
}

/* ── Tarjeta ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}

/* Franja superior de color por nivel */
.card-stripe {
    height: 5px;
    width: 100%;
}

.card-body {
    padding: 22px 22px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-categoria {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-nivel {
    font-size: 11px;
    color: var(--text-sub);
}

.card-titulo {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: normal;
    line-height: 1.3;
    color: var(--text-main);
}

.card-desc {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.6;
    flex: 1;
}

.card-footer {
    padding: 14px 22px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.card-duracion {
    font-size: 12px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-duracion::before {
    content: "⏱";
    font-size: 13px;
}

/* ── Estado: habilitado ──────────────────────────────────────────────────── */
.card.habilitado {
    cursor: pointer;
}

.card.habilitado:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.card.habilitado .card-stripe { background: var(--green); }

.btn-ingresar {
    padding: 7px 18px;
    border: none;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s;
}

.btn-ingresar:hover { background: #155f44; }

/* ── Estado: bloqueado ───────────────────────────────────────────────────── */
.card.bloqueado {
    opacity: .72;
    cursor: not-allowed;
}

.card.bloqueado .card-stripe { background: var(--locked); }

.badge-bloqueado {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--locked);
    font-weight: bold;
}

.badge-bloqueado::before { content: "🔒"; font-size: 13px; }

/* ── Skeleton loader ─────────────────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.card.skeleton {
    height: 240px;
    background: linear-gradient(90deg, #ececec 25%, #f5f5f5 50%, #ececec 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite;
    cursor: default;
    box-shadow: var(--shadow-card);
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-msg {
    text-align: center;
    color: var(--text-sub);
    font-size: 15px;
    margin-top: 60px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--text-sub);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .header-inner { padding: 10px 16px; height: auto; flex-wrap: wrap; gap: 10px; }
    .header-right { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
    .filtros-inner { padding: 0 16px; height: auto; flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
    .hero-sub { font-size: 16px; }
}

@media (max-width: 520px) {
    .cursos-grid { grid-template-columns: 1fr; }
    .hero { padding: 36px 18px 32px; }
    .main { padding: 24px 16px 40px; }
    .bienvenida { display: none; }
    .btn-salir, .btn-admin { font-size: 12px; padding: 6px 10px; }
    .filtro { font-size: 12px; padding: 5px 12px; }
}

/* ── Acciones en el footer de la tarjeta ────────────────────────────────── */
.card-acciones {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Botón Matricular ────────────────────────────────────────────────────── */
.btn-matricular {
    padding: 7px 18px;
    border: 2px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.btn-matricular:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Badge terminado ─────────────────────────────────────────────────────── */
.badge-terminado {
    font-size: 12px;
    font-weight: bold;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 5px 12px;
    border-radius: 6px;
}

/* ── Botón administrar (solo visible para admins) ────────────────────────── */
.btn-admin {
    display: none;          /* JS lo muestra si esAdmin=true */
    padding: 6px 14px;
    border: 1px solid #c7d2fb;
    border-radius: 6px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.btn-admin:hover {
    background: #dde4ff;
    border-color: var(--accent);
}
/* ═══════════════════════════════════════════════════════════════════════════
   Barra de progreso en tarjetas, cancelar matrícula y modal de confirmación
   ═══════════════════════════════════════════════════════════════════════════ */

/* Permitir que el footer envuelva cuando hay varios botones */
.card-footer  { flex-wrap: wrap; gap: 10px; }
.card-acciones { flex-wrap: wrap; }

/* ── Barra de progreso en la tarjeta (cursos matriculados/terminados) ────── */
.card-progreso { margin-top: 14px; }
.card-progreso-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}
.card-progreso-label { font-size: 12px; font-weight: bold; color: var(--text-sub); }
.card-progreso-pct   { font-size: 12px; font-weight: bold; color: var(--green); }
.card-barra {
    height: 7px;
    background: #EDEFF3;
    border-radius: 6px;
    overflow: hidden;
}
.card-barra-fill {
    height: 100%;
    background: var(--green);
    border-radius: 6px;
    transition: width .4s ease;
}

/* ── Botón cancelar matrícula (acción discreta de peligro) ───────────────── */
.btn-cancelar-matricula {
    padding: 7px 14px;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    background: transparent;
    color: #d32f2f;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s;
}
.btn-cancelar-matricula:hover { background: #fdecea; }

/* ── Modal de cancelación ────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.visible { display: flex; }
.modal-cancelar {
    background: var(--surface, #fff);
    border-radius: 16px;
    padding: 28px 28px 24px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    animation: modal-in .18s ease;
}
@keyframes modal-in { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 36px; text-align: center; }
.modal-cancelar-titulo {
    font-family: var(--font-display, 'Georgia', serif);
    font-size: 22px;
    font-weight: normal;
    text-align: center;
    color: #d32f2f;
    margin: 2px 0 10px;
}
.modal-cancelar-desc {
    font-size: 14px;
    color: var(--text-sub);
    text-align: center;
    line-height: 1.6;
    margin-bottom: 10px;
}
.modal-cancelar-desc strong { color: var(--text-main); }
.modal-cancelar-instr {
    font-size: 13px;
    color: var(--text-sub);
    text-align: center;
    line-height: 1.7;
    margin-bottom: 6px;
}
.modal-cancelar-instr code {
    display: inline-block;
    background: #fdecea;
    color: #d32f2f;
    border: 1px solid #fca5a5;
    border-radius: 5px;
    padding: 2px 10px;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: .05em;
    margin-top: 4px;
}
.modal-cancelar-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    margin: 10px 0 4px;
    transition: border-color .15s, box-shadow .15s;
}
.modal-cancelar-input:focus { outline: none; border-color: #d32f2f; box-shadow: 0 0 0 3px rgba(211,47,47,.12); }
.modal-cancelar-hint { font-size: 12px; min-height: 16px; margin-bottom: 6px; }
.modal-cancelar-acciones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-modal-sec {
    padding: 9px 20px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface, #fff);
    color: var(--text-sub);
    font-size: 14px;
    cursor: pointer;
}
.btn-modal-sec:hover { background: var(--bg, #f7f8fa); color: var(--text-main); }
.btn-modal-peligro {
    padding: 9px 20px;
    border: none;
    border-radius: 7px;
    background: #9CA3AF;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: not-allowed;
    transition: background .2s;
}
.btn-modal-peligro:not(:disabled) { background: #d32f2f; cursor: pointer; }
.btn-modal-peligro:not(:disabled):hover { background: #b71c1c; }

@media (prefers-reduced-motion: reduce) {
    .card-barra-fill, .modal-cancelar { transition: none; animation: none; }
}

/* ── Botones de certificado en tarjetas (cursos terminados/pagados) ───────── */
.btn-pagar-cert {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s;
}
.btn-pagar-cert:hover { background: #2f49b8; }

.btn-descargar-cert {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s;
}
.btn-descargar-cert:hover { background: #156647; }

/* ── Barra de búsqueda (nombre + categoría) ──────────────────────────────── */
.busqueda-bar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.busqueda-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.busqueda-campo {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
}

.busqueda-icono {
    position: absolute;
    left: 12px;
    font-size: 14px;
    opacity: 0.5;
    pointer-events: none;
}

.busqueda-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--surface);
    transition: border-color .15s;
}

.busqueda-input:focus {
    outline: none;
    border-color: var(--accent);
}

.busqueda-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--surface);
    cursor: pointer;
    min-width: 190px;
    transition: border-color .15s;
}

.busqueda-select:focus {
    outline: none;
    border-color: var(--accent);
}

@media (max-width: 560px) {
    .busqueda-inner { flex-direction: column; align-items: stretch; }
    .busqueda-select { width: 100%; }
}

/* Enlace a términos y condiciones en el footer */
.link-terminos {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color .15s;
}
.link-terminos:hover { color: var(--accent); }

/* Botón de aporte voluntario en la barra superior */
.btn-aporte {
    padding: 6px 14px;
    border: 1px solid #ddd6fe;
    border-radius: 6px;
    background: #f3effe;
    color: #6d28d9;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn-aporte:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
}
@media (max-width: 640px) {
    .btn-aporte { font-size: 0; padding: 6px 10px; }
    .btn-aporte::before { content: "💜"; font-size: 15px; }
}

/* ── Botón "Mi cuenta" (configuración) ── */
.btn-cuenta {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-cuenta:hover { background: var(--accent-dim); border-color: #c7d2fb; color: var(--accent); }
@media (max-width: 640px) { .btn-cuenta { font-size: 12px; padding: 6px 10px; } }
