/* static/css/main.css */
:root {
    --superset-primary: #0C074D;
    --superset-secondary: #6C757D;
    --superset-success: #3CB371;
    --superset-danger: #FF6B6B;
    --superset-warning: #FFA726;
    --superset-info: #17A2B8;
    --superset-light: #F8F9FA;
    --superset-dark: #343A40;
    --superset-gray: #6C757D;
    --superset-border: #E0E0E0;
    --superset-bg: #F5F7FA;
}

body {
    background-color: var(--superset-bg);
    padding-top: 70px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #2A3342;
    line-height: 1.6;
}

/* ===== ТРЁХКОЛОНОЧНЫЙ HEADER ===== */
.navbar .container-fluid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;
}

.nav-col-left,
.nav-col-right {
    flex: 0 0 10%;
    min-width: 0;
    display: flex;
    align-items: center;
}

.nav-col-left {
    justify-content: flex-start;
}

.nav-col-right {
    justify-content: flex-end;
}

.nav-col-center {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.nav-col-center .collapse:not(.show) {
    display: flex;
}

.navbar-nav {
    flex-direction: row;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}

/* Фон навбара – градиент */
.navbar {
    background: linear-gradient(135deg, #0C074D 0%, #1A91AD 100%);
    box-shadow: 0 2px 10px rgba(32, 167, 201, 0.2);
    padding: 0.75rem 0;
}

/* Логотип и бренд */
.navbar-brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
    transition: all 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand i {
    font-size: 1.75rem;
}

/* Пункты меню */
.nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 6px;
    margin: 0 0.125rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.nav-link.active {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Кнопка выхода */
.btn-logout {
    transition: all 0.3s ease !important;
}
.btn-logout:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.15);
}

/* Адаптивность хедера */
@media (max-width: 1200px) {
    .nav-col-left, .nav-col-right {
        flex: 0 0 auto;
        width: auto;
    }
    .nav-col-center {
        flex: 1 1 auto;
        justify-content: flex-end;
    }
    .navbar-toggler {
        order: 2;
        margin-left: auto;
    }
    .nav-col-center .collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(12, 7, 77, 0.95);
        backdrop-filter: blur(12px);
        border-radius: 0 0 20px 20px;
        padding: 0.5rem;
        z-index: 1000;
    }
    .nav-col-center .navbar-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-col-right {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    .navbar-brand span {
        display: none;
    }
    .nav-link span:not(.d-none) {
        display: none;
    }
    .nav-link i {
        margin-right: 0;
    }
}

/* Карточки */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    background: white;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: 1px solid var(--superset-border);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--superset-dark);
    border-radius: 12px 12px 0 0 !important;
    font-size: 1.1rem;
}

/* Общие кнопки (не superset) */
.btn-primary {
    background: linear-gradient(135deg, var(--superset-primary) 0%, #1A91AD 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(32, 167, 201, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(32, 167, 201, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--superset-success) 0%, #34A853 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(60, 179, 113, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(60, 179, 113, 0.4);
}

.btn-outline-secondary {
    border: 2px solid var(--superset-border);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    color: var(--superset-gray);
}

.fa-arrow-left {
    color: var(--superset-primary);
}

.btn-outline-secondary:hover {
    border-color: var(--superset-primary);
    color: var(--superset-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(32, 167, 201, 0.2);
}

.btn-create-student {
    background: linear-gradient(135deg, var(--superset-success) 0%, #34A853 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(60, 179, 113, 0.3);
    color: white;
    white-space: nowrap;
}

.btn-create-student:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(60, 179, 113, 0.4);
    color: white;
}

.btn-create-student i {
    margin-right: 0.5rem;
}

.btn-warning {
    background: linear-gradient(135deg, #FFA726 0%, #FF9800 100%) !important;
    border: none !important;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 167, 38, 0.3);
    color: white !important;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 167, 38, 0.4);
    background: linear-gradient(135deg, #FF9800 0%, #FFA726 100%) !important;
    color: white !important;
}

/* Формы */
.form-control, .form-select {
    border: 2px solid var(--superset-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--superset-primary);
    box-shadow: 0 0 0 0.2rem rgba(32, 167, 201, 0.25);
}

.form-label {
    font-weight: 600;
    color: var(--superset-dark);
    margin-bottom: 0.5rem;
}

.form-text {
    color: var(--superset-gray);
    font-size: 0.875rem;
    font-style: italic;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--superset-border);
}

.form-section.has-freezing {
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(74, 144, 226, 0.3), 0 0 10px rgba(74, 144, 226, 0.2);
    border: 1px solid rgba(74, 144, 226, 0.5);
    transition: all 0.3s ease;
}

.form-section.has-freezing::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle at 20% 40%, rgba(255,255,255,0.8) 0%, rgba(74,144,226,0.1) 80%);
    pointer-events: none;
    z-index: 0;
    border-radius: 12px;
}

.form-section.has-freezing .section-title,
.form-section.has-freezing .form-label,
.form-section.has-freezing .form-control,
.form-section.has-freezing .input-group-text,
.form-section.has-freezing .btn {
    position: relative;
    z-index: 1;
}

.section-title {
    color: var(--superset-dark);
    font-weight: 700;
    margin-bottom: 1.25rem;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--superset-primary);
}

/* Специфичные компоненты */
.schedule-item {
    border: 2px solid var(--superset-border);
    border-radius: 10px;
    padding: 1rem;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.schedule-item:hover {
    border-color: var(--superset-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(32, 167, 201, 0.15);
}

.schedule-item.selected {
    border-color: var(--superset-primary);
    background: linear-gradient(135deg, #f0f9ff 0%, #e1f5fe 100%);
    box-shadow: 0 4px 15px rgba(32, 167, 201, 0.2);
}

.student-card {
    border: 2px solid var(--superset-primary);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    background: linear-gradient(135deg, #f8fdff 0%, #f0f9ff 100%);
    box-shadow: 0 8px 30px rgba(32, 167, 201, 0.15);
}

/* Таблицы посещаемости */
.attendance-table th:first-child,
.attendance-table td:first-child {
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
}
.attendance-table th:nth-child(2),
.attendance-table td:nth-child(2) {
    position: sticky;
    left: 200px;
    background: white;
    z-index: 1;
}

/* Уведомления */
.alert {
    border: none;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid var(--superset-success);
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f1b0b7 100%);
    color: #721c24;
    border-left: 4px solid var(--superset-danger);
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid var(--superset-info);
}

/* Typography */
h1 {
    color: var(--superset-dark);
    font-weight: 700;
    margin-bottom: 1.5rem;
    font-size: 2.25rem;
    background: linear-gradient(135deg, var(--superset-primary) 0%, #1A91AD 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h5 {
    color: var(--superset-dark);
    font-weight: 600;
}

/* Select2 */
.select2-container--default .select2-selection--single {
    border: 2px solid var(--superset-border);
    border-radius: 8px;
    height: auto;
    padding: 0.75rem 1rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--superset-primary);
}

/* Спиннер */
.spinner-border {
    color: var(--superset-primary);
}

/* Badge общий */
.badge-superset {
    background: linear-gradient(135deg, var(--superset-primary) 0%, #1A91AD 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Контейнер */
.container {
    max-width: 1200px;
}

/* Ссылка Superset в навбаре */
.nav-link[href*="superset"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-link[href*="superset"]:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Утилиты */
.d-flex.align-items-center {
    align-items: center !important;
}

.hidden {
    display: none;
}

/* Последние платежи */
#recentPaymentsContainer .border {
    transition: all 0.2s ease;
    border: 1px solid #dee2e6 !important;
}
#recentPaymentsContainer .border:hover {
    background-color: rgba(32, 167, 201, 0.05) !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Хедер на Grid – идеальное центрирование */
.header-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;  /* левая и правая – равные доли, центр – по содержимому */
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.header-left {
    justify-self: start;
    display: flex;
    align-items: center;
}

.header-center {
    justify-self: center;
    display: flex;
    justify-content: center;
    width: auto;
}

.header-right {
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Меню внутри центра – тоже центрировано */
.header-center .navbar-nav {
    margin: 0 auto;
    justify-content: center;
}

/* Убираем возможные флексы от Bootstrap */
.header-center .collapse,
.header-center .navbar-collapse {
    flex-grow: 0 !important;
    width: auto !important;
}

/* Адаптив для мобилок */
@media (max-width: 1200px) {
    .header-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .header-left {
        order: 1;
    }
    .navbar-toggler {
        order: 2;
    }
    .header-right {
        order: 3;
    }
    .header-center {
        order: 4;
        width: 100%;
        justify-self: stretch;
    }
    .header-center .collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(12, 7, 77, 0.95);
        backdrop-filter: blur(12px);
        border-radius: 0 0 20px 20px;
        padding: 0.5rem;
        z-index: 1000;
    }
    .header-center .navbar-nav {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ===== Общие классы для карточек и заголовков (вынесены из шаблонов) ===== */

/* Карточка без анимации подъёма (для отчётов и главной) */
.card-static {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transform: none !important;
}

/* Градиентный заголовок карточки (синий градиент, белый текст) */
.card-header-gradient {
    background: linear-gradient(135deg, #0C074D 0%, #1A91AD 100%) !important; /* добавил !important */
    color: white !important;
    border-bottom: none;
    padding: 1rem 1.5rem;
}
.card-header-gradient h3,
.card-header-gradient h4,
.card-header-gradient h5 {
    color: white;
    margin: 0;
}

/* Эффект приподнимания карточки при наведении (для плиток меню) */
.hover-effect {
    transition: all 0.3s ease;
}
.hover-effect:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

/* Единый стиль для кнопок на главной и в отчётах */
.home-btn {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
    display: inline-block;
    min-width: 80px;
}


.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    color: white;
    filter: brightness(110%);
}
/* Спец-правило для кнопки с жёлтым/оранжевым фоном (лучше читаемость) */
.home-btn[style*="FFA726"],
.home-btn[style*="#FFA726"] {
    color: #212529;
}
.home-btn[style*="FFA726"]:hover,
.home-btn[style*="#FFA726"]:hover {
    color: #212529;
}


/* ===== Общие классы для карточек отчётов (вынесены из шаблонов) ===== */
.card-static {
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
    overflow: hidden !important;
    transform: none !important;
    background: white;
}

.card-header-gradient {
    background: linear-gradient(135deg, #0C074D 0%, #1A91AD 100%) !important;
    color: white !important;
    border-bottom: none !important;
    padding: 1rem 1.5rem !important;
}

.card-header-gradient h3,
.card-header-gradient h4,
.card-header-gradient h5 {
    color: white !important;
    margin: 0 !important;
}

/* Эффект приподнимания карточки */
.hover-effect {
    transition: all 0.3s ease;
}
.hover-effect:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

/* Стиль для кнопок на главной */
.home-btn {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
    display: inline-block;
    min-width: 80px;
}
.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    color: white;
    filter: brightness(110%);
}
.home-btn[style*="FFA726"],
.home-btn[style*="#FFA726"] {
    color: #212529 !important;
}



/* Убираем подчёркивание и наследуем цвет у карточек-ссылок */
a.card,
a.card:hover,
a.card:focus {
    color: inherit;
    text-decoration: none;
}

/* Ещё более компактный вид плиток на мобильных */
@media (max-width: 767.98px) {
    .card .fa-2x {
        font-size: 1.5em;       /* ≈ 24px */
    }
    .card-body h6 {
        font-size: 0.9rem;
        margin-bottom: 0.2rem;
    }
}

/* На самых маленьких экранах (до 575px) можно вообще убрать описание и уменьшить иконки */
@media (max-width: 575.98px) {
    .card .fa-2x {
        font-size: 1.4em;
    }
    .card-body h6 {
        font-size: 0.85rem;
    }
    /* Описание уже скрыто классом d-none d-sm-block, но на всякий случай */
    .card-body .small {
        display: none;
    }
}


/* Оптимизация под высоту мобильных экранов */
@media (max-height: 700px) and (max-width: 767.98px) {
    .container {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .card-body {
        padding: 0.5rem !important;
    }
    .card .fa-2x {
        font-size: 1.3em;
    }
    .card-body h6 {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
    .row.g-3 {
        --bs-gutter-y: 0.5rem;
    }
    /* Уменьшаем отступы у основного контейнера */
    .container.mt-4 {
        margin-top: 0.5rem !important;
    }
    /* Если карточка-заголовок слишком высокая, можно скрыть */
    .card-header h3 {
        font-size: 1.2rem;
    }
}


/* Компактный заголовок на мобильных */
@media (max-width: 767.98px) {
    .card-header-gradient h3 {
        font-size: 1.2rem;
        line-height: 1.3;
    }
}

@media (max-width: 575.98px) {
    .card-header-gradient h3 {
        font-size: 1rem;
    }
    /* Уменьшаем верхний отступ контейнера */
    .container.mt-4 {
        margin-top: 0.5rem !important;
    }
}

/* При малой высоте экрана дополнительно сжимаем */
@media (max-height: 700px) and (max-width: 767.98px) {
    .row.g-2 {
        --bs-gutter-y: 0.4rem;   /* уменьшаем вертикальный зазор */
    }
    .card-body {
        padding: 0.4rem !important;
    }
    .card .fa-2x {
        font-size: 1.3em;
    }
    .card-body h6 {
        font-size: 0.8rem;
        margin-bottom: 0;
    }
}


/* На мобильных устройствах скрываем бургер и навигационное меню */
@media (max-width: 991.98px) {
    .navbar-toggler,
    #navbarNav,
    .header-center {
        display: none !important;
    }

    /* Оставляем логотип и кнопку выхода */
    .header-left {
        flex: 1;
    }
    .header-right {
        flex: 0 0 auto;
        margin-left: auto;
    }

    /* Немного компактнее саму шапку */
    .navbar {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .btn-logout span {
        display: none;
    }
    /* Имя остаётся видимым */
}


/* Сервисы и регламентые задачи */
.table code {
    background: #f1f3f5;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
}