/**
 * Marathon Calendar - Modern Design System 2025
 * Вдохновлено: Strava, TrainingPeaks, Garmin Connect
 */

/* ========================================
   DESIGN TOKENS - Цветовая система
   ======================================== */
:root {
    /* Primary - фирменный голубой */
    --primary-50:  #E6F6FF;
    --primary-100: #CCEFFF;
    --primary-200: #99DFFF;
    --primary-300: #66CFFF;
    --primary-400: #33BFF5;
    --primary-500: #00A8E8;  /* Основной цвет */
    --primary-600: #0080B8;
    --primary-700: #006690;
    --primary-800: #004F70;
    --primary-900: #003A52;
    
    /* Success - Зеленый (выполнено, успех) */
    --success-50:  #ECFDF5;
    --success-100: #D1FAE5;
    --success-500: #10B981;
    --success-600: #059669;
    --success-700: #047857;
    
    /* Warning / Accent - Оранжевый */
    --warning-50:  #FFF3EB;
    --warning-100: #FFE3D3;
    --warning-500: #FF6B35;
    --warning-600: #E15822;
    
    /* Danger - Красный (интервалы, высокая интенсивность) */
    --danger-50:  #FEF2F2;
    --danger-500: #EF4444;
    --danger-600: #DC2626;
    
    /* Info - Синий (длительные пробежки) */
    --info-50:  #EFF6FF;
    --info-500: #3B82F6;
    --info-600: #2563EB;
    
    /* Neutrals - Серая шкала */
    --gray-50:  #F5F7FA;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Градиенты */
    --gradient-primary: linear-gradient(135deg, #00A8E8 0%, #0080B8 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-hero: linear-gradient(135deg, #00A8E8 0%, #FF6B35 100%);
    
    /* Spacing System (8px base) */
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-5: 1.25rem;  /* 20px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-10: 2.5rem;  /* 40px */
    --space-12: 3rem;    /* 48px */
    --space-16: 4rem;    /* 64px */
    
    /* Typography Scale */
    --text-xs:   0.75rem;   /* 12px */
    --text-sm:   0.875rem;  /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg:   1.125rem;  /* 18px */
    --text-xl:   1.25rem;   /* 20px */
    --text-2xl:  1.5rem;    /* 24px */
    --text-3xl:  1.875rem;  /* 30px */
    --text-4xl:  2.25rem;   /* 36px */
    --text-5xl:  3rem;      /* 48px */
    
    /* Font Weights - Montserrat */
    --font-light:    300;
    --font-normal:   400;
    --font-medium:   500;
    --font-semibold: 600;
    --font-bold:     700;
    --font-extrabold: 800;
    
    /* Border Radius */
    --radius-sm: 0.375rem;  /* 6px */
    --radius-md: 0.5rem;    /* 8px */
    --radius-lg: 0.75rem;   /* 12px */
    --radius-xl: 1rem;      /* 16px */
    --radius-2xl: 1.5rem;   /* 24px */
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   BASE STYLES
   ======================================== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--text-base);
    font-weight: 400;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   CONTAINER & LAYOUT
   ======================================== */
.container {
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ========================================
   HEADER - Обновленный дизайн
   ======================================== */
.header {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-10) var(--space-12);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

/* Subtle pattern overlay */
.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

h1 { 
    position: relative;
    color: white; 
    margin-bottom: var(--space-2); 
    font-size: var(--text-4xl); 
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.subtitle { 
    position: relative;
    color: rgba(255,255,255,0.95); 
    margin-bottom: 0; 
    font-size: var(--text-lg); 
    font-weight: var(--font-normal);
    opacity: 0.9;
}

/* ========================================
   CONTROLS BAR - Sticky navigation
   ======================================== */
.controls {
    background: white;
    padding: var(--space-5) var(--space-12);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

/* ========================================
   BUTTONS - Единая система
   ======================================== */
.btn {
    padding: var(--space-2) var(--space-4);
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
}

.btn:hover { 
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: var(--primary-50);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:hover {
    background: var(--primary-600);
    border-color: var(--primary-600);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

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

.btn-share:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-print {
    border-color: var(--gray-300);
}

.btn-print:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* ========================================
   PROGRESS INDICATOR
   ======================================== */
.progress-indicator {
    margin-left: auto;
    padding: var(--space-2) var(--space-4);
    background: var(--primary-50);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--primary-700);
}

.progress-indicator strong {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--primary-600);
}

/* ========================================
   VIEWING BANNER - Баннер просмотра
   ======================================== */
.viewing-banner {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-4) var(--space-6);
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.viewing-banner strong {
    font-weight: var(--font-semibold);
}

.btn-back {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: var(--font-medium);
    transition: all var(--transition-base);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: var(--text-sm);
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-3px);
}

/* ========================================
   CONTENT AREA
   ======================================== */
.content {
    padding: var(--space-8) var(--space-12);
    padding-bottom: 200px; /* Для фиксированной легенды */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ========================================
   PHASE - Фазы тренировок
   ======================================== */
.phase {
    margin-bottom: var(--space-8);
}

.phase-header {
    padding: var(--space-5) var(--space-6);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    user-select: none;
}

.phase-header:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.phase-header:active {
    transform: scale(0.98);
}

/* Цвета фаз (обновленные, без желтого!) */
.phase0 {
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    color: var(--gray-700);
}

.phase1 {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    color: #1E40AF;
}

.phase2 {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    color: #065F46;
}

.phase3 {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #92400E;
}

.phase4 {
    background: linear-gradient(135deg, #FCE7F3 0%, #FBCFE8 100%);
    color: #831843;
}

.phase5 {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    color: #991B1B;
}

.phase-toggle {
    font-size: var(--text-xl);
    transition: transform var(--transition-base);
    display: inline-block;
}

.phase-title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-1);
    line-height: 1.3;
}

.phase-goal {
    font-size: var(--text-sm);
    opacity: 0.9;
}

.phase-content {
    padding: var(--space-6) 0;
}

/* ========================================
   WEEK - Недели тренировок
   ======================================== */
.week {
    margin-bottom: var(--space-10);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.week-header {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    margin-top: var(--space-2);
    transition: all var(--transition-base);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
}

.week-header:hover {
    background: var(--gray-100);
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
    transform: translateX(2px);
}

/* Выделение текущей недели */
.week.current-week .week-header {
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
    border-color: var(--primary-400);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.week-toggle {
    font-size: var(--text-base);
    color: var(--gray-500);
    user-select: none;
    min-width: 20px;
    display: inline-block;
    transition: transform 0.2s ease;
    margin-right: var(--space-2);
}

.week-content {
    /* Без дополнительных отступов, используем существующие */
}

.week-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0;
}

.week-label {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    line-height: 1.3;
}

.week.current-week .week-label {
    color: var(--primary-700);
}

.week-stats {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-600);
}

.days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    padding: 0 var(--space-2);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.day-header {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--gray-500);
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ========================================
   DAYS GRID - Сетка дней
   ======================================== */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-3);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ========================================
   TRAINING CELL - ОПТИМИЗИРОВАННЫЙ ДИЗАЙН
   ======================================== */
.training-cell {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-3);
    min-height: 130px;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    
    /* Мягкая тень вместо borders */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08),
                0 1px 1px rgba(0, 0, 0, 0.04);
    
    /* Цветовая полоска слева - более заметная */
    border-left: 5px solid var(--gray-300);
    border-top: 1px solid var(--gray-100);
}

/* Hover effect - более плавный */
.training-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
                0 2px 4px rgba(0, 0, 0, 0.08);
    border-left-width: 6px;
}

/* Active/Focus */
.training-cell:active {
    transform: translateY(-2px);
}

/* Completed state - автоматически определяется */
.training-cell.completed,
.training-cell.has-workouts {
    background: var(--success-50);
    border-left-color: var(--success-500);
}

/* Галочка выполнения - отображается автоматически */
.training-cell.completed::after,
.training-cell.has-workouts::after {
    content: '✓';
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 24px;
    height: 24px;
    background: var(--success-500);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    box-shadow: var(--shadow-md);
}

/* Rest day */
.rest-day {
    background: var(--gray-50) !important;
    border-left-color: var(--gray-400) !important;
    min-height: 100px;
    cursor: pointer;
    opacity: 0.85;
}

.rest-day:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Training types - улучшенное цветовое кодирование */
.long-run {
    border-left-color: var(--info-600);
    background: linear-gradient(to right, var(--info-50) 0%, white 10%);
}

.interval {
    border-left-color: var(--danger-600);
    background: linear-gradient(to right, var(--danger-50) 0%, white 10%);
}

.tempo {
    border-left-color: var(--success-600);
    background: linear-gradient(to right, var(--success-50) 0%, white 10%);
}

.key-session {
    border-left-color: var(--warning-600);
    background: linear-gradient(to right, var(--warning-50) 0%, white 10%);
    border-left-width: 6px;
}

.key-session::before {
    content: '⭐';
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    font-size: var(--text-lg);
}

.control {
    border-left-color: var(--gray-600);
}

.free-training {
    background: white !important;
    border-left-color: var(--warning-500);
}

/* ========================================
   TRAINING CELL CONTENT
   ======================================== */
.date-cell {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    margin-bottom: var(--space-2);
    line-height: 1.2;
}

.training-content {
    font-size: var(--text-xs);
    color: var(--gray-700);
    line-height: 1.4;
    flex: 1;
    margin-bottom: var(--space-2);
}

/* УДАЛЕНО: Checkbox wrapper - больше не используется */

/* ========================================
   WORKOUT DISPLAY - Отображение тренировок
   ======================================== */
.result-display {
    margin-top: auto;
    font-size: var(--text-xs);
}

/* Вручную добавленные результаты */
.result-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.result-info-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--gray-700);
    font-weight: var(--font-medium);
}

.result-info-item strong {
    font-size: var(--text-sm);
}

/* Тренировки из GPX/TCX - ОБНОВЛЕННЫЙ ДИЗАЙН */
.workout-summary {
    margin-top: var(--space-2);
    padding: var(--space-3);
    background: var(--success-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--success-200);
}

.workout-indicator {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--success-700);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.workout-stat {
    font-size: var(--text-xs);
    color: var(--gray-700);
    margin-bottom: var(--space-1);
    font-weight: var(--font-medium);
}

.workout-summary-divider {
    height: 1px;
    background: var(--gray-200);
    margin: var(--space-2) 0;
}

/* Подсветка карточек с тренировками */
.training-cell.has-workouts {
    border-left-color: var(--success-500);
    border-left-width: 4px;
}

/* ========================================
   BUTTON ADD/EDIT TRAINING - Кнопки добавления/редактирования тренировки
   ======================================== */
.btn-add-training,
.btn-edit-training {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-base);
    transition: all var(--transition-base);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.btn-add-training:hover,
.btn-edit-training:hover {
    background: var(--primary-600);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-edit-training {
    background: var(--warning-500);
    top: 40px;
}

.btn-edit-training:hover {
    background: var(--warning-600);
}

/* ========================================
   BUTTON RESULT - Кнопка добавления
   ======================================== */
.btn-result {
    position: absolute;
    bottom: var(--space-3);
    right: var(--space-3);
    width: 32px;
    height: 32px;
    padding: 0;
    background: white;
    color: var(--primary-500);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--text-lg);
    transition: all var(--transition-base);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.btn-result:hover {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-result:active {
    transform: scale(0.95);
}

/* ========================================
   LEGEND - Обновленная легенда
   ======================================== */
.legend {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    z-index: 999;
    padding: var(--space-6) var(--space-12);
}

.legend-title {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--gray-900);
    margin-bottom: var(--space-4);
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--gray-700);
}

.legend-color {
    width: 4px;
    height: 32px;
    border-radius: var(--radius-sm);
}

/* ========================================
   MODAL - Модальные окна
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn var(--transition-base) ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-2xl);
    animation: modalSlideIn var(--transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-content.modal-large {
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from { 
        transform: translateY(-40px) scale(0.95); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) var(--space-6);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--gray-900);
}

.close {
    color: var(--gray-400);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    transition: all var(--transition-base);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    line-height: 1;
}

.close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal-body {
    padding: var(--space-6);
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.form-group {
    margin-bottom: var(--space-6);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-semibold);
    color: var(--gray-900);
    font-size: var(--text-sm);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    transition: all var(--transition-base);
    font-family: inherit;
    background: white;
    color: var(--gray-900);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234B5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-10);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input[type="checkbox"] {
    width: auto;
    height: 18px;
    width: 18px;
    cursor: pointer;
    accent-color: var(--primary-500);
    margin: 0;
}

.form-group label .required {
    color: var(--danger-500);
    font-weight: var(--font-bold);
    margin-left: 2px;
}

.form-group small {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--gray-500);
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--gray-200);
}

/* ========================================
   TODAY DASHBOARD - Карточка сегодняшнего дня
   ======================================== */
.today-dashboard {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Контейнер для дашборда и описания плана */
.dashboard-container {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    align-items: stretch;
}

@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        gap: var(--space-4);
    }
}

.today-dashboard-header {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-4) var(--space-5);
    position: relative;
    overflow: hidden;
}

.today-dashboard-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15), transparent 50%);
    pointer-events: none;
}

.today-date {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.today-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.today-day-name {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    line-height: 1.2;
}

.today-date-num {
    font-size: var(--text-base);
    opacity: 0.9;
    font-weight: var(--font-medium);
}

.today-week-info {
    position: relative;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    opacity: 0.85;
}

.today-dashboard-content {
    padding: var(--space-4) var(--space-5);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Стили для блока описания плана */
#plan-description-block {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-5) !important;
    font-size: var(--text-sm);
    line-height: 1.6;
}

#plan-description-block h2 {
    font-size: var(--text-lg) !important;
    margin-bottom: var(--space-3) !important;
}

#plan-description-block > div {
    flex: 1;
    overflow-y: auto;
    max-height: 100%;
}

/* Стили для карточки описания плана */
.plan-description-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-xl);
    color: white;
    box-shadow: var(--shadow-lg);
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255,255,255,0.1);
    padding: var(--space-4) var(--space-5) !important;
}

.plan-description-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.plan-description-close:hover {
    background: rgba(255,255,255,0.3);
}

.plan-description-card h2 {
    margin: 0 0 var(--space-2) 0;
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: white;
    padding-right: var(--space-8);
}

.plan-description-text {
    line-height: 1.5;
    color: rgba(255,255,255,0.95);
    white-space: pre-wrap;
    flex: 1;
    overflow-y: auto;
    font-size: var(--text-xs);
}

@media (max-width: 768px) {
    .dashboard-container {
        margin-bottom: var(--space-6);
    }
    
    .today-dashboard {
        margin-bottom: var(--space-4);
    }
    
    .plan-description-card {
        margin: 0 !important;
    }
    
    .plan-description-text {
        font-size: var(--text-xs);
    }
}

.today-plan {
    margin-bottom: var(--space-6);
}

.today-plan-type {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--gray-300);
}

.today-plan-type.long-run {
    border-left-color: var(--info-600);
    background: var(--info-50);
}

.today-plan-type.interval {
    border-left-color: var(--danger-600);
    background: var(--danger-50);
}

.today-plan-type.tempo {
    border-left-color: var(--success-600);
    background: var(--success-50);
}

.today-plan-type.key-session {
    border-left-color: var(--warning-600);
    background: var(--warning-50);
}

.plan-icon {
    font-size: var(--text-2xl);
    line-height: 1;
}

.plan-type-label {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--gray-900);
}

.today-plan-description {
    font-size: var(--text-base);
    color: var(--gray-700);
    line-height: 1.6;
}

/* Стили для полного описания ОФП в дашборде */
.today-plan-description .short-desc-details {
    font-size: var(--text-sm);
    color: var(--gray-700);
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-2) 0;
}

.today-plan-description .short-desc-details b,
.today-plan-description .short-desc-details strong {
    font-weight: var(--font-bold);
    color: var(--gray-900);
    display: block;
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
}

.today-plan-description .short-desc-details b:first-child,
.today-plan-description .short-desc-details strong:first-child {
    margin-top: 0;
}

.today-plan-description .short-desc-details br {
    line-height: 1.8;
}

.today-status {
    margin-bottom: var(--space-6);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.status-completed {
    background: var(--success-50);
    color: var(--success-700);
    border: 1px solid var(--success-200);
}

.status-pending {
    background: var(--warning-50);
    color: var(--warning-700);
    border: 1px solid var(--warning-200);
}

.status-icon {
    font-size: var(--text-lg);
}

.status-count {
    margin-left: var(--space-2);
    font-size: var(--text-xs);
    opacity: 0.8;
}

.today-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.btn-today-action {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    border: 1.5px solid var(--gray-300);
    background: white;
    color: var(--gray-900);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-today-action:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-today-action.btn-primary {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.btn-today-action.btn-primary:hover {
    background: var(--primary-600);
    border-color: var(--primary-600);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-today-action.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-900);
    border-color: var(--gray-300);
}

.btn-today-action.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

/* Десктопная версия dashboard - горизонтальная раскладка */
@media (min-width: 769px) {
    .today-dashboard-content {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: var(--space-6);
        align-items: start;
    }
    
    .today-plan {
        margin-bottom: 0;
    }
    
    .today-status {
        margin-bottom: var(--space-4);
    }
    
    .today-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .btn-today-action {
        flex: 1;
        min-width: 140px;
    }
}

/* Мобильная версия dashboard */
@media (max-width: 768px) {
    .today-dashboard {
        margin-bottom: var(--space-6);
        border-radius: var(--radius-lg);
    }
    
    .today-dashboard-header {
        padding: var(--space-5) var(--space-5);
    }
    
    .today-day-name {
        font-size: var(--text-xl);
    }
    
    .today-dashboard-content {
        padding: var(--space-5);
    }
    
    .today-actions {
        gap: var(--space-2);
    }
    
    .btn-today-action {
        padding: var(--space-4) var(--space-4);
        font-size: var(--text-sm);
    }
}

/* ========================================
   ACTIVITY TYPES SELECTION - Выбор типа тренировки
   ======================================== */
.activity-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.activity-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4) var(--space-3);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: white;
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
    position: relative;
}

.activity-type-card:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.activity-type-card.selected {
    border-color: var(--primary-500);
    background: var(--primary-100);
    box-shadow: 0 0 0 3px var(--primary-200);
}

.activity-type-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.activity-type-icon {
    font-size: var(--text-3xl);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.activity-type-name {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--gray-900);
}

.success-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.radio-option {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: white;
    cursor: pointer;
    transition: all var(--transition-base);
}

.radio-option:hover {
    border-color: var(--primary-400);
    background: var(--gray-50);
}

.radio-option input[type="radio"] {
    margin-right: var(--space-3);
    cursor: pointer;
}

.radio-option input[type="radio"]:checked + span {
    font-weight: var(--font-bold);
    color: var(--primary-700);
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

/* Мобильная версия выбора типов */
@media (max-width: 768px) {
    .activity-types-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: var(--space-2);
    }
    
    .activity-type-card {
        padding: var(--space-3) var(--space-2);
    }
    
    .activity-type-icon {
        font-size: var(--text-2xl);
    }
    
    .activity-type-name {
        font-size: var(--text-xs);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1400px) {
    .content, .controls, .header {
        padding-left: var(--space-8);
        padding-right: var(--space-8);
    }
    .days-grid {
        gap: var(--space-3);
    }
}

@media (max-width: 1024px) {
    .days-grid, .days-header {
        grid-template-columns: repeat(4, 1fr);
    }
    
    h1 {
        font-size: var(--text-3xl);
    }
}

@media (max-width: 768px) {
    /* Мобильная версия: горизонтальная прокрутка недели */
    .week-content {
        position: relative;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 15%; /* Отступ для эффекта peek */
        padding: 0;
        margin: 0;
        /* Скрываем полосу прокрутки */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .week-content::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    /* Убираем overlay градиенты - они создают нежелательный эффект прозрачности */
    
    .days-header {
        display: none; /* Скрываем заголовки дней на мобильной версии */
    }
    
    .days-grid {
        display: flex;
        flex-direction: row;
        gap: var(--space-3);
        padding: 0; /* Убираем padding - эффект peek будет через видимость соседних карточек */
        width: max-content;
        min-width: 100%;
        box-sizing: border-box;
        position: relative;
        background: transparent !important; /* Прозрачный фон контейнера */
        opacity: 1 !important; /* Полная непрозрачность контейнера */
    }
    
    .training-cell {
        flex: 0 0 70%; /* Каждая ячейка занимает 70% ширины экрана */
        min-width: 70%;
        max-width: 70%;
        scroll-snap-align: center;
        scroll-snap-stop: always;
        min-height: 200px;
        box-sizing: border-box;
        /* Убираем градиенты на мобильной версии для чистоты */
        background: white !important;
        opacity: 1 !important; /* Полная непрозрачность */
        /* Возвращаем box-shadow */
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08),
                    0 1px 1px rgba(0, 0, 0, 0.04) !important;
    }
    
    /* Упрощаем цветные рамки на мобильной версии - делаем их тоньше и менее заметными */
    .training-cell.long-run,
    .training-cell.interval,
    .training-cell.tempo,
    .training-cell.key-session,
    .training-cell.control,
    .training-cell.free-training {
        border-left-width: 3px !important;
        background: white !important; /* Убираем градиенты */
        opacity: 1 !important; /* Полная непрозрачность */
        /* Убираем все градиенты */
        background-image: none !important;
    }
    
    /* Упрощаем эффект выполненных тренировок на мобильной версии */
    .training-cell.completed,
    .training-cell.has-workouts {
        background: white !important; /* Убираем зеленый фон */
        background-image: none !important; /* Убираем градиенты */
        border-left-color: var(--success-500) !important; /* Оставляем только зеленую рамку */
        opacity: 1 !important; /* Полная непрозрачность */
    }
    
    /* Выделение текущего дня */
    .training-cell.current-day {
        box-shadow: 0 0 0 3px var(--primary-500), 0 4px 12px rgba(99, 102, 241, 0.3);
        transform: scale(1.03);
        z-index: 5;
        position: relative;
    }
    
    /* Убираем звездочку и другие декоративные элементы на мобильной версии */
    .training-cell.key-session::before {
        display: none;
    }
    
    .content, .controls, .header {
        padding: var(--space-5);
    }
    
    h1 {
        font-size: var(--text-2xl);
    }
}

@media (max-width: 640px) {
    /* На очень маленьких экранах уменьшаем размер ячеек для лучшей видимости */
    .training-cell {
        flex: 0 0 75%; /* Немного больше для маленьких экранов */
        min-width: 75%;
        max-width: 75%;
        min-height: 180px;
        /* Убираем градиенты на очень маленьких экранах */
        background: white !important;
        /* Возвращаем box-shadow */
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08),
                    0 1px 1px rgba(0, 0, 0, 0.04) !important;
    }
    
    /* Упрощаем цветные рамки на очень маленьких экранах */
    .training-cell.long-run,
    .training-cell.interval,
    .training-cell.tempo,
    .training-cell.key-session,
    .training-cell.control,
    .training-cell.free-training {
        border-left-width: 3px !important;
        background: white !important;
    }
    
    .days-grid {
        padding: 0; /* Убираем padding для маленьких экранов */
    }
    
    .training-cell .date-cell::before {
        content: attr(data-day-name) ' ';
        font-size: var(--text-xs);
        color: var(--gray-500);
        font-weight: var(--font-medium);
        text-transform: uppercase;
        margin-right: var(--space-1);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    body { 
        background: white; 
    }
    .header, .controls, .legend { 
        display: none; 
    }
    .training-checkbox, .btn-result { 
        display: none; 
    }
    .week { 
        page-break-inside: avoid; 
    }
    .training-cell {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* ========================================
   LOADING STATE
   ======================================== */
.loading {
    text-align: center;
    padding: var(--space-8);
    color: var(--gray-500);
    font-size: var(--text-sm);
}

.loading::before {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
    margin-right: var(--space-2);
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center { text-align: center; }
.font-bold { font-weight: var(--font-bold); }
.font-semibold { font-weight: var(--font-semibold); }
.text-gray-600 { color: var(--gray-600); }
.text-primary { color: var(--primary-500); }
.text-success { color: var(--success-500); }

