/* ============================================
   RESET Y BASE
   ============================================ */
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f4f5f7;
    color: #1c1d1f;
    line-height: 1.5;
}
a { color: #5624d0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   LAYOUT GENERAL
   ============================================ */
.container {
    max-width: 480px;
    margin: 3rem auto;
    padding: 2rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.container-wide {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
h1, h2, h3 { color: #1c1d1f; }
h1 { font-size: 1.75rem; margin-top: 0; }

/* ============================================
   FORMULARIOS
   ============================================ */
form label { display: block; margin-bottom: 1rem; font-weight: 600; }
form input[type="text"],
form input[type="email"],
form input[type="password"],
form textarea,
form select {
    width: 100%;
    padding: .65rem .8rem;
    font-size: 1rem;
    border: 1px solid #d1d7dc;
    border-radius: 4px;
    font-family: inherit;
    margin-top: .25rem;
}
form input:focus,
form textarea:focus,
form select:focus {
    outline: none;
    border-color: #5624d0;
    box-shadow: 0 0 0 2px rgba(86,36,208,.15);
}
button, .btn {
    display: inline-block;
    background: #5624d0;
    color: #fff;
    border: none;
    padding: .7rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .btn:hover { background: #401b9c; text-decoration: none; }
button.danger { background: #d32f2f; }
button.danger:hover { background: #b71c1c; }

/* ============================================
   MENSAJES
   ============================================ */
.error-list {
    background: #fdecea;
    border-left: 4px solid #d32f2f;
    padding: .75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    list-style: none;
}
.error-list li { color: #b71c1c; }
.msg-error { color: #d32f2f; }
.msg-ok    { color: #2e7d32; }

/* ============================================
   DASHBOARD
   ============================================ */
.curso-card {
    border: 1px solid #d1d7dc;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow .15s;
}
.curso-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.curso-card h3 { margin: 0 0 .25rem; }
.curso-card .meta { color: #6a6f73; font-size: .9rem; }
.progress-bar {
    background: #e9ecef;
    border-radius: 4px;
    height: 8px;
    margin: .75rem 0 .4rem;
    overflow: hidden;
}
.progress-bar > span {
    display: block;
    background: #5624d0;
    height: 100%;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    background: #1c1d1f;
    color: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar a { color: #fff; margin-left: 1rem; }
.topbar strong { font-size: 1.1rem; }

/* ============================================
   TABLAS ADMIN
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
table th, table td {
    padding: .65rem .8rem;
    text-align: left;
    border-bottom: 1px solid #d1d7dc;
}
table th { background: #f7f9fa; font-weight: 600; }
table tr:hover td { background: #fafbfc; }

/* ============================================
   SECCIONES ADMIN
   ============================================ */
.seccion {
    border: 1px solid #d1d7dc;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}
.seccion h3 { margin-top: 0; }
.leccion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px dashed #e9ecef;
}
.leccion-item:last-child { border-bottom: none; }

/* ============================================
   DISEÑO RESPONSIVO (CELULARES Y TABLETS)
   ============================================ */
@media (max-width: 768px) {
    /* Ajustar contenedores principales */
    .container, .container-wide {
        padding: 1rem;
        margin: 1rem auto;
        width: 95%;
    }

    /* Hacer que las tablas se puedan deslizar horizontalmente */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Ajustar formularios */
    form input, form select, form textarea, button, .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Ajustar títulos */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }

    /* Ajustar botones de acción en admin */
    .leccion-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .leccion-item div {
        display: flex;
        flex-wrap: wrap;
    }
}