/* === Reset y base === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar {
    background: #1e3a5f;
    color: #fff;
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar a { color: #fff; }
.navbar a:hover { opacity: 0.85; text-decoration: none; }
.navbar-brand { font-size: 1.15rem; font-weight: 600; }
.navbar-info { display: flex; gap: 1.5rem; align-items: center; font-size: 0.9rem; }
.badge-entregable {
    background: #f59e0b;
    color: #000;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* === Breadcrumbs === */
.breadcrumb {
    padding: 0.6rem 1.5rem;
    background: #e9ecef;
    font-size: 0.85rem;
    color: #666;
}
.breadcrumb a { color: #2563eb; }
.breadcrumb span { margin: 0 0.3rem; }

/* === Contenedor principal === */
.container {
    max-width: 960px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

/* === Mensajes flash === */
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* === Tarjetas de menú === */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.2rem;
    margin-top: 1.5rem;
}
.menu-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
    display: block;
    color: #333;
}
.menu-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: #333;
}
.menu-card h2 { font-size: 1.1rem; margin-bottom: 0.5rem; color: #1e3a5f; }
.menu-card p { font-size: 0.85rem; color: #666; }

/* === Formularios === */
.form-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group select {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.95rem;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}
.form-group .help-text { font-size: 0.8rem; color: #888; margin-top: 0.2rem; }

/* === Botones === */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    font-weight: 500;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; color: #fff; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* === Tablas === */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}
th, td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
th {
    background: #f1f5f9;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
tr:nth-child(even) { background: #f8fafc; }
tr:hover { background: #f1f5f9; }

/* === Login === */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}
.login-card {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: #1e3a5f;
}

/* === Informe renderizado === */
.informe-content {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.7;
}
.informe-content h1 { font-size: 1.4rem; margin: 1rem 0 0.5rem; color: #1e3a5f; }
.informe-content h2 { font-size: 1.2rem; margin: 1rem 0 0.5rem; color: #334155; }
.informe-content h3 { font-size: 1.05rem; margin: 0.8rem 0 0.4rem; color: #475569; }
.informe-content ul, .informe-content ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.informe-content p { margin-bottom: 0.7rem; }
.informe-content table { border: 1px solid #e2e8f0; }
.informe-content td, .informe-content th { border: 1px solid #e2e8f0; }

/* === Rúbricas === */
.rubrica-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 0.8rem;
}
.rubrica-item label { font-weight: 600; color: #1e3a5f; }
.rubrica-item .desc { font-size: 0.85rem; color: #666; margin: 0.3rem 0; }
.rubrica-item input[type="number"] { width: 80px; }

.nota-grupo-display {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e3a5f;
    text-align: center;
    padding: 1rem;
    background: #f0f9ff;
    border-radius: 8px;
    border: 2px solid #bae6fd;
    margin: 1rem 0;
}

/* === Detalle expandible === */
.detalle-toggle { cursor: pointer; }
.detalle-content { display: none; padding: 0.8rem; background: #f8fafc; border-radius: 4px; margin-top: 0.5rem; }
.detalle-content.active { display: block; }

/* === Spinner overlay === */
.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.overlay.active { display: flex; }
.spinner-box {
    background: #fff;
    padding: 2rem 3rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.spinner {
    border: 4px solid #e2e8f0;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    width: 40px; height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* === Resumen estadísticas === */
.stats {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

/* === Pantalla de progreso === */
.progress-container { max-width: 700px; margin: 0 auto; }
.progress-container h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.3rem; }

.progress-bar-wrapper {
    background: #e2e8f0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}
.progress-bar {
    height: 100%;
    background: #2563eb;
    border-radius: 10px;
    transition: width 0.5s ease, background 0.3s;
}
.progress-percent {
    text-align: right;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 1.2rem;
}

.progress-current {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.2rem;
    font-weight: 500;
    color: #1e3a5f;
}
.progress-current .spinner { margin: 0; width: 24px; height: 24px; border-width: 3px; flex-shrink: 0; }

.progress-log {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.2rem;
    line-height: 1.8;
}
.log-entry { border-bottom: 1px solid #334155; padding: 0.2rem 0; }
.log-entry:last-child { border-bottom: none; }
.log-time { color: #64748b; margin-right: 0.5rem; }
.log-paso { color: #93c5fd; }
.log-detalle { color: #94a3b8; }
.log-error { color: #fca5a5; }
.log-success { color: #86efac; }

.progress-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}
.progress-error h3 { color: #991b1b; margin-bottom: 0.5rem; }
.progress-error p { color: #7f1d1d; margin-bottom: 1rem; }

.progress-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}
.progress-success h3 { color: #065f46; margin-bottom: 0.5rem; }
.progress-success p { color: #047857; }

/* === Administración === */
.admin-action { margin-bottom: 1rem; }
.admin-action h2 { font-size: 1rem; margin-bottom: 0.3rem; }
.admin-action p { font-size: 0.85rem; color: #666; margin-bottom: 0.8rem; }
.admin-confirm {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.admin-confirm input[type="text"] {
    padding: 0.4rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 200px;
}

/* === Editor de prompts === */
.prompt-editor {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    background: #1e293b;
    color: #e2e8f0;
}
.prompt-editor:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

/* === Confirmación sobrescribir === */
.confirm-box {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* === Selector de vista === */
.view-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
}
.view-tab {
    padding: 0.6rem 1.5rem;
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
    font-weight: 500;
    font-size: 0.9rem;
}
.view-tab:first-child { border-radius: 6px 0 0 6px; }
.view-tab:last-child { border-radius: 0 6px 6px 0; }
.view-tab:hover { background: #cbd5e1; text-decoration: none; }
.view-tab.active {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}

/* === Responsive === */
@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    .navbar { flex-direction: column; gap: 0.5rem; text-align: center; }
    .menu-grid { grid-template-columns: 1fr; }
    table { font-size: 0.8rem; }
    th, td { padding: 0.4rem 0.5rem; }
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }
}
