/* ================================================================
   (future) code — мобільна та планшетна версія
   Підключається ПІСЛЯ styles.css і лише перевизначає розкладку.
   Десктопний вигляд (від 1025px) не змінюється.
   ================================================================ */

/* ---------------- ПЛАНШЕТ ТА ВУЗЬКИЙ НОУТБУК (≤1024px) --------- */
@media (max-width: 1024px) {

    .header {
        padding: 0 20px;
    }

    .content-consultation {
        padding: 70px 20px 40px;
    }

    /* Профіль клієнта: 5 колонок → 2 */
    .profile-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Підсумкові віджети: 4 колонки → 2 */
    .data-result-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Консультація: бічна панель вводу + дані → одна колонка */
    .consultation-content {
        flex-direction: column;
    }

    .consultation-content-item {
        width: 100%;
        flex-shrink: 1;
    }

    .consultation-content-item-header {
        flex-direction: column;
        align-items: stretch; /* інакше колонка стискає віджет до ширини вмісту */
        gap: 24px;
        margin-bottom: 24px;
    }

    .consultation-content-item-data-widjet,
    .consultation-content-item-data-text {
        width: 100%;
    }

    /* Список клієнтів */
    .clients-list-header,
    .client-row {
        grid-template-columns: 2fr 2fr 2fr 1fr;
        gap: 14px;
    }

    .clients-list-header .col-communication,
    .client-row .col-communication {
        display: none;
    }
}

/* ---------------- МОБІЛЬНИЙ (≤768px) --------------------------- */
@media (max-width: 768px) {

    /* --- Загальне --- */
    html,
    body {
        overflow-x: hidden;
        max-width: 100%;
    }

    .header {
        padding: 0 14px;
        height: 56px;
    }

    .header-text {
        font-size: 15px;
    }

    .header-text span {
        display: none; /* «/ capital management /» — зайве на малому екрані */
    }

    .user-info-text {
        font-size: 13px;
        max-width: 46vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* У кабінеті клієнта важливіші кнопки PDF і «вийти»,
       ніж власне ім'я — на телефоні ім'я ховаємо */
    .client-name-label {
        display: none;
    }

    .user-avatar {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .content-consultation {
        padding: 74px 14px 32px;
    }

    /* Заголовки */
    .clients-header h1,
    .consultation-header h1 {
        font-size: 28px;
        letter-spacing: -1px;
    }

    /* Заголовок консультації — flex-рядок на десктопі, колонка на телефоні */
    .consultation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .clients-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 24px;
    }

    .header-buttons {
        width: 100%;
    }

    .header-buttons .button,
    .header-buttons .button_2 {
        flex: 1;
        min-width: 0;
        text-align: center;
        font-size: 14px;
        padding: 11px 12px;
    }

    /* --- Вхід та створення профілю --- */
    .content {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 74px 14px 32px;
        gap: 16px;
    }

    .content_img_login,
    .content_img_profile_create {
        width: 100%;
        height: 150px;
        padding: 20px;
        border-radius: 20px;
        /* Затемнюємо фото, щоб світлий текст читався на малому екрані */
        background-color: rgba(0, 0, 0, 0.45);
        background-blend-mode: darken;
    }

    .content_img_login h1 span,
    .content_img_profile_create h1 span {
        color: rgba(255, 255, 255, 0.85);
    }

    .content_img_login h1,
    .content_img_profile_create h1 {
        font-size: 22px;
        letter-spacing: -0.5px;
    }

    .content_form,
    .content_form_profile_create {
        width: 100%;
        height: auto;
        padding: 0;
    }

    .content_form_in,
    .content_form_in_profile_create {
        width: 100%;
    }

    .content_form_in h1,
    .content_form_in_profile_create h1 {
        font-size: 26px;
    }

    /* Вкладки анкети — горизонтальна прокрутка замість переносу */
    .tabs,
    .tabs-consultation {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
    }

    .tabs::-webkit-scrollbar,
    .tabs-consultation::-webkit-scrollbar {
        display: none;
    }

    .tabs button,
    .tabs-consultation button {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 14px;
        padding: 8px 14px;
    }

    /* Крок анкети: дві колонки → одна */
    .tab-content {
        flex-direction: column;
    }

    .tab-content_column {
        width: 100%;
    }

    .buttons {
        flex-wrap: wrap;
    }

    .buttons .button,
    .buttons .button_2,
    .buttons .button_save {
        flex: 1 1 140px;
        text-align: center;
    }

    /* --- Список клієнтів: рядки стають картками --- */
    .clients-list-header {
        display: none;
    }

    .client-row {
        display: block;
        padding: 16px;
        border-bottom: 8px solid rgba(143, 146, 161, 0.06);
    }

    .client-row .col-name {
        margin-bottom: 12px;
    }

    .client-row .col-financial {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px 14px;
        padding: 12px 0;
        border-top: 1px solid rgba(143, 146, 161, 0.12);
        border-bottom: 1px solid rgba(143, 146, 161, 0.12);
    }

    .client-row .col-contacts,
    .client-row .col-communication {
        display: block;
        margin-top: 10px;
        font-size: 14px;
    }

    .client-row .col-actions {
        display: flex;
        gap: 8px;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px solid rgba(143, 146, 161, 0.12);
    }

    .client-row .col-actions .action-button {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        border-radius: 10px;
        background: rgba(143, 146, 161, 0.07);
    }

    .search-bar {
        margin: -8px 0 20px;
    }

    .search-bar input {
        min-width: 0;
        width: 100%;
        max-width: none;
        flex: 1 1 100%;
    }

    /* --- Профіль клієнта --- */
    .profile-info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 30px;
    }

    .info-section,
    .info-section:nth-child(4) .info-block,
    .info-section:nth-child(5) .info-block {
        padding: 18px;
    }

    .roadmap-section h2 {
        font-size: 24px;
        letter-spacing: -0.8px;
    }

    .roadmap-description-container {
        flex-direction: column;
        gap: 12px;
    }

    .progress-timeline {
        flex-direction: column;
        gap: 14px;
    }

    .timeline-item {
        width: 100%;
    }

    /* --- Консультація --- */
    /* Фіксовані ширини десктопної розкладки → на всю ширину екрана */
    .consultation-content-item-data-text,
    .consultation-content-item-data,
    .consultation-content-item-input,
    .block-item-add,
    .block-item-status {
        width: 100% !important;
        max-width: 100%;
    }

    /* Вкладки не мають розтягувати сторінку — прокручуються всередині */
    .tabs-consultation,
    .tabs {
        width: 100%;
        max-width: 100%;
    }

    /* Бічна панель у закритому стані стоїть за межами екрана
       і не повинна створювати горизонтальну прокрутку */
    .slide-panel {
        max-width: 88vw;
    }

    .consultation-content-item-data-text p {
        font-size: 16px;
        letter-spacing: -0.4px;
    }

    .consultation-content-item-data-text br {
        display: none;
    }

    /* Віджет вікової шкали.
       На вузькому екрані підписи накладаються один на одного,
       тому лишаємо тільки поточний вік і межі шкали 0–100.
       Самі маркери (лінії) залишаються видимими. */
    .widjet-item-date p,
    .age-label {
        font-size: 11px;
    }

    .balance-label,
    .savings-label,
    .age10-label,
    .age20-label,
    .prediction10-label,
    .prediction20-label {
        display: none;
    }

    .consultation-content-item-data-widjet {
        margin: 24px 0;
    }

    /* Підсумкові віджети в одну колонку */
    .data-result-summary {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .data-result-summary-item {
        padding: 16px;
    }

    .data-result-summary-item p {
        font-size: 22px;
    }

    /* Графіки: не даємо розтягувати сторінку вбік */
    .apexcharts-canvas,
    #splineChart,
    #splineChart-future,
    #splineChart-code {
        max-width: 100% !important;
    }

    .apexcharts-legend {
        justify-content: flex-start !important;
    }

    /* Таблиця розрахунків — горизонтальна прокрутка */
    .table-container,
    .investment-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Поля вводу активів/цілей */
    .block-item-add,
    .goals-add-form {
        padding-right: 0;
    }

    .input-group-goals-all {
        flex-direction: column;
        gap: 10px;
    }

    .input-group-goals-item {
        width: 100%;
    }

    .title-button {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Панель дій консультанта */
    .advisor-toolbar {
        gap: 8px;
    }

    .toolbar-link {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
        font-size: 13px;
        padding: 9px 10px;
    }

    /* Порівняння років досягнення цілей */
    .gt-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .gt-badge {
        margin-left: 0;
    }

    /* Швидке редагування цілі */
    .goal-edit-form input {
        width: calc(50% - 6px);
    }

    /* --- Версії, доступ клієнта, анкета, профіль, команда --- */
    .ver-wrap,
    .share-wrap,
    .edit-wrap,
    .acc-wrap,
    .adm-wrap {
        margin: 20px auto;
        padding: 60px 14px 40px;
    }

    .ver-card,
    .share-card,
    .edit-card,
    .acc-card,
    .adm-card {
        padding: 18px 16px;
    }

    /* Профіль консультанта та команда: поля в одну колонку */
    .acc-grid,
    .adm-grid {
        grid-template-columns: 1fr;
    }

    .acc-card h1,
    .adm-head h1 {
        font-size: 24px;
    }

    .acc-btn,
    .adm-save {
        width: 100%;
    }

    .adm-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .adm-actions {
        width: 100%;
    }

    .adm-actions .adm-btn,
    .adm-actions form {
        flex: 1 1 calc(50% - 8px);
    }

    .adm-actions .adm-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .acc-nav,
    .adm-nav {
        width: 100%;
    }

    .acc-link,
    .adm-link {
        flex: 1 1 100%;
        justify-content: center;
    }

    .ver-head h1,
    .share-card h1,
    .edit-card h1 {
        font-size: 24px;
    }

    .ver-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .ver-actions {
        width: 100%;
    }

    .ver-actions .va-btn,
    .ver-actions form {
        flex: 1 1 calc(50% - 8px);
    }

    .ver-actions .va-btn {
        width: 100%;
        text-align: center;
    }

    .ver-summary {
        gap: 6px 14px;
        font-size: 13px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .cred-box {
        flex-direction: column;
        align-items: flex-start;
    }

    .cred-box .pin-val {
        font-size: 24px;
        letter-spacing: 4px;
    }

    .btn-row {
        width: 100%;
    }

    .btn-row form,
    .btn-row .btn-plain {
        flex: 1 1 100%;
    }

    .btn-row .btn-primary,
    .btn-row .btn-danger,
    .btn-row .btn-plain {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .child-row {
        flex-wrap: wrap;
    }

    .child-row input {
        flex: 1 1 100%;
    }

    .child-row input.age {
        flex: 1 1 100%;
    }

    /* --- Кабінет клієнта --- */
    .portal-banner,
    .portal-versions {
        padding: 14px 16px;
        font-size: 14px;
    }

    .client-save-block textarea {
        font-size: 16px; /* 16px не дає iOS збільшувати сторінку при фокусі */
    }

    /* --- Нотатки консультанта --- */
    .notes-form {
        flex-direction: column;
    }

    .notes-form textarea {
        width: 100%;
        min-width: 0;
    }

    .notes-add-btn {
        width: 100%;
    }

    /* --- Модальне вікно видалення --- */
    .modal-content {
        min-width: 0;
        width: calc(100vw - 32px);
        padding: 22px;
    }

    .modal-buttons {
        flex-direction: column-reverse;
    }

    .modal-buttons button {
        width: 100%;
    }

    /* --- Результат консультації --- */
    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions .pdf-download-btn,
    .result-actions .result-link {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* --- Вхід клієнта за PIN --- */
    .client-login-card {
        padding: 26px 20px;
    }

    .pin-input {
        font-size: 26px;
        letter-spacing: 8px;
    }

    /* iOS: поля 16px, щоб екран не «стрибав» при фокусі */
    input[type="text"],
    input[type="number"],
    input[type="tel"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
    }

    /* Календар вибору дати не має вилазити за екран */
    .custom-datepicker {
        width: calc(100vw - 28px);
        max-width: 320px;
    }

    /* --- Головна та вітальний екран --- */
    /* На десктопі текст і кнопка позиціоновані абсолютно поверх
       анімації; на телефоні ставимо їх у звичайний потік */
    .welcome_future {
        height: auto;
        min-height: 100vh;
        padding: 80px 16px 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 20px;
    }

    .welcome_future_text {
        position: static;
        transform: none;
        font-size: 20px;
        letter-spacing: -0.4px;
        opacity: 1;
        color: #171717;
    }

    .welcome_future_text p {
        font-size: 15px;
        color: #8F92A1;
        letter-spacing: 0;
    }

    .future_code_animation {
        height: auto;
        min-height: 90px;
        font-size: 30px;
        letter-spacing: -1px;
        white-space: normal;
        margin: 10px 0;
    }

    #animated_image {
        max-width: 110px;
    }

    .create_profile_button {
        position: static;
        transform: none;
        width: 100%;
    }

    .create_profile_button a {
        display: block;
        width: 100%;
        text-align: center;
    }

    .content_wraper {
        padding: 0 14px;
    }
}

/* ---------------- МАЛИЙ ТЕЛЕФОН (≤480px) ----------------------- */
@media (max-width: 480px) {

    .clients-header h1,
    .consultation-header h1 {
        font-size: 24px;
    }

    .client-row .col-financial {
        grid-template-columns: 1fr 1fr;
        font-size: 13px;
    }

    .toolbar-link {
        flex: 1 1 100%;
    }

    .data-result-summary-item p {
        font-size: 20px;
    }

    .welcome_future_text {
        font-size: 26px;
    }

    .future_code_animation {
        font-size: 32px;
    }

    .create_profile_button a {
        display: block;
        text-align: center;
    }
}

/* --- Друк: ховаємо службові елементи ---------------------------- */
@media print {
    .header,
    .advisor-toolbar,
    .notes-panel,
    .preloader,
    .search-bar {
        display: none !important;
    }
}
