/* Базовые стили */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #FFC107;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;
    --background-color: #ffffff;
    --surface-color: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --background-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-light: 0 1px 3px rgba(0,0,0,0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: hidden;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Экраны */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.auth-container {
    text-align: center;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
}

.logo h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.logo p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 3rem;
}

.telegram-webapp-auth,
.telegram-login-widget {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
}

.telegram-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.telegram-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

/* Стили для Telegram Login Widget */
.telegram-login-widget iframe {
    border-radius: var(--border-radius) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    transition: var(--transition) !important;
}

.telegram-login-widget iframe:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2) !important;
}

/* Главный экран */
.main-screen {
    background-color: var(--background-color);
}

/* Шапка */
.header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.settings-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.settings-btn:hover {
    background-color: var(--border-color);
    color: var(--primary-color);
}

/* Основной контент */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Индикаторы вкладок */
.tab-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--surface-color);
}

.tab-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.tab-indicator.active {
    background-color: var(--primary-color);
    transform: scale(1.2);
}

/* Контейнер вкладок */
.tabs-container {
    display: flex;
    width: 300%;
    height: calc(100vh - 140px);
    transform: translateX(-33.333%);
    transition: transform 0.3s ease;
}

.tabs-container.tab-0 {
    transform: translateX(0);
}

.tabs-container.tab-1 {
    transform: translateX(-33.333%);
}

.tabs-container.tab-2 {
    transform: translateX(-66.666%);
}

.tab-content {
    width: 33.333%;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Заголовки вкладок */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.add-task-btn {
    background-color: var(--primary-color);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-light);
}

.add-task-btn:hover {
    background-color: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

/* Прогресс дня */
.daily-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.daily-progress-bar {
    width: 100px;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.daily-progress-fill {
    height: 100%;
    background-color: var(--success-color);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Статистика выполненных */
.completed-stats {
    font-weight: 600;
    color: var(--success-color);
}

/* Список задач */
.tasks-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Карточка задачи */
.task-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
    touch-action: pan-y;
}

.task-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.task-card.dragging {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 10;
}

.task-card.completed {
    opacity: 0.7;
    background-color: var(--success-color);
    color: white;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.task-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    flex: 1;
}

.task-priority {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.task-priority.low {
    background-color: #e3f2fd;
    color: #1976d2;
}

.task-priority.medium {
    background-color: #fff3e0;
    color: #f57c00;
}

.task-priority.high {
    background-color: #ffebee;
    color: #d32f2f;
}

.task-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.task-due-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.task-due-date.overdue {
    color: var(--error-color);
    font-weight: 600;
}

/* Прогресс-бар задачи */
.task-progress {
    position: relative;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
    cursor: pointer;
    touch-action: pan-x;
}

.task-progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.task-progress-collaborative {
    display: flex;
    height: 100%;
}

.task-progress-segment {
    height: 100%;
    transition: width 0.3s ease;
    position: relative;
}

.task-progress-segment:not(:last-child) {
    margin-right: 2px;
}

/* Подзадачи */
.task-subtasks {
    margin-top: 1rem;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.subtask-item:last-child {
    border-bottom: none;
}

.subtask-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.subtask-checkbox.checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.subtask-checkbox.checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.subtask-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.subtask-text.completed {
    text-decoration: line-through;
    opacity: 0.6;
}

.subtask-assignee {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    background-color: var(--border-color);
    color: var(--text-secondary);
}

/* Коллаборативные элементы */
.task-collaborators {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.collaborator-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--background-color);
    object-fit: cover;
}

.collaborator-avatar:not(:first-child) {
    margin-left: -8px;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Модальные окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 1rem;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Формы */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--background-color);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Кнопки */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--text-secondary);
    color: white;
}

/* Настройки */
.settings-group {
    margin-bottom: 2rem;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.help-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: normal;
    line-height: 1.5;
    background-color: var(--surface-color);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
}

/* Выбор задач на день */
.daily-limit-text {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.daily-tasks-select {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.daily-task-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.daily-task-option:last-child {
    border-bottom: none;
}

.daily-task-option:hover {
    background-color: var(--surface-color);
}

.daily-task-option.selected {
    background-color: rgba(33, 150, 243, 0.1);
    border-left: 4px solid var(--primary-color);
}

.daily-task-checkbox {
    margin-right: 1rem;
}

.daily-task-info {
    flex: 1;
}

.daily-task-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.daily-task-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1100;
    transform: translateX(400px);
    transition: var(--transition);
    max-width: 350px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--error-color);
}

.notification.warning {
    border-left: 4px solid var(--warning-color);
}

.notification-text {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Лоадер */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.loader.show {
    opacity: 1;
    visibility: visible;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Адаптивность */
@media (max-width: 768px) {
    .header-content {
        padding: 0;
    }
    
    .tab-content {
        padding: 0.75rem;
    }
    
    .task-card {
        padding: 1rem;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 2.5rem;
    }
    
    .tab-header h2 {
        font-size: 1.3rem;
    }
    
    .task-title {
        font-size: 1rem;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

/* Анимации */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.task-card.slide-in {
    animation: slideInUp 0.3s ease;
}

.task-card.slide-out {
    animation: slideOutRight 0.3s ease;
}

/* Touch стили */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: none;
}

.touch-feedback.active::after {
    width: 200px;
    height: 200px;
}