/* ===== SEARCH SECTION ===== */
.search-box {
    margin: 30px 0;
    max-width: 610px;
}

.search-wrapper {
    display: flex;
    align-items: center;
    border: 3px solid #193D50;
    border-radius: 15px;
    background-color: white;
    overflow: hidden;
}

.search-icon {
    padding: 0 12px;
    display: flex;
    align-items: center;
    color: #666;
}

.search-input {
    flex: 1;
    padding: 6px 10px 6px 0;
    font-size: 15px;
    font-style: italic;
    border: none;
    outline: none;
    background: transparent;
}

/* ===== TABLE STYLES ===== */
.table-container {
    overflow: hidden;
    border-radius: 16px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 28px rgba(25, 61, 80, 0.1);
    border: 1px solid rgba(25, 61, 80, 0.1);
}

table#schoolsTable {
    width: 100%;
    border-left: none;
    border-right: none;
    border-collapse: collapse;
    min-width: auto;
    table-layout: auto;
}

/* Table Head
   ВАЖНО: используем прямой дочерний комбинатор (>), а не обычный пробел,
   чтобы эти стили не "протекали" во вложенную таблицу списка учеников
   (.school-students-table), которая физически лежит внутри #schoolsTable. */
#schoolsTable > thead {
    background: linear-gradient(180deg, #1c4a63, #193D50);
}

#schoolsTable > thead > tr > th {
    position: relative;
    white-space: nowrap;
    box-sizing: border-box;
    padding: 16px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: white;
    user-select: none;
}

/* Table Body (только строки верхнего уровня — не вложенная таблица) */
#schoolsTable > tbody > tr > td {
    padding: 14px 12px;
    text-align: center;
    border-bottom: 1px solid #e3e9ed;
    transition: background-color 0.2s ease;
}

#schoolsTable > tbody > tr.main-row {
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    color: #193D50;
}

#schoolsTable > tbody > tr.main-row.row-even {
    background-color: #f6f9fb;
}

#schoolsTable > tbody > tr.main-row:hover {
    background-color: #eaf3fb;
}

#schoolsTable > tbody > tr.detail-row.row-even .detail-content {
    background-color: #eef3f6;
}

#schoolsTable > tbody > tr:last-child > td {
    border-bottom: none;
}

#schoolsTable > tbody > tr.main-row.expanded {
    background-color: #dceeff;
}

#schoolsTable > tbody > tr.main-row.expanded > td {
    border-bottom-color: transparent;
}

/* Место: медаль для топ-3 */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: 50%;
    background-color: #eef1f4;
    color: #193D50;
    font-weight: 700;
    font-size: 14px;
    transition: transform 0.2s ease;
}

#schoolsTable > tbody > tr.main-row:hover .rank-badge {
    transform: scale(1.08);
}

.rank-badge.rank-gold {
    background: linear-gradient(135deg, #ffe08a, #f5a623);
    color: #5a3d00;
    box-shadow: 0 3px 10px rgba(245, 166, 35, 0.45);
}

.rank-badge.rank-silver {
    background: linear-gradient(135deg, #eef1f4, #b9c1c9);
    color: #33414a;
    box-shadow: 0 3px 10px rgba(150, 160, 170, 0.4);
}

.rank-badge.rank-bronze {
    background: linear-gradient(135deg, #e6ac74, #b9702f);
    color: #3a1f00;
    box-shadow: 0 3px 10px rgba(180, 120, 50, 0.4);
}

.school-name-cell {
    font-weight: 600;
}

/* Подсветка школы, к которой привязан текущий пользователь — рассчитывается
   на клиенте (см. getCurrentUserSchoolId в script.js), поэтому видна только
   самому этому пользователю, а не всем посетителям страницы. */
#schoolsTable > tbody > tr.main-row.is-own-school {
    background-color: #fff6d8;
    box-shadow: inset 3px 0 0 #f5a623;
}

#schoolsTable > tbody > tr.main-row.is-own-school:hover {
    background-color: #fdedb8;
}

.own-school-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 50px;
    background-color: #f5a623;
    color: #4a3300;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.student-profile-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed rgba(25, 61, 80, 0.35);
    transition: color 0.15s, border-color 0.15s;
}

.student-profile-link:hover {
    color: #1867AA;
    border-bottom-color: #1867AA;
}

/* Шеврон-индикатор раскрытия строки (только на широких экранах, см. responsive.css) */
@media (min-width: 769px) {
    #schoolsTable > tbody > tr > td.total-column {
        position: relative;
        padding-right: 36px;
    }

    #schoolsTable > tbody > tr.main-row > td.total-column::after {
        content: '';
        position: absolute;
        right: 16px;
        top: 50%;
        width: 8px;
        height: 8px;
        border-right: 2px solid #193D50;
        border-bottom: 2px solid #193D50;
        opacity: 0.4;
        transform: translateY(-65%) rotate(45deg);
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    #schoolsTable > tbody > tr.main-row.expanded > td.total-column::after {
        transform: translateY(-35%) rotate(-135deg);
        opacity: 0.75;
    }
}

/* Column Widths */
.fio-column {
    min-width: 200px;
}

.group-column {
    min-width: 111px;
}

.number-column {
    min-width: 167px;
}

.total-column {
    font-weight: 600;
}

/* ===== DETAIL ROW (EXPANDABLE) ===== */
.detail-row {
    background-color: #eef3f6;
    display: none;
}

.detail-row.expanded {
    display: table-row;
}

.detail-content {
    padding: 0 !important;
    background-color: #eef3f6;
    border-bottom: 1px solid #e3e9ed;
    width: 100%;
}

/* Обёртка, которая плавно раскрывается по высоте при разворачивании строки
   (высота выставляется через JS в script.js: toggleSchoolRow/collapseSchoolRow) */
.detail-anim {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== СПИСОК УЧЕНИКОВ ШКОЛЫ (раскрывающаяся строка рейтинга) ===== */
.school-students-list {
    padding: 18px 28px 22px;
    background-color: #eef3f6;
}

.school-students-loading,
.school-students-error,
.school-students-empty {
    color: #667685;
    font-size: 14px;
    padding: 14px 0;
    text-align: center;
}

.school-students-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.school-students-loading::before {
    content: '';
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border: 3px solid rgba(25, 61, 80, 0.15);
    border-top-color: #193D50;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.school-students-error {
    color: #AA1818;
}

.school-students-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(25, 61, 80, 0.08);
    animation: fadeIn 0.3s ease both;
}

.school-students-table th {
    background-color: #193D50;
    color: white;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    padding: 10px 16px;
    border-bottom: none;
}

.school-students-table td {
    padding: 10px 16px;
    font-size: 14px;
    color: #2b3a45;
    border-bottom: 1px solid #eef1f4;
}

.school-students-table tbody tr:nth-child(even) {
    background-color: #f7f9fb;
}

.school-students-table tbody tr:hover {
    background-color: #eaf3fb;
}

.school-students-table tr:last-child td {
    border-bottom: none;
}

/* ===== СОСТОЯНИЯ ТАБЛИЦЫ (загрузка / пусто / ошибка) ===== */
.table-loading-state,
.table-empty-state,
.table-error-state {
    text-align: center;
    padding: 48px 20px;
    color: #6b7a85;
    font-size: 15px;
}

.table-error-state {
    color: #AA1818;
}

.table-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 10px;
    vertical-align: -4px;
    border: 3px solid rgba(25, 61, 80, 0.15);
    border-top-color: #193D50;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.detail-flex {
    display: flex;
    width: 100%;
    background-color: #c7c7c7;
    min-height: 100px;
    box-sizing: border-box;
}

.detail-cell {
    flex: 0 0 auto;
    padding: 12px;
    background-color: #c7c7c7;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.detail-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 15px 12px;
    background-color: #c7c7c7;
    box-sizing: border-box;
    min-height: 100px;
}

.detail-section:last-child {
    border-right: none;
}

.detail-item {
    margin-bottom: 8px;
    text-align: left;
    width: 100%;
}

.detail-item .label {
    color: black;
    font-size: 14px;
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.detail-item .value {
    color: black;
    font-size: 14px;
    font-style: italic;
    display: block;
}

/* Detail Section Widths */
.detail-institute {
    width: 200px;
    min-width: 200px;
}

.detail-group {
    width: 111px;
    min-width: 111px;
}

.detail-study {
    width: 167px;
    min-width: 167px;
}

.detail-research {
    width: 188px;
    min-width: 188px;
}

.detail-creative {
    width: 167px;
    min-width: 167px;
}

.detail-sport {
    width: 167px;
    min-width: 167px;
}

.detail-social {
    width: 167px;
    min-width: 167px;
}

.detail-certificates {
    width: 167px;
    min-width: 167px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-cell.certificates-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.certificates-btn {
    padding: 3px 23px;
    background-color: #193D50;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s;
    text-align: center;
    font-size: 11px;
    max-width: 117px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.certificates-btn:hover {
    background-color: #0056b3;
    text-decoration: none;
    color: white;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.pagination-info {
    color: #7f8c8d;
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    color: #495057;
    font-size: 14px;
    transition: all 0.2s;
    min-width: 36px;
    text-align: center;
}

.pagination-btn:hover:not(:disabled) {
    background-color: #e9ecef;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-number {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    color: #495057;
    font-size: 14px;
    transition: all 0.2s;
    min-width: 36px;
    text-align: center;
}

.page-number:hover {
    background-color: #f8f9fa;
}

.page-number.active {
    background-color: #193D50;
    color: white;
    border-color: #193D50;
}

.page-number.ellipsis {
    border: none;
    cursor: default;
    background: none;
}

.page-number.ellipsis:hover {
    background: none;
}

.goto-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.goto-input {
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-align: center;
}

.goto-btn {
    padding: 8px 12px;
    background-color: #193D50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.goto-btn:hover {
    background-color: #0056b3;
}

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    color: #193D50;
    background-color: white;
    margin: 6% auto;
    padding: 30px 0;
    width: 650px;
    border-radius: 18px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border: 4px solid #bdbdbd;
}

.subtext {
    text-align: center;
    margin-bottom: 50px;
    font-size: 21px;
    font-weight: 400;
}

/* ===== FORM STYLES ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 7px;
    border: 2px solid #bdbdbd;
    border-radius: 10px;
    font-size: 16px;
}

.form-group select {
    width: 100%;
    padding: 7px;
    border: 2px solid #bdbdbd;
    border-radius: 10px;
    font-size: 16px;
    background-color: white;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px;
    color: #777777;
}

.form-group select:focus {
    outline: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.form-group select option {
    padding: 10px;
    background-color: white;
    color: #333;
}

.form-group select option:hover {
    background-color: #f5f5f5;
}

/* ===== BUTTON STYLES ===== */
.next-btn,
.submit-btn {
    padding: 8px 50px;
    background-color: #193D50;
    color: white;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.next-btn:hover,
.submit-btn:hover {
    background-color: #11436f;
}

.submit-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.home-btn {
    padding: 10px 15px;
    background-color: #193D50;
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.home-btn:hover {
    background-color: #11436f;
}

/* ===== ERROR MESSAGES ===== */
.error-message {
    color: #f44336;
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

.error-message2 {
    color: #f44336;
    font-size: 14px;
    margin-top: 10px;
    height: 18px;
    text-align: center;
    display: block;
}

/* ===== CATEGORIES GRID ===== */
.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 30px 100px 50px;
}

.category-btn {
    padding: 10px 0;
    border: 2px solid #bdbdbd;
    background-color: white;
    border-radius: 10px;
    font-size: 16px;
    color: #193D50;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-btn:hover {
    background-color: #e9e9e9;
}

.category-btn.selected {
    background-color: #e0f7fa;
    border-color: #4CAF50;
    color: #00796b;
    font-weight: bold;
}