/* ============================================
   ACADEMICO PAGE - I.E.P.E. Apóstol Pablo
   Gestion de Grados, Secciones, Cursos, Aulas
   ============================================ */

.academic-page {
    padding: 1rem;
    min-height: 100%;
}

/* ============================================
   BREADCRUMB NAVIGATION
   ============================================ */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.breadcrumb-item:not(:disabled):hover {
    background: rgba(0, 85, 163, 0.1);
}

.breadcrumb-item:disabled,
.breadcrumb-item.current {
    color: #4a5568;
    cursor: default;
    font-weight: 600;
}

.breadcrumb-item.current:not(button) {
    background: rgba(0, 85, 163, 0.08);
}

.breadcrumb-home {
    width: 16px;
    height: 16px;
}

.breadcrumb-separator {
    color: #a0aec0;
    font-size: 0.85rem;
    user-select: none;
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 1rem;
    color: #718096;
}

.loading-state .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   ACADEMIC HEADER - Tabs y Acciones
   ============================================ */
.academic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.level-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.level-tab {
    padding: 0.6rem 1.25rem;
    background: var(--bg-white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.level-tab:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.level-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.level-tab .badge {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.level-tab.active .badge {
    background: rgba(255, 255, 255, 0.25);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(0, 85, 163, 0.05);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-sm:hover {
    background: #edf2f7;
    color: var(--color-primary);
}

.btn-icon-sm.danger:hover {
    background: #fed7d7;
    color: #c53030;
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
}

.btn-action {
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: var(--color-primary-dark);
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #4a5568;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.btn-back svg {
    width: 16px;
    height: 16px;
}

.btn-manage {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: var(--color-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-manage:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.btn-manage svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   GRADES GRID
   ============================================ */
.grades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.grade-card {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.grade-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.grade-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grade-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.grade-actions {
    display: flex;
    gap: 0.25rem;
}

.grade-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   SECTION VIEW
   ============================================ */
.section-view,
.courses-view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.section-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-dark);
}

.level-badge {
    padding: 0.3rem 0.75rem;
    background: var(--color-primary);
    color: white;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ============================================
   SECTIONS LIST
   ============================================ */
.sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-card {
    background: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all 0.2s ease;
}

.section-card:hover {
    box-shadow: var(--shadow-md);
}

.section-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.section-name h3 {
    margin: 0 0 0.35rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.section-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #718096;
}

.meta-item svg {
    width: 14px;
    height: 14px;
}

.section-stats {
    display: flex;
    gap: 1.5rem;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.mini-stat .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.mini-stat .label {
    font-size: 0.7rem;
    color: #a0aec0;
    text-transform: uppercase;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   COURSES TABLE
   ============================================ */
.courses-table {
    background: var(--bg-white);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.courses-table table {
    width: 100%;
    border-collapse: collapse;
}

.courses-table thead {
    background: #f7fafc;
}

.courses-table th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
}

.courses-table td {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    color: var(--text-dark);
    border-bottom: 1px solid #f0f0f0;
}

.courses-table tbody tr:hover {
    background: #f7fafc;
}

.courses-table tbody tr:last-child td {
    border-bottom: none;
}

.course-code {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #edf2f7;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--color-primary);
}

.actions-cell {
    display: flex;
    gap: 0.25rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #a0aec0;
}

.empty-state svg {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.modal {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal.modal-lg {
    max-width: 600px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.btn-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 1.5rem;
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: #f7fafc;
    color: #4a5568;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-dark);
    background: var(--bg-white);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 85, 163, 0.1);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dark);
    cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

/* ============================================
   CLASSROOMS MODAL
   ============================================ */
.classroom-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.classroom-form .form-input {
    flex: 1;
    min-width: 120px;
}

.classrooms-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.classroom-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.classroom-item:hover {
    background: #edf2f7;
}

.classroom-item.in-use {
    opacity: 0.7;
}

.classroom-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.classroom-name {
    font-weight: 600;
    color: var(--text-dark);
}

.classroom-capacity {
    font-size: 0.85rem;
    color: #718096;
}

.badge-equipment {
    padding: 0.2rem 0.5rem;
    background: #c6f6d5;
    color: #22543d;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-in-use {
    padding: 0.2rem 0.5rem;
    background: #fed7d7;
    color: #c53030;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.classroom-actions {
    display: flex;
    gap: 0.25rem;
}

/* ============================================
   SPINNER SMALL
   ============================================ */
.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 992px) {
    .section-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .section-card {
        flex-direction: column;
        align-items: stretch;
    }

    .section-actions {
        justify-content: flex-end;
        padding-top: 0.75rem;
        border-top: 1px solid #f0f0f0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .academic-page {
        padding: 0.75rem;
    }

    .academic-header {
        flex-direction: column;
        align-items: stretch;
    }

    .level-tabs {
        justify-content: center;
    }

    .header-actions {
        justify-content: center;
    }

    .grades-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .section-title {
        justify-content: center;
        text-align: center;
        flex-wrap: wrap;
    }

    .courses-table {
        overflow-x: auto;
    }

    .courses-table table {
        min-width: 500px;
    }

    .modal {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .classroom-form {
        flex-direction: column;
    }

    .classroom-form .form-input,
    .classroom-form .btn-primary,
    .classroom-form .btn-secondary {
        width: 100%;
    }
}
