/* ── 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;
    --red:          #d32f2f;
    --red-dim:      #fdecea;
    --amber:        #b45309;
    --amber-dim:    #fef3c7;

    --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: 1200px;
    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; }
.admin-badge {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: .1em;
    text-transform: uppercase;
    background: var(--amber-dim);
    color: var(--amber);
    border: 1px solid #fcd34d;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 4px;
}
.header-right { display: flex; align-items: center; gap: 12px; }
.bienvenida   { font-size: 13px; color: var(--text-sub); }
.btn-secundario {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-main);
    font-size: 13px;
    text-decoration: none;
    transition: background .15s;
}
.btn-secundario:hover { background: var(--bg); }
.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;
}
.btn-salir:hover { background: var(--bg); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero { background: linear-gradient(135deg, #1e3a8a 0%, #3B5BDB 100%); color: #fff; padding: 48px 24px 44px; }
.hero-inner     { max-width: 1200px; 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(26px,4vw,38px); font-weight: normal; line-height: 1.15; margin-bottom: 8px; }
.hero-sub       { font-size: 18px; opacity: .8; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main { flex: 1; max-width: 1200px; margin: 0 auto; width: 100%; padding: 36px 24px 60px; }
.admin-layout { display: grid; grid-template-columns: 480px 1fr; gap: 28px; align-items: start; }

/* ── Encabezados de sección ──────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title  { font-family: var(--font-display); font-size: 20px; font-weight: normal; }
.curso-count    { font-size: 12px; font-weight: bold; color: var(--text-sub); background: var(--bg); border: 1px solid var(--border); padding: 3px 10px; border-radius: 20px; }

/* ── Formulario ──────────────────────────────────────────────────────────── */
.form-card { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group--sm { max-width: 160px; }
.form-label { font-size: 13px; font-weight: bold; color: var(--text-main); }
.form-control {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text-main);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,91,219,.12); }
.form-control--sm { width: 100%; }
.form-textarea { resize: vertical; min-height: 100px; }
.desc-counter  { font-size: 11px; color: var(--text-sub); text-align: right; margin-top: -4px; }
.campo-hint    { font-size: 11px; min-height: 14px; color: var(--text-sub); }

/* ── Combo de categoría ──────────────────────────────────────────────────── */
.combo-wrapper { position: relative; }

.combo-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
}

.combo-item {
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: background .1s;
    color: var(--text-main);
}
.combo-item:hover          { background: var(--accent-dim); color: var(--accent); }
.combo-item--new           { color: var(--green); font-weight: bold; border-top: 1px solid var(--border); }
.combo-item--new:hover     { background: var(--green-dim); }

/* Chip de categoría seleccionada */
.cat-seleccionada {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    border: 1px solid #c7d2fb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--accent);
    font-weight: bold;
}
.cat-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
    padding: 0;
    margin-left: auto;
    opacity: .7;
    transition: opacity .15s;
}
.cat-clear:hover { opacity: 1; }

/* ── Mensajes ────────────────────────────────────────────────────────────── */
.error-msg   { font-size: 13px; color: var(--red);   background: var(--red-dim);   border: 1px solid #fca5a5; border-radius: 6px; padding: 10px 14px; display: none; }
.success-msg { font-size: 13px; color: var(--green); background: var(--green-dim); border: 1px solid #6ee7b7; border-radius: 6px; padding: 10px 14px; display: none; }
.error-msg.visible   { display: block; }
.success-msg.visible { display: block; }

/* ── Acciones del formulario ─────────────────────────────────────────────── */
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.btn-limpiar {
    padding: 9px 20px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text-sub);
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.btn-limpiar:hover { background: var(--bg); color: var(--text-main); }
.btn-crear {
    padding: 9px 24px;
    border: none;
    border-radius: 7px;
    background: #9CA3AF;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: not-allowed;
    transition: background .2s;
}
.btn-crear.activo           { background: var(--accent); cursor: pointer; }
.btn-crear.activo:hover     { background: #2d46b0; }

/* ── Lista de cursos ─────────────────────────────────────────────────────── */
.cursos-lista { display: flex; flex-direction: column; gap: 10px; }
.curso-item {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow .15s;
}
.curso-item:hover  { box-shadow: var(--shadow-hover); }
.curso-stripe      { width: 4px; height: 44px; border-radius: 4px; flex-shrink: 0; }
.curso-info        { flex: 1; min-width: 0; }
.curso-titulo      { font-size: 15px; font-weight: bold; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.curso-meta        { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.tag               { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--accent-dim); color: var(--accent); font-weight: bold; }
.tag-nivel         { background: var(--bg); color: var(--text-sub); font-weight: normal; }
.tag-duracion      { background: var(--bg); color: var(--text-sub); font-weight: normal; }

/* ── Botón eliminar ──────────────────────────────────────────────────────── */
.btn-eliminar {
    background: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
}
.btn-eliminar:hover { background: var(--red-dim); border-color: #fca5a5; color: var(--red); }

/* ── Modal de confirmació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 {
    background: var(--surface);
    border-radius: 16px;
    padding: 36px 32px 28px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: modal-in .18s ease;
}

@keyframes modal-in {
    from { transform: scale(.94); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.modal-icon      { font-size: 36px; text-align: center; }
.modal-title     { font-family: var(--font-display); font-size: 20px; text-align: center; color: var(--red); }
.modal-desc      { font-size: 14px; color: var(--text-sub); text-align: center; line-height: 1.6; }
.modal-desc strong { color: var(--text-main); }
.modal-instruccion { font-size: 13px; color: var(--text-sub); text-align: center; line-height: 1.7; }
.modal-instruccion code {
    display: inline-block;
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid #fca5a5;
    border-radius: 5px;
    padding: 2px 10px;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: .05em;
    margin-top: 4px;
}
.modal-input     { margin-top: 4px; }
.modal-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(211,47,47,.12); }

.modal-actions   { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.btn-eliminar-confirm {
    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-eliminar-confirm:not(:disabled) { background: var(--red); cursor: pointer; }
.btn-eliminar-confirm:not(:disabled):hover { background: #b71c1c; }

/* ── Skeleton ────────────────────────────────────────────────────────────── */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton-list  { display: flex; flex-direction: column; gap: 10px; }
.skeleton-item  { height: 76px; border-radius: 10px; background: linear-gradient(90deg,#ececec 25%,#f5f5f5 50%,#ececec 75%); background-size: 800px 100%; animation: shimmer 1.4s infinite; }

/* ── 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: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .form-row     { grid-template-columns: 1fr; }
    .form-group--sm { max-width: 100%; }
    .bienvenida   { display: none; }
    .modal        { padding: 28px 20px 22px; }
}
/* ── Botón de editar contenido del curso (lista de cursos) ───────────────── */
.btn-editar-curso {
    background: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
}
.btn-editar-curso:hover {
    background: var(--accent-dim);
    border-color: #c7d2fb;
    color: var(--accent);
}

/* ── Botón mostrar/ocultar (visibilidad del curso) ───────────────────────── */
.btn-visibilidad {
    background: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
}
.btn-visibilidad:hover {
    background: var(--accent-dim);
    border-color: #c7d2fb;
    color: var(--accent);
}
.btn-visibilidad:disabled { opacity: .5; cursor: default; }
.btn-visibilidad.esta-oculto:hover {
    background: var(--red-dim);
    border-color: #fca5a5;
    color: var(--red);
}

/* ── Curso oculto: se atenúa para distinguirlo del resto ─────────────────── */
.curso-item--oculto { opacity: .62; }
.curso-item--oculto .curso-stripe { filter: grayscale(.6); }

.badge-oculto {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--red-dim, #fde8e8);
    color: var(--red, #c0392b);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: .3px;
    vertical-align: middle;
    text-transform: uppercase;
}
/* ── Botón descargar curso como JSON ── */
.btn-descargar-json {
    background: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
}
.btn-descargar-json:hover {
    background: var(--green-dim);
    border-color: #a7d7c5;
    color: var(--green);
}
