/* Основные стили для системы управления турнирами по фигурному катанию */

:root {
    --primary-color: #007bff;
    --primary-dark: #0056b3;
    --primary-light: #3399ff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --gradient-primary: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    --gradient-primary-hover: linear-gradient(135deg, #0056b3 0%, #004085 100%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    min-height: 100vh;
    /* Глобальный автоматический перенос длинных слов/строк */
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Навигация */
.navbar {
    background: var(--gradient-primary) !important;
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.3);
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    color: white !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.navbar-nav .nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9) !important;
    transition: background 0.2s ease, color 0.2s ease;
    padding: 0.55rem 0.75rem !important;
    border-radius: 0.375rem;
    margin: 0;
    white-space: nowrap;
}

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

/* Удобные зоны нажатия в раскрытом меню (моб. / планшет) */
@media (max-width: 1199.98px) {
    .navbar-nav-touch .nav-link,
    .navbar-nav-touch .dropdown-toggle {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .navbar .dropdown-menu .dropdown-item {
        min-height:44px;
        display: flex;
        align-items: center;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Широкий экран: компактнее отступы, при нехватке места перенос блоков меню */
@media (min-width: 1200px) {
    .navbar-nav .nav-link {
        padding: 0.45rem 0.6rem !important;
    }
    .navbar .dropdown-menu {
        max-height: min(70vh, 28rem);
        overflow-y: auto;
    }
}

/* Карточки */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

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

.card-header {
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 1rem 1rem 0 0 !important;
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 123, 255, 0.2);
}

.card-header h4,
.card-header h5 {
    margin: 0;
    color: white;
    font-weight: 600;
}

/* Кнопки */
.btn {
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.625rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--gradient-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    color: white;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: white;
}

.btn-outline-primary:hover {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    border: none;
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8, #117a8b);
    border: none;
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #117a8b, #0c5460);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.4);
    color: white;
}

/* Таблицы */
.table {
    border-radius: 0.75rem;
    overflow: hidden;
    background: white;
}

.table thead th {
    background: var(--gradient-primary);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Исключение для таблиц с белым фоном - темный текст */
.table thead th[style*="background: #fff"],
.table thead th[style*="background:#fff"],
.table thead th[style*="background: white"],
.table thead th[style*="background:white"],
.rank-table thead th,
.category-table thead th {
    background: #fff !important;
    color: #333 !important;
    text-shadow: none;
}

.table-hover tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 123, 255, 0.1);
}

.table-hover tbody tr:hover {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.08) 0%, rgba(0, 123, 255, 0.05) 100%);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    /* Чтобы длинные значения не ломали вёрстку */
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Статистика */
.stat-item {
    text-align: center;
    padding: 1rem;
}

.stat-item h3,
.stat-item h4 {
    margin-bottom: 0.5rem;
    font-weight: bold;
}

/* Значки */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.bg-primary {
    background: var(--gradient-primary) !important;
}

.bg-success {
    background: linear-gradient(135deg, #28a745, #1e7e34) !important;
}

.bg-info {
    background: linear-gradient(135deg, #17a2b8, #117a8b) !important;
}

.bg-warning {
    background: linear-gradient(135deg, #ffc107, #e0a800) !important;
}

.bg-danger {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
}

/* Формы */
.form-control,
.form-select {
    border-radius: 0.5rem;
    border: 2px solid rgba(0, 123, 255, 0.2);
    transition: all 0.3s ease;
    padding: 0.625rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.form-control:hover,
.form-select:hover {
    border-color: rgba(0, 123, 255, 0.4);
}

/* Алерты */
.alert {
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
}

/* Пагинация - современный дизайн */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination .page-item {
    margin: 0;
}

.pagination .page-link {
    border-radius: 0.5rem;
    border: 2px solid rgba(0, 123, 255, 0.2);
    color: var(--primary-color);
    font-weight: 600;
    padding: 0.625rem 1rem;
    min-width: 44px;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.pagination .page-link:hover {
    background: var(--gradient-primary);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.pagination .page-item.active .page-link {
    background: var(--gradient-primary);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    transform: scale(1.05);
}

.pagination .page-item.disabled .page-link {
    background: #f8f9fa;
    border-color: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    box-shadow: none;
}

.pagination .page-item.disabled .page-link:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.pagination .page-link i {
    font-size: 0.875rem;
}

/* Прогресс бар */
.progress {
    border-radius: 0.5rem;
    height: 0.75rem;
}

.progress-bar {
    border-radius: 0.5rem;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.25rem;
    }
}

/* Специальные стили для фигурного катания */
.medal {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.medal.gold {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.medal.silver {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #000;
    box-shadow: 0 2px 4px rgba(192, 192, 192, 0.3);
}

.medal.bronze {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    color: #fff;
    box-shadow: 0 2px 4px rgba(205, 127, 50, 0.3);
}

/* Аватар спортсмена */
.athlete-avatar {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 3px solid var(--primary-color);
}

/* Информация о спортсмене */
.athlete-info .info-item {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.athlete-info .info-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.athlete-info .info-item strong {
    color: #495057;
    font-weight: 600;
}

/* Загрузка файлов */
.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.05);
}

.upload-area.dragover {
    border-color: var(--success-color);
    background-color: rgba(40, 167, 69, 0.05);
}

/* Спиннер */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Утилиты */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.shadow {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Стили для графиков */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-bottom: 1rem;
}

.chart-container canvas {
    max-height: 100% !important;
    max-width: 100% !important;
}

/* Адаптивность для графиков */
@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
}

@media (max-width: 576px) {
    .chart-container {
        height: 200px;
    }
}

/* Принудительно сохраняем светлую цветовую схему на устройствах с темной темой */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: only light;
    }

    body {
        background-color: #f8f9fa;
        color: #212529;
    }

    .card {
        background-color: #ffffff;
        color: #212529;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    }
    
    .card-header {
        background-color: #ffffff;
        border-bottom-color: #dee2e6;
        color: #212529;
    }
    
    .table {
        background-color: #ffffff;
        color: #212529;
    }
    
    .table thead th {
        background-color: #f8f9fa;
        color: #495057;
    }

    /* navbar не трогаем: иначе белый фон + белые ссылки .nav-link — «Вход» не виден и кажется «не нажимается» */
    .footer,
    footer {
        background-color: #ffffff;
        color: #212529;
    }
}
