:root {
    --animation-duration: 0.3s;
}

/* ===== Базовые стили ===== */
html {
    scroll-behavior: smooth;
}

body,
nav,
.tracker-container,
.stat-card,
.tracker-list-item,
input,
select,
textarea,
.modal-responsive {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ===== Утилиты ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.break-words {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ===== Выравнивание текста ===== */
.text-justify {
    text-align: justify !important;
}

.modal-content p,
.modal-content .description-text,
.card-description,
.goal-section p,
.tracker-container .goal-section p,
.stat-card p.description,
[class*="modal"] p:not(.text-center):not(.text-left):not(.text-right) {
    text-align: justify;
    text-justify: inter-word;
}


h1, h2, h3, h4, h5, h6,
nav a,
button:not(.modal-content button),
.text-center {
    text-align: center;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

/* ===== Анимации ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fade-in { animation: fadeIn var(--animation-duration) ease-out; }
.animate-fadeIn { animation: fadeInUp var(--animation-duration) ease-out; }
.loading-spinner { animation: spin 1s linear infinite; }

/* ===== Компоненты ===== */
/* Дни */
.day-cell {
    transition: all 0.2s ease;
    min-height: 5rem;
    border-radius: 0.5rem;
    padding: 0.5rem;
    text-align: center;
}
.day-cell:hover { transform: translateY(-2px); }

/* Список трекеров */
.tracker-list-item {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}
.tracker-list-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.tracker-list-item.active {
    border-left-color: #3b82f6;
    background-color: #f0f9ff;
}

/* Прогресс */
.progress-bar {
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Карточки статистики */
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Пустое состояние */
.empty-state {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}
.empty-state:hover { opacity: 0.8; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Переключатель языка */
.language-switcher { position: relative; }
.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    min-width: 140px;
    z-index: 50;
    display: none;
    border: 1px solid #e5e7eb;
}
.language-dropdown.active { display: block; }

.language-option {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.875rem;
    gap: 0.75rem;
}
.language-option:hover { background-color: #f9fafb; }
.language-option.active {
    background-color: #eff6ff;
    color: #1d4ed8;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s;
    cursor: pointer;
}
.language-btn:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}
.language-btn i {
    font-size: 0.75rem;
    color: #6b7280;
    transition: transform 0.2s;
}
.language-btn.active i { transform: rotate(180deg); }

.mobile-lang-btn {
    transition: all 0.2s;
    border: 1px solid transparent;
}
.mobile-lang-btn.active {
    background-color: #eff6ff;
    color: #1d4ed8;
    font-weight: 500;
    border: 1px solid #dbeafe;
}

/* Календарь */
.calendar-grid {
    display: grid;
    gap: 0.75rem;
}

/* ===== Расширенная цветовая палитра ===== */
.color-palette {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(5, 1fr);
    justify-items: center;
    align-items: center;
}

.color-grid-main {
    margin-bottom: 0.5rem;
}

/* Кнопка-кружок для раскрытия */
.color-expand-btn {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 auto;
}

.color-expand-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
    border-color: #d1d5db;
}

.color-expand-btn i {
    color: #6b7280;
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.color-expand-btn.active i {
    transform: rotate(180deg);
}

.color-extra-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    justify-items: center;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Темная тема */
.dark .color-expand-btn {
    background: #374151;
    border-color: #4b5563;
}

.dark .color-expand-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
}

.dark .color-expand-btn i {
    color: #9ca3af;
}

.dark .color-extra-grid {
    border-top-color: #4b5563;
}

/* Адаптивность */
@media (max-width: 480px) {
    .color-expand-btn {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .color-expand-btn i {
        font-size: 0.875rem;
    }
    
    .color-grid,
    .color-extra-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
}

@media (max-width: 360px) {
    .color-grid,
    .color-extra-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Стили для выбора цвета */
.color-label {
    transition: all 0.2s ease;
    border: 4px solid transparent;
}
input[name="color"]:checked + .color-label {
    border-color: #1f2937;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}

/* Уведомление */
#simple-notification {
    position: fixed;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 14px;
    text-align: center;
    max-width: calc(100% - 32px);
    width: auto;
    min-width: 200px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}

/* ===== PDF стили ===== */
.pdf-template {
    width: 794px !important;
    height: 1123px !important;
    padding: 40px !important;
    background: white !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    box-sizing: border-box !important;
}
.pdf-calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 8px !important;
    margin: 20px 0 !important;
}
.pdf-day-cell {
    border: 2px solid !important;
    border-radius: 8px !important;
    padding: 8px !important;
    text-align: center !important;
    background: white !important;
    min-height: 60px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
}
.pdf-check-box {
    width: 30px !important;
    height: 30px !important;
    margin: 0 auto !important;
    border: 2px solid !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ===== Темная тема ===== */
.dark {
    color-scheme: dark;
}
.dark body {
    background-color: #111827;
    color: #f9fafb;
}

/* Навигация */
.dark nav a,
.dark nav .language-btn {
    color: #d1d5db;
}

.dark nav .language-btn:hover {
    color: #ffffff;
    background-color: #374151;
}

/* Градиенты и фоны */
.dark .bg-gradient-to-br.from-blue-50.to-cyan-50 {
    background: linear-gradient(to bottom right, #1e3a8a, #155e75);
}
.dark .bg-white,
.dark .modal-responsive,
.dark .tracker-container,
.dark .stat-card,
.dark .tracker-list-item,
.dark [id$="-modal"] .bg-white {
    background-color: #1f2937;
}
.dark .bg-gray-50 { background-color: #111827; }
.dark .bg-gray-100,
.dark .bg-gray-200 { background-color: #374151; background-color: #4b5563; }
.dark .bg-blue-50,
.dark .bg-green-50,
.dark .bg-purple-50,
.dark .bg-orange-50 {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Границы */
.dark .border-gray-200,
.dark .border-gray-300 {
    border-color: #4b5563;
}
.dark .border-gray-200 { border-color: #374151; } /* Уточнение для некоторых элементов */

/* Текст */
.dark .text-gray-400,
.dark .text-gray-500,
.dark .text-gray-600,
.dark .text-gray-700 {
    color: #9ca3af;
}
.dark .text-gray-300 { color: #d1d5db; }
.dark .text-gray-900 { color: #f9fafb; }

/* Выравнивание текста в темной теме */
.dark .modal-content p,
.dark .modal-content .description-text,
.dark .card-description,
.dark .goal-section p,
.dark .tracker-container .goal-section p,
.dark .stat-card p.description,
.dark [class*="modal"] p:not(.text-center):not(.text-left):not(.text-right) {
    text-align: justify;
    text-justify: inter-word;
}

/* Исправление выравнивания заголовков в карточках */
.stat-card h3,
.stat-card h4,
.stat-card .font-semibold,
.tracker-list-item h3,
.tracker-list-item .font-semibold,
.modal-content h4,
.modal-content .font-semibold,
#privacy-modal h4,
#about-modal .grid h4,
#contact-modal h4,
#support-modal h4,
.category-option span:last-child {
    text-align: left !important;
}

/* Для иконок и текста в карточках категорий */
.modal-content .flex.items-center {
    text-align: left;
    justify-content: flex-start;
}

/* Заголовки внутри карточек статистики */
.stat-card .flex.items-center .text-gray-600 {
    text-align: left;
}

/* Оставляем по центру только основные заголовки */
h1, h2, h3.section-title,
.modal-content > h2,
.modal-content > h3 {
    text-align: center;
}

/* Компоненты в темной теме */
.dark .day-cell {
    background-color: #374151;
    border-color: #4b5563;
}
.dark .tracker-list-item {
    background-color: #1f2937;
}
.dark .tracker-list-item:hover {
    background-color: #374151;
}
.dark .goal-section {
    background-color: rgba(59, 130, 246, 0.1);
}
.dark input,
.dark select,
.dark textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}
.dark input:focus,
.dark select:focus,
.dark textarea:focus {
    border-color: #3b82f6;
    background-color: #4b5563;
}
.dark footer { background-color: #030712; }
.dark #mobile-menu { background-color: #1f2937; }


/* Языковой переключатель в темной теме */
.dark .language-btn {
    background-color: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}
.dark .language-btn:hover {
    background-color: #4b5563;
    border-color: #6b7280;
}
.dark .language-dropdown {
    background-color: #1f2937;
    border-color: #374151;
}
.dark .language-option:hover { background-color: #374151; }

/* Выбор цвета в темной теме */
.dark input[name="color"]:checked + .color-label {
    border-color: #f9fafb;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Уведомление в темной теме */
.dark #simple-notification { background-color: #374151; }

/* ===== Стили для графиков ===== */
.chart-container {
    transition: all 0.3s ease;
}

.stat-card .chart-container {
    opacity: 1;
}


/* Адаптивность для графиков */
@media (max-width: 640px) {
    .chart-container {
        height: 280px !important;
    }
    
    .grid-cols-1.lg\:grid-cols-2 {
        gap: 1rem;
    }
}

/* Стили для легенды в темной теме */
.dark .chart-legend {
    color: #e5e7eb;
}

/* Анимация появления графиков */
@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card canvas {
    animation: chartFadeIn 0.5s ease-out;
}

/* ===== Адаптивные стили ===== */
@media (min-width: 1024px) and (max-width: 1200px) {
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-card .w-12.h-12 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem !important;
        margin-right: 0.5rem !important;
    }
    
    .stat-card .w-12.h-12 i {
        font-size: 1.25rem !important;
    }
    
    .stat-card .text-gray-600.text-sm {
        font-size: 0.7rem;
    }
    
    .stat-card .text-lg.md\:text-xl.font-bold,
    .stat-card .text-2xl.md\:text-3xl.font-bold {
        font-size: 0.9rem !important;
    }
    
    #favorite-category {
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .language-switcher { position: static; }
    .language-dropdown {
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
    }
    .language-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 640px) {
    .modal-responsive {
        margin: 0.5rem !important;
        padding: 1rem !important;
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
    }
    .modal-responsive .p-6 { padding: 1rem !important; }
    .modal-responsive .text-2xl { font-size: 1.25rem !important; }

    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .day-cell {
        min-height: 5rem !important;
        padding: 0.5rem !important;
    }
    .check-box {
        width: 2.5rem !important;
        height: 2.5rem !important;
    }
}

@media (max-width: 480px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    .day-cell {
        min-height: 4.5rem !important;
        padding: 0.375rem !important;
    }
    .check-box {
        width: 2rem !important;
        height: 2rem !important;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.75rem;
    }
}

@media (min-width: 769px) {
    .calendar-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 1rem;
    }
}