/* ============================================================
   LMS PAULO FREIRE — UI KIT COMPARTIDO

   Por qué existe: `.btn-modern`, `.content-card`, `.form-input` y los
   `.modal-*` estaban definidos a mano en ~20 plantillas y usados en 49.
   Las 49 que no los definían renderizaban botones sin estilo (un enlace
   de texto donde debía haber un botón primario) — el caso más visible
   era la Imprenta editorial.

   Contrato de carga: este archivo entra en `lms/base.html` ANTES de
   `{% block extra_css %}`. Por eso una plantilla que ya define su propia
   versión de una clase sigue ganando (misma especificidad, orden
   posterior) y su apariencia NO cambia. El kit solo pinta lo que hoy
   está sin pintar.

   Deliberadamente FUERA del kit:
     - `.toggle-switch`: conviven dos APIs incompatibles (div+.active por
       JS, y label+checkbox+.toggle-slider). Una definición global le
       metería fondo gris y una perilla fantasma a la segunda familia.
     - `--shadow-xl`: `base.html` lo define con tinte azul-gris y cada
       plantilla lo pisa con negro. Redeclararlo aquí cambiaría sombras
       en páginas que hoy se ven bien; se usan valores literales.

   Depende de Tailwind (cargado en base.html) para el layout: el kit solo
   aporta el "chrome" del componente, no el espaciado ni la tipografía.
   ============================================================ */

:root {
    /* Cada página puede pisar estos gradientes en su propio :root.
       leccion_detail usa el verde de marca; config y planificación, índigo. */
    --primary-gradient: linear-gradient(135deg, #2d6a4f 0%, #1e4d7b 100%);
    --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --ai-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #7c3aed 100%);
    --primary-glow: 79, 70, 229;
}

/* ---------------- Botones ---------------- */
.btn-modern {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    max-width: 100%;
    border: none;
    cursor: pointer;
}

@media (max-width: 768px) {
    .btn-modern { padding: 10px 16px; font-size: 13px; }
}

.btn-modern:disabled,
.btn-modern.is-loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-glow), 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(var(--primary-glow), 0.4);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4f46e5;
    border: 1px solid rgba(79, 70, 229, 0.2);
}
.btn-secondary:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: #4f46e5;
}

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
    color: white;
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
    color: white;
}

/* Destructiva secundaria: el rojo saturado dentro de un modal chilla. */
.btn-danger-soft {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    box-shadow: none;
}
.btn-danger-soft:hover { background: #fecaca; color: #b91c1c; }

.btn-warning {
    background: var(--warning-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
    color: white;
}

.btn-ghost {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #0f172a;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }

/* ---------------- Tarjetas ---------------- */
.content-card {
    background: white;
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
}
.content-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--secondary-gradient);
}
.content-card--hoverable:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.content-card--flat {
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: none;
}
.content-card--flat::before { display: none; }

.content-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* KPI de dashboard. La barra superior solo aparece con modificador,
   así que una página que hoy usa .stat-card pelada no cambia. */
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
}
.stat-card.primary::before { background: var(--ai-gradient); }
.stat-card.danger::before { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.success::before { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.warning::before { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.info::before { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ---------------- Formularios ---------------- */
.form-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #475569;
    margin-bottom: 6px;
}

.form-help { font-size: 12px; color: #6b7280; margin-top: 6px; }

.form-input,
.form-textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}
.form-input::placeholder,
.form-textarea::placeholder { color: #94a3b8; }

.form-textarea { border-radius: 12px; min-height: 120px; resize: vertical; }

/* `.form-select` es un add-on: se usa como class="form-input form-select". */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* ---------------- Modales ---------------- */
/* Mecánica display:none / .active{display:flex}. No cambiar a
   opacity/visibility: los modales de leccion_detail quedarían
   invisibles pero capturando clics. */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex !important; }

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}
.modal-content--sm { max-width: 500px; }

.modal-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0f2fe 100%);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}
.modal-header--plain {
    background: none;
    border-bottom-color: #f1f5f9;
    align-items: flex-start;
}

.modal-body { padding: 20px; overflow-y: auto; flex: 1; max-height: 65vh; }

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}
.modal-close:hover { color: #0f172a; }

.modal-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}
.modal-section:last-child { margin-bottom: 0; }

.modal-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-section-title i { color: #6366f1; }

.modal-field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 768px) {
    .modal-field-grid { grid-template-columns: 1fr; }
}

.modal-field { margin-bottom: 0; }

.modal-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
}
.modal-field-label.required::after { content: '*'; color: #ef4444; margin-left: 4px; }
