@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ===== ГЛОБАЛЬНЫЕ ===== */
:root {
    --primary: #1A3B5C;
    --primary-light: #E8EEF4;
    --bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --text-primary: #1A1A2E;
    --text-secondary: #6B7280;
    --radius: 24px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-primary);
    padding-bottom: 100px;
    -webkit-font-smoothing: antialiased;
}

/* ===== КОНТЕЙНЕР ===== */
.container {
    max-width: 600px;
    padding: 0 20px;
    margin: 0 auto;
}

/* ===== КАРТОЧКИ ===== */
.card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: all 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* ===== ЗАГОЛОВКИ ===== */
h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

h1 .highlight {
    color: var(--primary);
}

h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.lead {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== КНОПКИ ===== */
.btn {
    border-radius: 60px !important;
    font-weight: 600;
    padding: 14px 28px !important;
    transition: all 0.2s ease;
    font-size: 16px;
    border: none;
}

.btn-primary {
    background: #1A3B5C !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(26, 59, 92, 0.25);
}

.btn-primary:hover {
    background: #152E4A !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 59, 92, 0.35);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-outline-primary {
    border: 2px solid #1A3B5C !important;
    color: #1A3B5C !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background: #1A3B5C !important;
    color: white !important;
}

.btn-lg {
    padding: 16px 32px !important;
    font-size: 18px;
}

.btn-block {
    width: 100%;
    display: block;
}

/* ===== ПОЛЯ ВВОДА ===== */
.form-control {
    border-radius: 16px !important;
    border: 2px solid #E5E7EB;
    padding: 14px 18px !important;
    font-size: 16px;
    background: var(--card-bg);
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.form-control:focus {
    border-color: #1A3B5C;
    box-shadow: 0 0 0 4px rgba(26, 59, 92, 0.1);
}

.form-control::placeholder {
    color: #A0AEC0;
    font-weight: 400;
}

.form-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-select {
    border-radius: 16px !important;
    border: 2px solid #E5E7EB;
    padding: 14px 18px !important;
    background-color: var(--card-bg);
    color: var(--text-primary);
}

/* ===== БЭЙДЖИ ===== */
.badge {
    border-radius: 40px !important;
    padding: 6px 16px !important;
    font-weight: 500;
    font-size: 13px;
}

.badge.bg-primary {
    background: #1A3B5C !important;
}

.badge-soft-success {
    background: #D1FAE5;
    color: #065F46;
}

.badge-soft-info {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-soft-warning {
    background: #FEF3C7;
    color: #92400E;
}

/* ===== НАВИГАЦИЯ ===== */
.navbar.bg-primary {
    background: #FFFFFF !important;
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.navbar-dark .nav-link {
    color: #1A3B5C !important;
    font-weight: 500;
    font-size: 14px;
}

.navbar-brand {
    font-weight: 700;
    font-size: 20px;
    color: #1A3B5C !important;
}

/* ===== НИЖНЕЕ МЕНЮ ===== */
.fixed-bottom {
    background: #FFFFFF !important;
    padding: 8px 0 12px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.fixed-bottom .nav-link {
    color: #1A3B5C !important;
    font-size: 11px;
}

/* ===== КАРТОЧКА СОВЕТА ===== */
.tip-card {
    background: #1A3B5C;
    color: white;
    border-radius: var(--radius);
    padding: 24px 28px;
    text-align: center;
}

.tip-card h5 {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.8;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tip-card p {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.6;
    margin: 0;
}

/* ================================================================ */
/* ===== ИКОНКИ — ВСЕГДА СИНИЕ ===== */
/* ================================================================ */

.nav-link img,
.navbar-brand img,
.card img:not(.btn img):not(.diary-entry img):not(#avatar-img):not(#avatar-fallback img):not([src*="user_"]):not([src*="post_"]),
a img:not(.btn img):not(.diary-entry img):not(#avatar-img):not([src*="user_"]):not([src*="post_"]),
.quick-link img {
    filter: brightness(0) saturate(100%) invert(58%) sepia(87%) saturate(1352%) hue-rotate(197deg) brightness(97%) contrast(93%);
}

.btn img {
    filter: brightness(0) saturate(100%) invert(58%) sepia(87%) saturate(1352%) hue-rotate(197deg) brightness(97%) contrast(93%);
}

.btn-primary img,
.btn-success img,
.btn-danger img,
.btn-outline-primary:hover img,
.btn-outline-success:hover img,
.btn-outline-danger:hover img,
.tip-card img {
    filter: brightness(0) invert(1) !important;
}

#theme-icon,
#theme-icon-mobile,
.navbar-brand img {
    filter: none !important;
}

.diary-entry .ai-label img {
    filter: none !important;
}

#avatar-img,
#avatar-fallback img,
img[src*="user_"],
img[src*="post_"] {
    filter: none !important;
}

/* ================================================================ */
/* ===== СПИННЕР ЗАГРУЗКИ ===== */
/* ================================================================ */

.loading-spinner {
    display: none;
}

.loading-spinner.active {
    display: block;
    text-align: center;
    padding: 20px;
}

.spinner-border {
    width: 40px;
    height: 40px;
    border-width: 4px;
    color: #1A3B5C !important;
}

/* ===== ОНБОРДИНГ ===== */
.onboarding-step {
    display: none;
    animation: fadeIn 0.4s ease;
}

.onboarding-step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== ПРИВЫЧКИ ===== */
.habit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: 14px;
    margin-bottom: 8px;
}

.habit-item .form-check-input {
    width: 22px;
    height: 22px;
    border-radius: 8px !important;
    border: 2px solid #CBD5E0;
    cursor: pointer;
}

.habit-item .form-check-input:checked {
    background-color: #1A3B5C;
    border-color: #1A3B5C;
}

/* ===== КАРТОЧКА ЗАПИСИ ДНЕВНИКА ===== */
.diary-entry {
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    border-left: 4px solid #1A3B5C;
}

.diary-entry .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.diary-entry .user-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.diary-entry .ai-response {
    background: var(--bg);
    padding: 14px 18px;
    border-radius: 14px;
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.6;
}

.diary-entry .ai-response .ai-label {
    font-weight: 600;
    color: #1A3B5C;
}

/* ================================================================ */
/* ===== ТЁМНАЯ ТЕМА ===== */
/* ================================================================ */

body.dark-theme {
    --bg: #12121E;
    --card-bg: #1A1A2E;
    --text-primary: #FFFFFF;
    --text-secondary: #BBBBBB;
    color: #FFFFFF;
}

body.dark-theme .navbar.bg-primary {
    background: #1A1A2E !important;
}

body.dark-theme .fixed-bottom {
    background: #1A1A2E !important;
}

body.dark-theme .navbar-dark .nav-link {
    color: #FFFFFF !important;
}

body.dark-theme .navbar-brand {
    color: #FFFFFF !important;
}

body.dark-theme .fixed-bottom .nav-link {
    color: #FFFFFF !important;
}

body.dark-theme .tip-card {
    background: #0F2A45;
}

body.dark-theme .form-control {
    background: #1A1A2E;
    color: #FFFFFF;
    border-color: #2D2D4A;
}

body.dark-theme .form-control::placeholder {
    color: #888888;
}

body.dark-theme .form-select {
    background-color: #1A1A2E;
    color: #FFFFFF;
    border-color: #2D2D4A;
}

body.dark-theme .form-label {
    color: #CCCCCC;
}

body.dark-theme .form-check-label {
    color: #CCCCCC;
}

body.dark-theme .habit-item {
    background: #12121E;
    color: #FFFFFF;
}

body.dark-theme .diary-entry .ai-response {
    background: #12121E;
    color: #FFFFFF;
}

body.dark-theme .btn-primary {
    background: #0F2A45 !important;
}

body.dark-theme .btn-primary:hover {
    background: #0A1F35 !important;
}

body.dark-theme .btn-outline-primary {
    border-color: #CCCCCC !important;
    color: #CCCCCC !important;
}

body.dark-theme .btn-outline-primary:hover {
    background: #4A8DF8 !important;
    color: #FFFFFF !important;
}

body.dark-theme .btn-outline-secondary {
    border-color: #888888 !important;
    color: #BBBBBB !important;
}

body.dark-theme .btn-outline-info {
    border-color: #4A8DF8 !important;
    color: #4A8DF8 !important;
}

body.dark-theme .btn-outline-success {
    border-color: #4ADE80 !important;
    color: #4ADE80 !important;
}

body.dark-theme .badge.bg-primary {
    background: #0F2A45 !important;
}

body.dark-theme .badge.bg-secondary {
    background: #2A2A5E !important;
    color: #FFFFFF !important;
}

body.dark-theme .badge.bg-info {
    background: #1A3A5E !important;
    color: #FFFFFF !important;
}

body.dark-theme .text-muted {
    color: #BBBBBB !important;
}

body.dark-theme small {
    color: #CCCCCC;
}

body.dark-theme strong {
    color: #FFFFFF;
}

body.dark-theme a {
    color: #4A8DF8;
}

body.dark-theme a.text-dark {
    color: #FFFFFF !important;
}

body.dark-theme a.text-muted {
    color: #BBBBBB !important;
}

body.dark-theme .table {
    color: #FFFFFF;
}

body.dark-theme .table th {
    background: #0F2A45;
    color: #FFFFFF;
}

body.dark-theme .table td {
    color: #FFFFFF;
}

body.dark-theme .alert-light {
    background-color: #1A1A2E;
    color: #FFFFFF;
    border-color: #2D2D4A;
}

body.dark-theme .bg-light {
    background-color: #1A1A2E !important;
    color: #FFFFFF !important;
}

body.dark-theme .progress {
    background-color: #1A1A2E;
}

body.dark-theme .border-start {
    border-left-color: #2D2D4A !important;
}

body.dark-theme .border-top {
    border-top-color: #2D2D4A !important;
}

body.dark-theme .nav-link {
    color: #FFFFFF !important;
}

body.dark-theme .navbar-brand {
    color: #FFFFFF !important;
}

body.dark-theme .spinner-border {
    color: #4A8DF8 !important;
}

body.dark-theme hr {
    border-color: #2D2D4A;
}

body.dark-theme .nav-link img,
body.dark-theme .btn img,
body.dark-theme .card img:not(.navbar-brand img):not(#avatar-img):not(#avatar-fallback img):not([src*="user_"]):not([src*="post_"]) {
    filter: brightness(0) invert(1) !important;
}

body.dark-theme strong {
    color: #FFFFFF !important;
}

body.dark-theme .card h4,
body.dark-theme .card p {
    color: #FFFFFF !important;
}

body.dark-theme .text-dark {
    color: #FFFFFF !important;
}

body.dark-theme #theme-icon,
body.dark-theme #theme-icon-mobile {
    filter: none !important;
}

body.dark-theme .text-dark,
body.dark-theme a.text-dark,
body.dark-theme strong,
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5,
body.dark-theme h6,
body.dark-theme .card strong,
body.dark-theme .navbar-brand,
body.dark-theme .nav-link {
    color: #FFFFFF !important;
}

body.dark-theme img {
    filter: brightness(0) invert(1) !important;
}

body.dark-theme img[src*="user_"],
body.dark-theme img[src*="post_"],
body.dark-theme #theme-icon,
body.dark-theme #theme-icon-mobile,
body.dark-theme .navbar-brand img {
    filter: none !important;
}

/* ===== АДАПТИВ ===== */
@media (max-width: 768px) {
    h1 { font-size: 24px; }
    .container { padding: 0 16px; }
    .card { padding: 16px 18px; }
    .btn { font-size: 15px; padding: 12px 24px !important; }
    .tip-card p { font-size: 16px; }
}

/* ===== IPHONE ОПТИМИЗАЦИЯ ===== */
@media (max-width: 430px) {
    body {
        padding-bottom: 80px;
    }
    
    main.container {
        padding-bottom: 20px !important;
    }
    
    .fixed-bottom {
        padding: 6px 0 8px;
    }
    
    .fixed-bottom .nav-link {
        font-size: 10px;
    }
    
    .fixed-bottom img {
        width: 18px;
        height: 18px;
    }
    
    .card {
        padding: 16px 14px;
        margin-bottom: 12px;
    }
    
    .btn {
        padding: 12px 20px !important;
        font-size: 14px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .lead {
        font-size: 14px;
    }
    
    .tip-card {
        padding: 16px 18px;
    }
    
    .tip-card p {
        font-size: 14px;
    }
    
    .card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .btn:hover {
        transform: none;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    input, textarea, select {
        font-size: 16px !important;
    }
}

@supports (padding: max(0px)) {
    .fixed-bottom {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ===== ИКОНКИ В НАВИГАЦИИ — НЕ ИНВЕРТИРОВАТЬ ===== */
.nav-link img,
.fixed-bottom img,
.navbar-brand img {
    filter: none !important;
}

body.dark-theme .nav-link img,
body.dark-theme .fixed-bottom img,
body.dark-theme .navbar-brand img {
    filter: none !important;
}