/**
 * iLogist — Express Diagnostics (Аналітика v1.1, Розділ 5).
 *
 * Фіксована кнопка лівий-нижній кут. З'являється через 30 сек після першого візиту.
 * Клік → модалка з 4 питаннями + телефон. Відправка → Telegram + /data/diagnostics/.
 *
 * Для повторного візиту — спрощена форма (без діагностики).
 */

/* ============================================================
   FLOATING BUTTON (лівий нижній кут)
============================================================ */
.diag-trigger {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9985000;  /* нижче cookie-banner (9990000), вище звичайного контенту */

    background: linear-gradient(135deg, #fca311 0%, #ffb733 100%);
    color: #0b192c;
    border: 0;
    padding: 14px 22px;
    border-radius: 100px;
    font-family: 'Manrope', 'Poppins', system-ui, sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.3px;
    box-shadow: 0 12px 32px rgba(252, 163, 17, 0.45), 0 4px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;

    /* Initial hidden — JS додає клас .is-visible */
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    visibility: hidden;
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0s linear 0.45s;
}

.diag-trigger.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0s linear 0s;
    /* Легке блимання щоб привернути увагу */
    animation: diag-pulse 2.8s ease-in-out infinite;
}

@keyframes diag-pulse {
    0%, 100% { box-shadow: 0 12px 32px rgba(252,163,17,0.45), 0 4px 8px rgba(0,0,0,0.15); }
    50% { box-shadow: 0 12px 36px rgba(252,163,17,0.85), 0 4px 10px rgba(0,0,0,0.2), 0 0 0 6px rgba(252,163,17,0.18); }
}

.diag-trigger:hover {
    transform: translateY(-3px) scale(1.03);
    animation: none;
    box-shadow: 0 16px 40px rgba(252,163,17,0.55), 0 6px 12px rgba(0,0,0,0.2);
}

.diag-trigger__icon {
    font-size: 18px;
    line-height: 1;
}

/* ============================================================
   MODAL OVERLAY + BOX
============================================================ */
.diag-modal {
    display: none;          /* JS перебиває через setProperty('flex', 'important') */
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9991000;       /* вище cookie-banner */
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    overflow-y: auto;
}

.diag-modal__box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    padding: 36px 32px 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    font-family: 'Manrope', 'Poppins', system-ui, sans-serif;
    transform: translateY(-20px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.diag-modal[style*="display: flex"] .diag-modal__box,
.diag-modal[style*="display:flex"] .diag-modal__box {
    transform: translateY(0);
}

.diag-modal__close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.diag-modal__close:hover { background: #f3f4f6; color: #0b192c; }

.diag-modal__tag {
    display: inline-block;
    font-size: 11px; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase;
    color: #fca311;
    margin-bottom: 12px;
}

.diag-modal__title {
    font-size: 1.6rem; font-weight: 800;
    color: #0b192c; line-height: 1.2;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
}

.diag-modal__lead {
    font-size: 14px; color: #4b5563;
    margin: 0 0 24px;
    line-height: 1.55;
}

/* ============================================================
   FORM FIELDS
============================================================ */
.diag-field {
    margin-bottom: 18px;
}

.diag-field__label {
    display: block;
    font-size: 12px; font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.diag-field__select,
.diag-field__input,
.diag-field__textarea {
    width: 100%;
    background: #f4f7f9;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 15px;
    color: #0b192c;
    font-family: inherit;
    outline: none;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.diag-field__select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.diag-field__textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.45;
}

.diag-field__select:focus,
.diag-field__input:focus,
.diag-field__textarea:focus {
    background: #fff;
    border-color: #fca311;
    box-shadow: 0 0 0 3px rgba(252,163,17,0.15);
}

.diag-submit {
    width: 100%;
    background: linear-gradient(135deg, #fca311 0%, #ffb733 100%);
    color: #0b192c;
    border: 0;
    padding: 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 6px 18px rgba(252,163,17,0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.diag-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(252,163,17,0.5);
}
.diag-submit:active { transform: translateY(0); }
.diag-submit:disabled {
    opacity: 0.6; cursor: not-allowed;
    transform: none;
}

.diag-modal__success {
    text-align: center; padding: 20px 0;
}
.diag-modal__success-icon {
    font-size: 56px; margin-bottom: 10px;
}
.diag-modal__success-title {
    font-size: 1.4rem; font-weight: 800;
    color: #0b192c; margin: 0 0 8px;
}
.diag-modal__success-desc {
    font-size: 14px; color: #4b5563; margin: 0;
}

.diag-modal__error {
    background: #fee2e2; color: #991b1b;
    padding: 12px 14px; border-radius: 8px;
    font-size: 13px; margin-bottom: 16px;
    display: none;
}
.diag-modal__error.is-visible { display: block; }

/* ============================================================
   MOBILE — кругла кнопка-іконка (тільки чат-бабл, без тексту)
   На малих екранах велика pill-кнопка перевантажує UX.
   Круг 56×56 — мінімум для тач-таргету (WCAG 2.5.5).
============================================================ */
@media (max-width: 767.98px) {
    .diag-trigger {
        bottom: 16px;
        left: 16px;
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
        font-size: 0;  /* приховуємо весь текст одразу */
        gap: 0;
        justify-content: center;
    }
    .diag-trigger__label {
        display: none;  /* текстова мітка не потрібна — є tooltip і ясна іконка */
    }
    .diag-trigger__icon {
        font-size: 26px;  /* більша іконка щоб компенсувати відсутність тексту */
        line-height: 1;
    }
    .diag-modal__box {
        padding: 28px 22px 22px;
        max-height: calc(100vh - 24px);
    }
    .diag-modal__title { font-size: 1.35rem; }
}
