/* Сброс стилей и базовые настройки */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.2s ease-in-out;
    /* weekday sticky variables removed */
}

/* Dark theme variables */
[data-theme='dark'] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --success-color: #22c55e;
    --error-color: #f87171;
    --warning-color: #fbbf24;
    --background-color: #0b1220;
    --surface-color: #0f172a;
    --text-primary: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #1f2937;
    --border-hover: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.7);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.7), 0 2px 4px -2px rgb(0 0 0 / 0.7);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7), 0 4px 6px -4px rgb(0 0 0 / 0.7);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Навигация */
.navbar {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand:hover {
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary-color);
    background-color: var(--background-color);
}

.nav-link-danger {
    color: var(--error-color);
    border-color: #fecaca;
}
.nav-link-danger:hover {
    background: #fef2f2;
}

.user-label {
    cursor: default;
}

/* Основной контент */
.main-content {
    min-height: calc(100vh - 80px);
    padding: 2rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Главная страница */
.hero-section {
    text-align: center;
    padding: 4rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e40af 100%);
    color: white;
    margin-bottom: 4rem;
}

.hero-content {
    max-width: 600px;
    margin: 0 auto;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-description {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.hero-actions {
    margin-top: 2rem;
}

/* Секция возможностей */
.features-section {
    padding: 4rem 0;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 1.5rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--background-color);
    border-color: var(--border-hover);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
}

/* Авторизация */
.auth-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
    padding: 2rem 1.5rem;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-form {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
    font-family: inherit;
}

/* Inputs in dark theme */
[data-theme='dark'] .form-group input:not([type="checkbox"]):not([type="radio"]),
[data-theme='dark'] .form-group textarea,
[data-theme='dark'] select,
[data-theme='dark'] input[type="time"],
[data-theme='dark'] input[type="date"] {
    background: #0b1220;
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme='dark'] .form-group input:not([type="checkbox"]):not([type="radio"]):focus,
[data-theme='dark'] .form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.25);
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Checkbox compact layout */
.form-group input[type="checkbox"] {
    width: auto;
    height: 16px;
    margin: 0;
}

.form-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.auth-help {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.auth-help h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.auth-help ol {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding-left: 1rem;
}

.auth-help li {
    margin-bottom: 0.25rem;
}

.auth-help code {
    background: var(--background-color);
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Календарь */
.calendar-section {
    padding: 0 1.5rem;
}

.calendar-container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.calendar-toolbar {
    position: sticky;
    top: 0; /* закрепляем у верхней границы окна */
    background: var(--surface-color);
    z-index: 10;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.calendar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
}

.calendar-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.calendar-actions-hint {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
}

.calendar-grid {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--background-color);
}

.weekday {
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
}

.weekday:last-child {
    border-right: none;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    aspect-ratio: 1;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: var(--surface-color);
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day:hover {
    background: var(--background-color);
}

.calendar-day.today {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
}

.calendar-day.other-month {
    color: var(--text-muted);
    background: var(--background-color);
}

.calendar-day.has-tasks {
    border-left: 4px solid var(--primary-color);
}

.day-number {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.tasks-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--background-color);
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    align-self: flex-start;
    margin-top: auto;
}

.calendar-day.today .tasks-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-in-out;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.2s ease-in-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

/* Tabs inside settings modal */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-secondary);
    cursor: pointer;
}
.tab-btn:hover {
    background: var(--background-color);
}
.tab-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
.tab-pane .list .list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.tab-pane .list .list-item:last-child {
    border-bottom: none;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-actions .btn {
    flex: 1;
}

/* Список задач */
.task-item {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.task-item:hover {
    box-shadow: var(--shadow-sm);
}

.task-item.editing {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.task-title {
    font-weight: 600;
    color: var(--text-primary);
}

.task-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.task-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
}

.task-actions .btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

.btn .fa-spinner { margin-right: 6px; }

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition);
    z-index: 50;
}

.fab:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Уведомления */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-error {
    background: rgba(220, 38, 38, 0.15);
    color: #fecaca;
    border: 1px solid rgba(220,38,38,0.35);
}

.alert-success {
    background: rgba(34,197,94,0.15);
    color: #bbf7d0;
    border: 1px solid rgba(34,197,94,0.35);
}

/* Additional dark theme refinements */
[data-theme='dark'] .calendar-day:hover,
[data-theme='dark'] .btn-secondary:hover,
[data-theme='dark'] .nav-link:hover {
    background: #111827;
}
[data-theme='dark'] .calendar-weekdays {
    background: #111827;
}
[data-theme='dark'] .task-item {
    background: #0b1220;
}
[data-theme='dark'] .task-time {
    background: #111827;
}
[data-theme='dark'] .tasks-count {
    background: #111827;
    color: var(--text-secondary);
}
[data-theme='dark'] .calendar-day.today {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .nav-container {
        padding: 1rem;
    }
    
    .nav-menu {
        gap: 1rem;
    }
    
    .nav-link {
        padding: 0.5rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .calendar-container {
        padding: 1rem;
        margin: 0 0.5rem;
    }
    
    .calendar-header {
        gap: 1rem;
    }
    
    .calendar-header h2 {
        font-size: 1.25rem;
        min-width: 150px;
    }
    
    .calendar-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .calendar-day {
        min-height: 80px;
        padding: 0.5rem;
    }
    
    .modal-content {
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body {
        padding: 1rem;
    }
    
    .fab {
        bottom: 1rem;
        right: 1rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .calendar-days {
        font-size: 0.75rem;
    }
    
    .calendar-day {
        min-height: 60px;
        padding: 0.25rem;
    }
    
    .weekday {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}