/* Responsive system shared by admin, teacher and family portals. */
:root {
    --app-mobile-gutter: .75rem;
    --app-table-min-width: 720px;
    --sidebar-width: 230px;
    --sidebar-width-md: 200px;
    --topbar-height: 65px;
}

html {
    -webkit-text-size-adjust: 100%;
}

body,
main,
#main-content,
#content-inner,
#portal-content,
#docente-content,
.app-content,
.app-content-inner {
    min-width: 0;
}

.app-sidebar,
.docente-sidebar,
.portal-sidebar,
.sidebar-portal {
    height: 100vh;
    height: 100dvh;
}

.app-sidebar .nav-link,
.docente-sidebar .nav-link,
.portal-sidebar .nav-link {
    min-height: 42px;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
}

.card,
.card-body,
.row > * {
    min-width: 0;
}

.chart-responsive,
canvas {
    width: 100% !important;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    margin-bottom: 0;
}

.table th,
.table td {
    vertical-align: middle;
}

.form-control,
.form-select,
.input-group {
    max-width: 100%;
}

.select2-container {
    width: 100% !important;
    max-width: 100%;
}

.select2-container .select2-selection--single {
    min-height: 38px;
}

.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    padding-bottom: .25rem;
}

.nav-tabs .nav-link {
    white-space: nowrap;
}

.modal-content {
    max-height: calc(100dvh - 1rem);
}

.modal-body {
    overflow-y: auto;
}

.breadcrumb {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: .2rem;
}

.responsive-header {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
}

.responsive-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.page-shell {
    width: 100%;
    min-width: 0;
}

.stat-grid > [class*="col-"] {
    min-width: 0;
}

.mobile-card-list {
    display: none;
}

.desktop-table {
    display: block;
}

.card-asignacion {
    border: none;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .08);
    transition: transform .2s ease, box-shadow .2s ease;
}

.card-asignacion:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .12);
}

/* Calificaciones – estilos base (desktop + mobile) */
.calif-table-wrap {
    max-height: 75vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.calif-table {
    font-size: .75rem;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1100px;
}

.calif-sticky-col {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    min-width: 150px;
    box-shadow: 2px 0 4px rgba(0, 0, 0, .06);
}

.calif-estudiante-head {
    background: #f8faff !important;
    vertical-align: middle;
}

.calif-bloque-formativo {
    background: #0d9488;
    color: #fff;
    font-size: .68rem;
    letter-spacing: .04em;
}

.calif-bloque-sumativo {
    background: #1d4ed8;
    color: #fff;
    font-size: .68rem;
}

.calif-cat-head {
    font-size: .65rem;
    padding: .35rem .2rem !important;
    border-color: rgba(255, 255, 255, .2) !important;
}

.calif-insumo-head {
    font-size: .62rem;
    padding: .25rem !important;
    min-width: 42px;
}

.calif-sum-head {
    background: #dbeafe !important;
    color: #1e40af !important;
}

.bg-formativo-total {
    background: #ccfbf1 !important;
}

.bg-sumativo-total {
    background: #dbeafe !important;
}

.bg-final-total {
    background: #fef3c7 !important;
}

.calif-total-col {
    font-size: .65rem;
    min-width: 52px;
    vertical-align: middle;
}

.nota-input {
    width: 48px;
    font-size: .72rem;
    padding: .15rem .2rem;
    text-align: center;
}

.nota-guardada {
    border-color: #22c55e !important;
    background: #f0fdf4 !important;
}

.nota-error {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
}

.calif-calc {
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 991.98px) {
    .card-header.d-flex,
    .card-body > .d-flex.justify-content-between,
    .responsive-header,
    .d-flex.justify-content-between.align-items-center.mb-3,
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.mb-4 {
        flex-wrap: wrap;
        gap: .75rem;
    }

    .table-responsive > .table:not(.table-compact-mobile) {
        min-width: var(--app-table-min-width);
    }

    .dt-container .dt-layout-row {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .dt-container .dt-search,
    .dt-container .dt-length,
    .dt-container .dt-info,
    .dt-container .dt-paging {
        width: 100%;
        text-align: left;
    }

    .desktop-table {
        display: none !important;
    }

    .mobile-card-list {
        display: block !important;
    }
}

@media (max-width: 767.98px) {
    h1 { font-size: 1.45rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.2rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }

    .container,
    .container-fluid {
        --bs-gutter-x: 1.5rem;
    }

    .card {
        border-radius: .9rem !important;
    }

    .card-body {
        padding: 1rem;
    }

    .card-body.p-4,
    .card-body.p-5 {
        padding: 1rem !important;
    }

    .p-4:not(.modal-body),
    .p-5:not(.modal-body) {
        padding: 1rem !important;
    }

    .px-4,
    .px-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-4,
    .py-5 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .btn-group > .btn {
        border-radius: .375rem !important;
        margin: 1px;
    }

    .pagination {
        gap: .2rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination .page-link {
        border-radius: .4rem;
    }

    .modal-dialog {
        margin: .5rem;
    }

    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
    }

    .custom-alert {
        left: var(--app-mobile-gutter) !important;
        right: var(--app-mobile-gutter) !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    .responsive-actions,
    .responsive-actions > .btn,
    .responsive-actions > button,
    .responsive-actions > a {
        width: 100%;
    }

    .responsive-header > .btn,
    .responsive-header > button {
        width: 100%;
    }

    .hero-banner,
    .card > div[style*="linear-gradient"] {
        padding: 1.25rem !important;
    }

    .calif-table {
        font-size: .68rem;
    }

    .calif-sticky-col {
        min-width: 120px;
    }

    .nota-input {
        width: 44px;
        min-height: 36px;
    }

    .col-observacion {
        display: none;
    }

    .card-asignacion:hover {
        transform: none;
    }
}

@media (max-width: 575.98px) {
    .row {
        --bs-gutter-x: 1rem;
    }

    .btn:not(.btn-sm):not(.btn-close) {
        min-height: 42px;
    }

    .form-control,
    .form-select {
        font-size: 16px;
    }

    .input-group .form-control {
        min-width: 0;
    }

    .badge {
        white-space: normal;
    }

    .table-responsive {
        margin-inline: -.25rem;
        width: calc(100% + .5rem);
    }

    .table-responsive > .table {
        font-size: .78rem;
    }

    .table-responsive > .table th,
    .table-responsive > .table td {
        padding: .45rem .5rem;
    }

    .card-estudiante:hover {
        transform: none;
    }

    .w-md-auto {
        width: 100% !important;
    }
}

@media (min-width: 576px) {
    .w-md-auto {
        width: auto !important;
    }
}

@media print {
    .table-responsive {
        overflow: visible !important;
    }

    .table-responsive > .table {
        min-width: 0 !important;
    }

    .mobile-card-list {
        display: none !important;
    }

    .desktop-table {
        display: block !important;
    }
}
