/* ===== Виджет чата техподдержки ===== */
#support-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10000;
    font-family: 'Montserrat', Arial, sans-serif;
}

#support-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: #5b8c5a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
}

#support-toggle:hover {
    transform: scale(1.07);
    background: #4d7a4c;
}

#support-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.support-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 12px;
    min-width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-sizing: border-box;
}

#support-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100dvh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* [hidden] всегда побеждает display из стилей ниже */
#support-panel[hidden],
#support-messages[hidden],
#support-form[hidden],
#support-name-form[hidden],
.support-file-preview[hidden],
.support-name-error[hidden] {
    display: none !important;
}

.support-header {
    background: #5b8c5a;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.support-header-text {
    display: flex;
    flex-direction: column;
}

.support-title {
    font-weight: 600;
    font-size: 16px;
}

.support-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

#support-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

/* --- Шаг «представьтесь» --- */
#support-name-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 20px;
    flex: 1;
    justify-content: center;
    background: #f6f7f6;
}

.support-name-title {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    text-align: center;
}

.support-name-hint {
    font-size: 13px;
    color: #777;
    text-align: center;
    margin: 0;
}

#support-name-input {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 16px; /* защита от авто-зума на iOS */
    font-family: inherit;
    outline: none;
}

#support-name-input:focus {
    border-color: #5b8c5a;
}

#support-name-submit {
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #5b8c5a;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

#support-name-submit:hover:not(:disabled) {
    background: #4d7a4c;
}

#support-name-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.support-name-error {
    font-size: 13px;
    color: #e74c3c;
    text-align: center;
}

/* --- Сообщения --- */
#support-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f6f7f6;
    -webkit-overflow-scrolling: touch;
}

.support-msg {
    display: flex;
}

.support-msg.from-user {
    justify-content: flex-end;
}

.support-bubble {
    max-width: 80%;
    padding: 9px 12px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.support-msg.from-user .support-bubble {
    background: #dcf3dc;
}

.support-author {
    font-size: 11px;
    font-weight: 600;
    color: #5b8c5a;
    margin-bottom: 2px;
}

.support-text {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    color: #222;
}

.support-time {
    font-size: 10px;
    color: #999;
    text-align: right;
    margin-top: 3px;
}

/* --- Форма отправки --- */
#support-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

#support-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

#support-input:focus {
    border-color: #5b8c5a;
}

#support-form button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #5b8c5a;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

#support-form button:hover {
    background: #4d7a4c;
}

#support-form button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.support-attach {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
}

.support-attach svg {
    width: 22px;
    height: 22px;
    fill: #666;
}

.support-image {
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    display: block;
    margin: 4px 0;
}

.support-file-preview {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f5f5f5;
    border-radius: 8px;
}

.support-file-preview img {
    max-height: 48px;
    border-radius: 6px;
}

.support-file-preview button {
    border: 0;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: #888;
}

/* Мобильные устройства: чат на весь экран */
@media (max-width: 480px) {
    #support-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }

    #support-widget {
        right: 16px;
        bottom: 16px;
    }

    #support-input {
        font-size: 16px; /* защита от авто-зума на iOS */
    }

    #support-form {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}
