/* Цветовая палитра */
:root {
    --brand-color: #397DFF;
    --text-base: #393B55;
    --text-secondary: #737484;
    --success: #4AD280;
    --error: #FF555F;
    --warning1: #F9931A;
    --warning2: #F9CA3E;
    --bg-white: #FFFFFF;
    --bg-light: #F5F5F7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-base);
    line-height: 1.6;
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    padding-bottom: 100px;
}

.screen.active {
    display: block;
}

#chat-screen {
    padding: 0;
    padding-bottom: 0;
}

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

/* Логотип */
.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    max-width: 120px;
    height: auto;
}

.logo-small {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.logo-small img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Заголовки */
.greeting {
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-base);
}

.menu-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-base);
}

h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-base);
    margin-bottom: 20px;
}

/* Текст согласия */
.consent-text {
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 15px;
    color: var(--text-base);
}

.consent-hint {
    font-size: 14px;
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-secondary);
}

/* Кнопки */
.btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.btn-primary:hover {
    background-color: #2d5fcc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(57, 125, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Заголовок с кнопкой назад */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    position: relative;
}

/* Специальный стиль для header в главном меню (с логотипом и аватаркой) */
#main-menu-screen .header {
    justify-content: space-between;
    gap: 0;
}

.header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-base);
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--brand-color);
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.back-btn:hover {
    opacity: 0.7;
}

.back-btn:active {
    opacity: 0.5;
}

.profile-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.profile-btn-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-base);
}

/* Для header в главном меню - без абсолютной позиции */
#main-menu-screen .header .profile-btn {
    position: static;
}

/* Для других экранов, где нужна абсолютная позиция */
.header .profile-btn {
    position: absolute;
    right: 0;
    z-index: 10;
}

.profile-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--brand-color);
    transition: transform 0.2s ease;
}

.profile-avatar-btn:hover {
    transform: scale(1.1);
}

.profile-avatar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--brand-color);
    box-shadow: 0 4px 12px rgba(57, 125, 255, 0.2);
}

/* Форма */
.form {
    background: var(--bg-white);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-base);
}

.form-group input {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border: 2px solid #E0E0E0;
    border-radius: 10px;
    font-family: inherit;
    transition: border-color 0.3s ease;
    color: var(--text-base);
}

.form-group input:focus {
    outline: none;
    border-color: var(--brand-color);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.form-group input.error {
    border-color: var(--error);
}

.form-group input.error:focus {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(255, 85, 95, 0.1);
}

/* Автодополнение городов */
.form-group {
    position: relative;
}

.city-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 2px solid #E0E0E0;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: -2px;
}

.city-suggestion-item {
    padding: 12px 14px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-base);
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #F5F5F7;
}

.city-suggestion-item:last-child {
    border-bottom: none;
}

.city-suggestion-item:hover,
.city-suggestion-item.selected {
    background-color: #F0F5FF;
    color: var(--brand-color);
}

.city-suggestion-item strong {
    font-weight: 600;
    color: var(--brand-color);
}

/* Меню */
.menu-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.menu-item {
    background: var(--bg-white);
    border: 2px solid #E0E0E0;
    padding: 18px 20px;
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-base);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-item::after {
    content: '›';
    color: var(--text-secondary);
    font-size: 20px;
    font-weight: 300;
}

.menu-item:hover {
    border-color: var(--brand-color);
    background-color: #F0F5FF;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(57, 125, 255, 0.15);
}

.menu-item:active {
    transform: translateY(0);
}

.menu-item-primary-wrapper {
    position: relative;
    margin-top: 8px;
}

.menu-item-primary {
    background-color: var(--brand-color);
    color: white;
    border-color: var(--brand-color);
    font-weight: 600;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 17px;
    width: 100%;
}

.menu-item-primary::after {
    display: none;
}

.menu-item-badge {
    position: absolute;
    right: -8px;
    top: -8px;
    background-color: var(--error);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(255, 85, 95, 0.4);
    border: 2px solid white;
    z-index: 10;
}

.menu-item-badge:empty {
    display: none;
}

.menu-item-primary:hover {
    background-color: #2d5fcc;
    border-color: #2d5fcc;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(57, 125, 255, 0.3);
}

.menu-item-icon {
    font-size: 20px;
}

/* Чат */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
}

.chat-header {
    background: var(--bg-white);
    padding: 16px 20px;
    border-bottom: 1px solid #E0E0E0;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-header .back-btn {
    padding: 4px 8px;
    font-size: 24px;
    color: var(--brand-color);
}

.chat-header-content {
    flex: 1;
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-base);
}

.operator-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    display: inline-block;
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-messages {
    flex: 1;
    background: var(--bg-white);
    padding: 20px;
    padding-bottom: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 75%;
    word-wrap: break-word;
    position: relative;
    line-height: 1.4;
}

.message-text {
    margin: 0;
    white-space: pre-wrap !important;
    word-break: break-word;
}

.message.user {
    background-color: var(--brand-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.operator {
    background-color: #F5F5F7;
    color: var(--text-base);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.system {
    background-color: transparent;
    color: var(--text-secondary);
    text-align: center;
    max-width: 100%;
    font-size: 13px;
    font-style: italic;
    padding: 8px;
}

.message-time {
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.6;
    align-self: flex-end;
}

.message.operator .message-time {
    align-self: flex-start;
}

.message.system .message-time {
    display: none;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    background: var(--bg-white);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    border-top: 1px solid #E0E0E0;
    position: sticky;
    bottom: 0;
    align-items: center;
    flex-shrink: 0;
}

.attach-btn-icon {
    width: 40px;
    height: 40px;
    background: none;
    color: var(--text-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    border-radius: 50%;
}

.attach-btn-icon:hover {
    background-color: #F5F5F7;
    color: var(--brand-color);
}

.attach-btn-icon:active {
    transform: scale(0.95);
}

.attach-btn-icon svg {
    width: 20px;
    height: 20px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: none;
    border-radius: 20px;
    background-color: #F5F5F7;
    font-family: inherit;
    color: var(--text-base);
}

.chat-input:focus {
    outline: none;
    background-color: #EBEBED;
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.send-btn-icon {
    width: 44px;
    height: 44px;
    background-color: var(--brand-color);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
}

.send-btn-icon:hover {
    background-color: #2d5fcc;
    transform: scale(1.05);
}

.send-btn-icon:active {
    transform: scale(0.95);
}

.send-btn-icon:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.send-btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Стили для сообщений с файлами */
.message-attachment {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
}

.attachment-link {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.attachment-link:hover {
    opacity: 0.8;
}

.message-attachment img {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    object-fit: contain;
}

.message-attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    margin-top: 8px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.message-attachment-file:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.message.operator .message-attachment-file {
    background-color: rgba(0, 0, 0, 0.05);
}

.message.operator .message-attachment-file:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.message-attachment-file-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.message-attachment-file-name {
    font-size: 14px;
    word-break: break-all;
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 24px;
    border-radius: 12px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideDown 0.3s ease;
    white-space: pre-line; /* Для поддержки переносов строк */
    line-height: 1.5;
    font-size: 15px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification.success {
    background-color: var(--success);
}

.notification.error {
    background-color: var(--error);
}

.notification.warning {
    background-color: var(--warning1);
}

.notification.info {
    background-color: var(--bg-light);
    color: var(--text-base);
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--bg-light);
    border-top: 3px solid var(--brand-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Контентные экраны */
.content-card {
    background: var(--bg-white);
    padding: 28px 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.content-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-base);
}

.content-text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-base);
}

.content-paragraph {
    margin-bottom: 20px;
}

.content-paragraph:last-child {
    margin-bottom: 0;
}

.content-subtitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-base);
    margin-top: 24px;
    margin-bottom: 14px;
}

.content-subtitle:first-child {
    margin-top: 0;
}

.content-list {
    margin: 20px 0;
    padding-left: 0;
}

.content-list-item {
    margin-bottom: 14px;
    padding-left: 12px;
    padding-right: 8px;
    line-height: 1.7;
    position: relative;
}

.content-list-item:last-child {
    margin-bottom: 0;
}

.content-indented-list {
    margin: 12px 0 20px 0;
    padding-left: 0;
}

.content-indented-item {
    margin-bottom: 10px;
    padding-left: 20px;
    line-height: 1.7;
    color: var(--text-base);
}

.content-indented-item:last-child {
    margin-bottom: 0;
}

.content-link {
    color: var(--brand-color);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--brand-color);
    transition: all 0.2s ease;
}

.content-link:hover {
    color: #2d5fcc;
    border-bottom-color: #2d5fcc;
}

.content-link:active {
    opacity: 0.8;
}

.content-date {
    color: var(--brand-color);
    font-weight: 600;
}

.content-note {
    margin-top: 20px;
    padding: 12px 16px;
    background-color: #F0F5FF;
    border-left: 3px solid var(--brand-color);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-base);
}

/* Стили для промо-акций */
.promo-highlight {
    background: linear-gradient(135deg, #F0F5FF 0%, #E8F0FE 100%);
    padding: 20px 24px;
    border-radius: 12px;
    border: 2px solid var(--brand-color);
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-color);
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(57, 125, 255, 0.15);
}

.promo-important {
    color: var(--brand-color);
    font-weight: 600;
    background-color: #F0F5FF;
    padding: 2px 6px;
    border-radius: 4px;
}

.promo-step {
    margin-bottom: 16px;
    padding: 16px 20px;
    background-color: #F9FAFB;
    border-left: 4px solid var(--brand-color);
    border-radius: 8px;
    line-height: 1.7;
    font-size: 16px;
}

.promo-step:last-child {
    margin-bottom: 0;
}

/* Стили для медицинского осмотра */
.medical-time {
    color: var(--brand-color);
    font-weight: 600;
    background-color: #F0F5FF;
    padding: 2px 6px;
    border-radius: 4px;
}

.medical-address {
    margin-bottom: 12px;
    padding: 12px 16px;
    background-color: #F9FAFB;
    border-left: 3px solid #E0E0E0;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 15px;
}

.medical-address-highlight {
    background-color: #F0F5FF;
    border-left-color: var(--brand-color);
    font-weight: 500;
}

.medical-address:last-child {
    margin-bottom: 0;
}

.medical-phone {
    margin-top: 12px;
    padding: 16px 20px;
    background-color: #F0F5FF;
    border-radius: 12px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.medical-phone .content-link {
    font-size: 20px;
    border-bottom: none;
    text-decoration: none;
}

/* Стили для расторжения договора */
.termination-important {
    background-color: #F0F5FF;
    padding: 16px 20px;
    border-radius: 12px;
    border-left: 4px solid var(--brand-color);
    margin-top: 12px;
}

.termination-example {
    margin-top: 12px;
    padding: 12px 16px;
    background-color: #F9FAFB;
    border-radius: 8px;
    font-style: italic;
    color: var(--text-secondary);
}

.termination-date {
    color: var(--brand-color);
    font-weight: 600;
}

.termination-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-secondary {
    background-color: var(--bg-white);
    color: var(--brand-color);
    border: 2px solid var(--brand-color);
}

.btn-secondary:hover {
    background-color: #F0F5FF;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(57, 125, 255, 0.15);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-secondary:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background-color: #EEF1F6;
    border-color: #D6DBE6;
    color: #9AA3B2;
}

.btn-secondary:disabled:hover {
    transform: none;
    box-shadow: none;
    background-color: #EEF1F6;
    border-color: #D6DBE6;
    color: #9AA3B2;
}

.btn-resend {
    margin-top: 12px;
}

.btn-resend.btn-timer {
    letter-spacing: 0.2px;
}

.btn-logout {
    margin-top: 12px;
    background-color: #FFF1F2;
    border-color: #FFC9CF;
    color: #C82333;
}

.btn-logout:hover {
    background-color: #FFE4E7;
    border-color: #FFB3BC;
    color: #A91726;
}

.btn-logout:disabled {
    background-color: #F8DDE1;
    border-color: #F0C5CB;
    color: #B06B74;
}

/* Адаптивность */
@media (max-width: 480px) {
    .screen {
        padding: 15px;
    }
    
    .greeting {
        font-size: 24px;
    }
    
    .menu-title {
        font-size: 18px;
    }
    
    .form {
        padding: 20px;
    }
    
    .content-card {
        padding: 24px 20px;
    }
    
    .content-text {
        font-size: 15px;
        line-height: 1.75;
    }
    
    .content-paragraph {
        margin-bottom: 18px;
    }
    
    .content-list-item {
        margin-bottom: 12px;
        padding-left: 10px;
    }
    
    .content-subtitle {
        margin-top: 20px;
        margin-bottom: 12px;
        font-size: 17px;
    }
}

