html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* без общ скрол в iframe */
}

/* Модален прозорец за уреди на отбор (ансамбъл) в класирането */
.team-apparatus-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.team-apparatus-modal-content {
    background-color: #fefefe;
    margin: 4% auto;
    padding: 24px;
    border-radius: 10px;
    width: 90%;
    max-width: 960px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.team-apparatus-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.team-apparatus-modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.team-apparatus-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.team-apparatus-close:hover {
    color: #000;
}

.team-apparatus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.team-apparatus-item {
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: transform 0.2s, box-shadow 0.2s;
}

.team-apparatus-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-apparatus-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 8px;
}

.team-apparatus-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    word-break: break-word;
}

.team-apparatus-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.gymnasts-columns {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.gymnasts-columns .col {
    flex: 1;
    text-align: left;
}

.gymnasts-columns .col-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.team-apparatus-item ol {
    margin: 0 0 0 18px;
    padding: 0;
    text-align: left;
}

.ranking-container {
    padding: 15px 20px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.ranking-container h2 {
    margin-bottom: 12px;
}

.ranking-filters {
    background: #f9fafb;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 10px;
    flex: 0 0 auto;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 8px;
}

.filter-group {
    min-width: 180px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

/* Падащи менюта във филтрите */
.filter-group select,
.filter-group .form-control {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #cbd3da;
    background-color: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.filter-group select:focus,
.filter-group .form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
}

.filter-group select:hover,
.filter-group .form-control:hover {
    background-color: #fdfdfd;
}

.filter-row .filter-buttons {
    display: flex;
    align-items: center;
}

/* Бутон "Изчисти" – ползва се и в двата файла */
.clear-filters-btn {
    display: inline-block;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.clear-filters-btn:hover {
    background-color: #ffe8a1;
    border-color: #ffdf7e;
    color: #7a5a00;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.clear-filters-btn:active {
    background-color: #ffd666;
    border-color: #ffc94a;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.ranking-table-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* хоризонтален скрол ще е в .ranking-table-body */
}

.ranking-table-body {
    display: block;
    width: 100%;
    overflow-y: auto;   /* вертикален скрол за редовете */
    overflow-x: auto;   /* хоризонтален скрол под таблицата */
    max-height: 100%;
}

.ranking-table {
    width: max-content; /* позволява таблицата да се разшири хоризонтално при много колони */
    min-width: 100%;    /* но да не става по-тясна от прозореца */
}

.ranking-table th,
.ranking-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #ddd;
    vertical-align: middle;
    white-space: nowrap; /* не позволява свиване на колоните, за да се появи хоризонтален скрол */
}

.ranking-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ranking-table .photo-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.ranking-table .flag-icon {
    width: 24px;
    height: 16px;
    vertical-align: middle;
    margin-right: 5px;
}

.ranking-table .apparatus-thumbnail {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.total-score-column {
    font-weight: bold;
}

.selection-controls {
    margin-left: 10px;
}

/* Модален прозорец за детайли на оценката - използва се в ranking_web.php */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.score-details {
    margin-top: 20px;
}

.score-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.score-item {
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.score-label {
    font-weight: bold;
    margin-bottom: 5px;
}

.score-value {
    font-size: 18px;
    color: #2c3e50;
}

.loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #6c757d;
}
