/* ========================================
   ROOT VARIABLES (цвета, отступы, шрифты)
   ======================================== */
:root {
    /* Основные цвета */
    --primary-light: #f8c9d4;
    --primary-dark: #fcd9e5;
    --bg-main: #fef7f2;
    --text-dark: #2d2a2e;
    --text-muted: #5e3e4b;
    --accent: #cd7c9b;
    --accent-dark: #b35d7c;
    --accent-hover: #e06c8c;
    --card-bg: #ffffff;
    --border-light: #ffefe8;
    --badge-bg: #fff0e8;
    --tip-bg: #fffaf5;
    --warning-bg: #fff5f0;
    
    /* Тени и радиусы */
    --radius-sm: 16px;
    --radius-md: 24px;
    --radius-lg: 28px;
    --radius-xl: 60px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.02);
    
    /* Шрифты */
    --font-main: 'Inter', sans-serif;
}

/* ========================================
   GLOBAL STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.5;
    padding-bottom: 80px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 18px;
}

/* ========================================
   HEADER / HERO
   ======================================== */
.hero {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%);
    border-radius: 0 0 32px 32px;
    padding: 24px 20px 32px 20px;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #4a2c3a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hero h1 i {
    background: rgba(255,255,255,0.8);
    padding: 8px;
    border-radius: 60px;
    font-size: 1.4rem;
    color: var(--accent-dark);
}

.hero p {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.badge {
    background: var(--badge-bg);
    display: inline-block;
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-dark);
    margin-top: 12px;
}

/* ========================================
   CARDS
   ======================================== */
.card, .section-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    animation: fadeInUp 0.3s ease backwards;
}

.card-header, .section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 2px dotted #ffe0d6;
    padding-bottom: 12px;
}

.card-header i, .section-header i {
    font-size: 1.5rem;
    color: var(--accent);
    background: #fff2ec;
    padding: 10px;
    border-radius: 24px;
}

.card-header h2, .section-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #4a2c3a;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.btn-help, .btn-tool, .nav-btn, .back-button, .calc-btn {
    background: #fbeae8;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-xl);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #9f5879;
    cursor: pointer;
    transition: 0.2s;
}

.btn-help:active, .btn-tool:active, .nav-btn:active, .calc-btn:active {
    background: #f0dbd6;
    transform: scale(0.97);
}

.calc-btn {
    background: var(--accent-hover);
    color: white;
    justify-content: center;
    width: 100%;
}

.calc-btn:active {
    background: #c95778;
}

/* Плавающая кнопка дома */
.floating-home-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: var(--accent-hover);
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(224, 108, 140, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1000;
    border: none;
    font-size: 1.6rem;
}

.floating-home-btn:active {
    transform: scale(0.92);
    background: #c95778;
}

/* ========================================
   SERVICE & TIP LISTS
   ======================================== */
.service-list, .tip-list, .topics-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.service-item, .tip-item, .topic-card {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: 0.2s;
}

.service-item, .tip-item {
    border-bottom: 1px solid #faf0ea;
}

.topic-card {
    background: white;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.topic-card:active {
    background: #fef0ea;
    transform: scale(0.98);
}

.service-item i, .tip-item i, .topic-card i {
    width: 28px;
    color: var(--accent);
    font-size: 1.2rem;
    text-align: center;
}

/* ========================================
   EMERGENCY BLOCK
   ======================================== */
.emergency {
    background: #ffefea;
    border-left: 8px solid var(--accent-hover);
    border-radius: var(--radius-md);
}

.contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.phone-number {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #b9496f;
}

.call-btn {
    background: var(--accent-hover);
    border: none;
    padding: 12px 18px;
    border-radius: var(--radius-xl);
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ========================================
   CALCULATOR STYLES
   ======================================== */
.calculator-card {
    background: #fffaf5;
    border-radius: 20px;
    padding: 16px;
    margin: 16px 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--accent-dark);
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ffe0d6;
    border-radius: var(--radius-xl);
    font-family: inherit;
    font-size: 1rem;
    background: white;
    outline: none;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent);
}

.result-box {
    background: #fef0e8;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    margin-top: 16px;
}

.result-date, .result-bmi {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-hover);
    margin: 10px 0;
}

.tip-box, .warning-box {
    background: var(--tip-bg);
    border-left: 4px solid #f3bfcf;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.warning-box {
    background: var(--warning-bg);
    border-left-color: var(--accent-hover);
}

/* ========================================
   BOTTOM NAVIGATION
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 20px 22px;
    border-top: 1px solid #ffe0d6;
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #ab8a96;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item.active {
    color: var(--accent);
    font-weight: 600;
}

/* ========================================
   MODAL
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    width: 85%;
    max-width: 320px;
    border-radius: 48px;
    padding: 28px 20px 32px;
    text-align: center;
    animation: fadeUp 0.2s ease;
}

.modal-content i {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 12px;
}

.modal-content h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: #4a2c3a;
}

.close-modal {
    background: #f1dfda;
    border: none;
    padding: 12px 0;
    width: 100%;
    border-radius: var(--radius-xl);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    color: #9f5879;
}

/* ========================================
   DAILY TIP
   ======================================== */
.daily-tip {
    background: var(--tip-bg);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-style: italic;
    font-weight: 500;
    border-left: 6px solid #f3bfcf;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}

.daily-tip:active {
    background: #f5e6e0;
}

/* ========================================
   SEARCH BOX
   ======================================== */
.search-box {
    background: white;
    border-radius: var(--radius-xl);
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #ffe0d6;
}

.search-box i {
    color: var(--accent);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .container {
        padding: 12px 16px;
    }
    .hero h1 {
        font-size: 1.6rem;
    }
    .phone-number {
        font-size: 1.3rem;
    }
    .result-date, .result-bmi {
        font-size: 1.4rem;
    }
}

/* ========================================
   DARK THEME (опционально)
   ======================================== */
body.dark-theme {
    --bg-main: #1a1520;
    --card-bg: #2d2430;
    --text-dark: #f0e6ea;
    --border-light: #3d2e3a;
    --tip-bg: #2d2430;
    --badge-bg: #3d2e3a;
}

/* ========================================
   СПЕЦИФИЧНЫЕ СТИЛИ ДЛЯ БАЗЫ ЗНАНИЙ И КАЛЬКУЛЯТОРОВ
   ======================================== */

/* Темы базы знаний */
.topic-card {
    background: white;
    border-radius: 20px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #ffefe8;
    margin-bottom: 10px;
}

.topic-card:active {
    background: #fef0ea;
    transform: scale(0.98);
}

.topic-number {
    background: #fbeae8;
    border-radius: 40px;
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #b35d7c;
}

.topic-content {
    flex: 1;
}

.topic-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #2d2a2e;
}

.topic-sub {
    font-size: 0.7rem;
    color: #cba7b4;
    margin-top: 4px;
}

.topic-arrow {
    color: #cd7c9b;
}

.back-button {
    background: #fbeae8;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #9f5879;
    cursor: pointer;
    margin-bottom: 20px;
}

.back-button:active {
    background: #f0dbd6;
    transform: scale(0.97);
}

/* Калькуляторы */
.method-group {
    margin-bottom: 16px;
}

.result-date, .result-bmi {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e06c8c;
    margin: 10px 0;
}

.calc-btn {
    background: #e06c8c;
    color: white;
    width: 100%;
    padding: 14px;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.calc-btn:active {
    background: #c95778;
    transform: scale(0.97);
}

/* Категории ИМТ */
.category-underweight { color: #4a90e2; }
.category-normal { color: #2e7d32; }
.category-overweight { color: #f5a623; }
.category-obese { color: #e85d8e; }

/* Навигация по темам в BD */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    gap: 12px;
}

.nav-topic-btn {
    background: #fbeae8;
    border: none;
    padding: 10px 16px;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.85rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #9f5879;
    cursor: pointer;
    transition: 0.2s;
}

.nav-topic-btn:active {
    background: #f0dbd6;
    transform: scale(0.97);
}

.back-to-list {
    background: #e06c8c;
    color: white;
    margin-top: 20px;
    width: 100%;
    justify-content: center;
}

.back-to-list:active {
    background: #c95778;
}

/* Контент тем */
.topic-content {
    font-size: 1rem;
    line-height: 1.6;
}

.topic-content h2 {
    color: #4a2c3a;
    margin: 20px 0 12px 0;
    font-size: 1.4rem;
}

.topic-content h3 {
    color: #b35d7c;
    margin: 16px 0 8px 0;
    font-size: 1.2rem;
}

.topic-content p {
    margin-bottom: 12px;
}

.topic-content ul, .topic-content ol {
    margin: 10px 0 15px 25px;
}

.topic-content li {
    margin-bottom: 6px;
}

/* ========================================
   МЕДИЦИНСКАЯ КАРТА - МОДАЛЬНЫЕ ОКНА И КНОПКИ
   ======================================== */

/* Стили для модальных окон медицинской карты */
.med-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

.med-modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 28px;
    padding: 28px 24px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: fadeUp 0.2s ease;
}

.med-modal-content h3 {
    font-size: 1.4rem;
    color: #4a2c3a;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px dotted #ffe0d6;
}

.med-modal-content label {
    display: block;
    font-weight: 600;
    color: #b35d7c;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.med-modal-content input,
.med-modal-content select,
.med-modal-content textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ffe0d6;
    border-radius: 60px;
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 1rem;
    background: white;
    transition: 0.2s;
}

.med-modal-content input:focus,
.med-modal-content select:focus,
.med-modal-content textarea:focus {
    outline: none;
    border-color: #cd7c9b;
    box-shadow: 0 0 0 3px rgba(205,124,155,0.1);
}

.med-modal-content textarea {
    border-radius: 20px;
    resize: vertical;
}

/* Кнопки в модальных окнах */
.med-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.med-btn-save {
    background: #e06c8c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 60px;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    flex: 1;
    transition: 0.2s;
}

.med-btn-save:hover {
    background: #c95778;
    transform: scale(0.98);
}

.med-btn-cancel {
    background: #fbeae8;
    color: #9f5879;
    border: none;
    padding: 12px 24px;
    border-radius: 60px;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    flex: 1;
    transition: 0.2s;
}

.med-btn-cancel:hover {
    background: #f0dbd6;
    transform: scale(0.98);
}

/* Кнопки добавления записей */
.med-add-btn {
    background: #fbeae8;
    border: none;
    padding: 10px 20px;
    border-radius: 60px;
    color: #9f5879;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    margin-bottom: 16px;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.med-add-btn:hover {
    background: #f0dbd6;
    transform: scale(0.98);
}

/* Кнопка удаления */
.med-delete-btn {
    background: none;
    border: none;
    color: #c62828;
    cursor: pointer;
    font-size: 1rem;
    padding: 6px;
    border-radius: 50%;
    transition: 0.2s;
}

.med-delete-btn:hover {
    background: #ffebee;
    transform: scale(1.1);
}

/* Таблицы медицинской карты */
.med-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.med-table th {
    padding: 12px 8px;
    text-align: left;
    color: #ab8a96;
    font-weight: 600;
    font-size: 0.75rem;
    border-bottom: 2px solid #ffe0d6;
}

.med-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #faf0ea;
    font-size: 0.85rem;
    color: #4a2c3a;
}

.med-table tr:hover {
    background: #fffaf5;
}

/* Вкладки медицинской карты */
.med-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 2px dotted #ffe0d6;
    padding-bottom: 12px;
}

.med-tab {
    background: #fbeae8;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    color: #9f5879;
    transition: 0.2s;
}

.med-tab.active {
    background: #e06c8c;
    color: white;
}

.med-tab-content {
    display: none;
}

.med-tab-content.active {
    display: block;
}

/* Карточки информации */
.med-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.med-info-card {
    background: #fffaf5;
    border-radius: 20px;
    padding: 16px;
    border: 1px solid #ffe0d6;
}

.med-info-card h4 {
    color: #4a2c3a;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ffe0d6;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Бейджи для списков */
.med-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.med-badge-item {
    background: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid #ffe0d6;
}

/* ========================================
   КНОПКИ НАЗАД ДЛЯ МЕДИЦИНСКОЙ КАРТЫ
   ======================================== */
.back-link {
    background: #fbeae8;
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    color: #9f5879;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: 0.2s;
}

.back-link:hover {
    background: #f0dbd6;
    transform: scale(0.98);
}

.floating-back-btn {
    position: fixed;
    bottom: 90px;
    left: 20px;
    background: #fbeae8;
    padding: 14px 24px;
    border-radius: 50px;
    text-decoration: none;
    color: #9f5879;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: 0.2s;
}

.floating-back-btn:hover {
    background: #f0dbd6;
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .floating-back-btn {
        bottom: 100px;
        left: 16px;
        padding: 12px 20px;
        font-size: 0.85rem;
    }
}