/* ============================
   ALINEACIÓN CON RENOVA2
   Variables y Configuración Base
   ============================ */
:root {
    /* Paleta de colores moderna alineada con RENOVA2 */
    --primary-color: #6366F1;
    --primary-dark: #4F46E5;
    --secondary-color: #8B5CF6;
    --accent: #EC4899;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --info-color: #3B82F6;
    --light-bg: #F9FAFB;
    --white: #ffffff;
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Reset y base con tipografía moderna */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header moderno con gradiente */
.header {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* Logo en el header */
.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
}

.header-titles {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Logo en login */
.login-logo {
    height: 60px;
    width: auto;
    margin: 0 auto 1rem auto;
    display: block;
    transition: transform 0.3s ease;
}

.login-logo:hover {
    transform: scale(1.05);
}

.school-name {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-left: 1rem;
    font-weight: 400;
}

.nav-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--white);
    transition: all 0.3s ease;
}

.nav-link:hover::after {
    width: 80%;
    left: 10%;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-1px);
}

.nav-link.logout {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
}

.nav-link.logout:hover {
    background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.separator {
    opacity: 0.5;
}

.user-info {
    font-weight: 600;
    color: var(--white);
}

/* Alertas mejoradas estilo RENOVA2 */
.alert-banner {
    padding: 0.75rem 0;
    font-weight: 500;
}

.alert-warning {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #92400E;
    border-bottom: 2px solid #F59E0B;
}

.alert-link {
    color: #92400E;
    margin-left: 1rem;
    font-weight: 700;
    text-decoration: underline;
}

.flash-messages {
    padding: 1rem 0;
}

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    font-weight: 500;
}

.alert-success {
    background-color: #DEF7EC;
    border-color: #84E1BC;
    color: #03543F;
}

.alert-error {
    background-color: #FDE8E8;
    border-color: #F8B4B4;
    color: #9B1C1C;
}

.alert-info {
    background-color: #E1EFFE;
    border-color: #93C5FD;
    color: #1E40AF;
}

.close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    color: inherit;
}

.close:hover {
    opacity: 1;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Footer moderno */
.footer {
    background: #1F2937;
    color: var(--white);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-info p {
    margin: 0.25rem 0;
    opacity: 0.9;
}

.footer-copyright {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Botones modernos estilo RENOVA2 */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(145deg, #6366F1, #4F46E5);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: linear-gradient(145deg, #4F46E5, #6366F1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: linear-gradient(145deg, #8B5CF6, #7C3AED);
    color: var(--white);
}

.btn-secondary:hover {
    background: linear-gradient(145deg, #7C3AED, #8B5CF6);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-info {
    background: linear-gradient(145deg, #3B82F6, #2563EB);
    color: var(--white);
}

.btn-warning {
    background: linear-gradient(145deg, #F59E0B, #D97706);
    color: var(--white);
}

.btn-success {
    background: linear-gradient(145deg, #10B981, #059669);
    color: var(--white);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* Formularios modernos */
.form-group {
    margin-bottom: 1rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--white);
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.col-md-3 {
    flex: 0 0 25%;
}

.col-md-6 {
    flex: 0 0 50%;
}

label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.875rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input {
    margin-right: 0.5rem;
}

/* Login mejorado */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(99, 102, 241, 0.1);
    animation: fadeIn 0.5s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Tabs modernos */
.tabs-container {
    margin: 2rem 0;
}

.tabs {
    display: flex;
    list-style: none;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    gap: 0.5rem;
}

.tab-item {
    margin-right: 0.5rem;
}

.tab-item a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    border: 2px solid transparent;
    border-bottom: none;
    position: relative;
    top: 2px;
    background: transparent;
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-item:hover a {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.tab-item.active a {
    background: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    border-bottom: 2px solid var(--white);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-pane.active {
    display: block;
}

/* ACORDEONES BASE MODERNOS */
.accordion-section {
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.07);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(99, 102, 241, 0.08);
}

.accordion-section:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.accordion-header {
    width: 100%;
    padding: 1.5rem;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    color: var(--white);
    text-align: left;
    font-weight: 600;
    font-size: 1.1rem;
}

.accordion-header:hover {
    background: linear-gradient(135deg, #5B21B6 0%, #7C3AED 100%);
}

.accordion-header h3 {
    margin: 0;
    flex: 1;
    color: var(--white);
    font-size: inherit;
    font-weight: inherit;
}

.accordion-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    color: var(--white);
    margin-right: 0.75rem;
}

.accordion-header.active .accordion-icon {
    transform: rotate(90deg);
}

.accordion-badge {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.accordion-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s ease;
    background: var(--white);
}

.accordion-header.active + .accordion-content {
    padding: 2rem;
    max-height: 5000px;
}

/* Cards modernos */
.protocol-card,
.form-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.07);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(99, 102, 241, 0.05);
}

.protocol-card:hover,
.form-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: rgba(99, 102, 241, 0.2);
}

.protocol-card-header,
.form-card-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-bottom: 1px solid var(--border-color);
}

.protocol-card-body,
.form-card-body {
    padding: 1.25rem;
}

.protocol-card-footer,
.form-card-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(99, 102, 241, 0.02);
}

.protocols-grid,
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* Case Actions */
.case-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.btn-accion {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-accion-view {
    background: #e3f2fd;
}

.btn-accion-view:hover {
    background: #2196f3;
    transform: scale(1.1);
}

.btn-accion-print {
    background: #f3e5f5;
}

.btn-accion-print:hover {
    background: #9c27b0;
    transform: scale(1.1);
}

.btn-accion-edit {
    background: #fff3e0;
}

.btn-accion-edit:hover {
    background: #ff9800;
    transform: scale(1.1);
}

/* Estadísticas */
.protocol-stats {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.stat {
    text-align: center;
    flex: 1;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat.urgent .stat-value {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Tablas modernas */
.cases-table {
    width: 100%;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border-collapse: separate;
    border-spacing: 0;
}

.cases-table thead {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    color: var(--white);
}

.cases-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cases-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.cases-table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

.cases-table td {
    padding: 0.75rem 1rem;
    color: var(--text-dark);
}

.caso-row.urgente {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.caso-row.urgente:hover {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.08) 100%);
}

/* Badges mejorados */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.badge-info {
    background: linear-gradient(135deg, #56ccf2 0%, #2f80ed 100%);
    color: white;
}

.badge-secondary {
    background: linear-gradient(135deg, #667c88 0%, #434343 100%);
    color: white;
}

.badge-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: var(--white);
}

.badge-warning {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: var(--white);
}

.badge-tipo {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: var(--white);
    margin-right: 0.25rem;
    text-transform: capitalize;
}

/* Page header */
.page-header,
.protocol-header,
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.page-header h2,
.protocol-header h2,
.form-header h2 {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* Animaciones */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Secciones colapsables */
.collapsible-section {
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.section-header {
    padding: 1rem;
    background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: all 0.3s ease;
}

.section-header:hover {
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    padding: 1rem;
    display: block;
}

.section-header.collapsed + .section-content {
    display: none;
}

/* Filtros */
.filters-section {
    background: var(--white);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.filter-form {
    display: flex;
    align-items: end;
    gap: 1rem;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    transition: all 0.3s ease;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.pagination-info {
    padding: 0.5rem 1rem;
    background: var(--light-bg);
    border-radius: 6px;
    font-weight: 500;
}

/* Estados vacíos */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .col-md-3,
    .col-md-6 {
        flex: 1 1 100%;
    }
    
    .protocols-grid,
    .forms-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-item {
        margin-right: 0;
        margin-bottom: 0.25rem;
    }
    
    .tab-item a {
        border-radius: 6px;
    }
    
    .filter-form {
        flex-direction: column;
    }
    
    .cases-table {
        font-size: 0.875rem;
    }
    
    .cases-table th,
    .cases-table td {
        padding: 0.5rem;
    }
    
    .header-logo {
        height: 32px;
    }
    
    .login-logo {
        height: 50px;
    }
    
    .logo-section {
        gap: 0;
    }

    .form-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: flex-start;
        align-items: center;
        margin-top: 2rem;
        padding: 1.5rem;
        background: linear-gradient(135deg, rgba(99, 102, 241, 0.03) 0%, rgba(139, 92, 246, 0.03) 100%);
        border-radius: 10px;
        border: 1px solid rgba(99, 102, 241, 0.1);
    }

    .form-actions .btn {
        flex: 0 0 auto;
        width: 220px;
        text-align: center;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    @media (max-width: 768px) {
        .form-actions {
            flex-direction: column;
            align-items: stretch;
        }
        
        .form-actions .btn {
            width: 100%;
        }
    }

    /* Específico para acuerdos restaurativos */
    .acuerdo-form-footer {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        align-items: center;
        margin-top: 2rem;
        padding: 1rem;
        background: rgba(99, 102, 241, 0.02);
        border-radius: 8px;
    }

    .acuerdo-form-footer .btn {
        flex: 0 0 auto;
        min-width: 160px;
    }

    @media (max-width: 768px) {
        .form-actions,
        .acuerdo-form-footer {
            flex-direction: column;
            align-items: stretch;
        }
        
        .form-actions .btn,
        .acuerdo-form-footer .btn {
            min-width: auto;
            width: 100%;
        }
    }

/* Footer mejorado con enlaces activos */
.footer-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.footer-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
    transform: translateY(-1px);
}

.footer-copyright small {
    opacity: 0.8;
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .footer-content {
        text-align: center;
        gap: 1rem;
    }
    
    .footer-info p {
        margin: 0.5rem 0;
        font-size: 0.9rem;
    }
}