/* ===== Базовые стили ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #1f2937;
    line-height: 1.6;
}

/* ===== Контейнеры ===== */
.container {
    max-width: 28rem;
    margin: 0 auto;
    padding: 1rem;
}

.card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

/* ===== Заголовки ===== */
h1, h2, h3 {
    color: #1f2937;
    font-weight: 700;
    margin-bottom: 1rem;
}

h1 {
    font-size: 1.875rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.125rem;
}

/* ===== Формы ===== */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: #4f46e5;
}

textarea {
    resize: vertical;
    min-height: 100px;
    padding: 0.5rem;
}

/* ===== Кастомные слайдеры ===== */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

output {
    display: inline-block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #4f46e5;
    margin-left: 0.5rem;
}

/* ===== Кнопки ===== */
button,
.btn {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ===== ИИ-совет блок ===== */
.ai-advice {
    background: #f3f4f6;
    border-left: 4px solid #10b981;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    white-space: pre-wrap;
    line-height: 1.8;
}

.ai-advice.loading {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

/* ===== Разделители ===== */
.divider {
    border-top: 2px solid #e5e7eb;
    margin: 1.5rem 0;
    padding-top: 1rem;
}

/* ===== Навигация ===== */
nav {
    background: white;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

nav a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

nav a:hover {
    color: #4338ca;
}

/* ===== Адаптивность ===== */
@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }
}

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

.card {
    animation: fadeIn 0.3s ease-out;
}

/* ===== Утилиты ===== */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* ===== Toast-уведомления ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

.toast.success {
    background: #10b981;
    color: white;
}

.toast.error {
    background: #ef4444;
    color: white;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Последняя запись ===== */
.latest-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
}

.latest-emoji {
    font-size: 3rem;
}

.latest-stats {
    flex: 1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.stat-row span {
    color: #6b7280;
}

.stat-row strong {
    color: #1f2937;
}

/* ===== История за неделю ===== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: translateX(4px);
}

.history-date {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    min-width: 60px;
}

.history-emoji {
    font-size: 1.5rem;
}

.history-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #374151;
}

/* ===== Утилиты ===== */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.text-sm {
    font-size: 0.875rem;
}

.text-gray-500 {
    color: #6b7280;
}

.text-center {
    text-align: center;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

/* По умолчанию скрываем ВСЁ — ждём, пока JS определит состояние */
.auth-only,
.guest-only {
    display: none;
}

/* Если JS определил, что пользователь авторизован */
html.authed .auth-only {
    display: list-item;
}

/* Если JS определил, что пользователь гость */
html.guest .guest-only {
    display: list-item;
}

/* Кнопка "Выйти" — стилизуем как ссылку */
#logoutBtn {
    cursor: pointer;
}
