.support-widget,
.support-widget * {
    box-sizing: border-box;
}

.support-widget {
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
}

.support-widget button,
.support-widget input,
.support-widget select,
.support-widget textarea {
    font: inherit;
}

.support-widget {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 1000;
    font-family: inherit;
}

.support-widget.support-widget--custom {
    top: var(--tugi-toggle-top, auto);
    right: var(--tugi-toggle-right, 32px);
    bottom: var(--tugi-toggle-bottom, 32px);
    left: var(--tugi-toggle-left, auto);
}

.support-widget.support-widget--inline {
    position: static;
    right: auto;
    bottom: auto;
    top: auto;
    left: auto;
    z-index: auto;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.support-widget-toggle {
    min-width: 88px;
    height: 56px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #285f99;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    line-height: 1;
    position: relative;
    color: #fff;
}

.support-widget.support-widget--inline .support-widget-toggle {
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    min-width: 72px;
    min-height: 40px;
    height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 16px;
    box-shadow: 0 4px 14px rgba(20, 45, 80, 0.16);
}

.support-widget.support-widget--inline .support-widget-toggle-icon {
    width: 22px;
    height: 22px;
    font-size: 13px;
}

.support-widget.support-widget--inline .support-widget-toggle-dot {
    width: 8px;
    height: 8px;
}

.support-widget.support-widget--compact .support-widget-toggle {
    min-width: 72px;
    height: 44px;
    padding: 0 12px;
    gap: 6px;
    border-radius: 12px;
    font-size: 15px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

.support-widget.support-widget--compact .support-widget-toggle-icon {
    width: 18px;
    height: 18px;
    font-size: 12px;
}

.support-widget.support-widget--compact .support-widget-toggle-text {
    font-size: 15px;
}

.support-widget.support-widget--compact .support-widget-toggle-dot {
    width: 8px;
    height: 8px;
}

.support-widget-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
    font-size: 13px;
    line-height: 1;
    color: #fff;
    flex: 0 0 auto;
}

.support-widget-toggle-text {
    color: #fff;
}

.support-widget-toggle-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #9ca3af;
    flex: 0 0 auto;
}

.support-widget-toggle-dot.is-online {
    background: #22c55e;
}

.support-widget.is-open .support-widget-toggle {
    display: none;
}

.support-widget-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: auto;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #d7dee8;
    overscroll-behavior: contain;
}

.support-widget.support-widget--custom .support-widget-panel {
    top: calc(100% + 16px);
    right: 0;
    bottom: auto;
    max-height: calc(100vh - 164px);
}

.support-widget-panel[hidden] {
    display: none !important;
}

.support-widget-panel:not([hidden]) {
    display: flex;
}

.support-widget-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.support-widget-header {
    background: #285f99;
    color: #fff;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.support-widget-title {
    font-size: 20px;
    font-weight: 700;
}

.support-widget-presence {
    margin-top: 4px;
    font-size: 13px;
    opacity: .95;
    display: flex;
    align-items: center;
    gap: 7px;
}

.support-widget-presence-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #9ca3af;
    flex: 0 0 auto;
}

.support-widget-presence-dot.is-online {
    background: #22c55e;
}

.support-widget-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.support-widget-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 14px;
    background: #f4f7fb;
}

.support-widget-intro {
    padding: 10px 14px 4px;
    color: #334155;
    font-size: 13px;
    line-height: 1.35;
    min-height: 0;
}

.support-widget-intro:empty {
    display: none;
}

.support-message {
    display: flex;
    margin-bottom: 8px;
}

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

.support-message-operator,
.support-message-system {
    justify-content: flex-start;
}

.support-message-bubble {
    max-width: 82%;
    padding: 9px 11px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    white-space: pre-wrap;
    word-break: break-word;
}

.support-message-user .support-message-bubble {
    background: #285f99;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.support-message-operator .support-message-bubble {
    background: #fff;
    border-bottom-left-radius: 4px;
}

.support-message-system .support-message-bubble {
    background: #e8eef6;
    color: #334155;
}

.support-widget-form {
    padding: 8px 12px 10px;
    border-top: 1px solid #dbe4f0;
    background: #fff;
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
}

.support-widget-initial-fields {
    display: grid;
    gap: 6px;
    margin-bottom: 6px;
}

.support-widget-initial-fields.is-hidden {
    display: none;
}

.support-widget-form label {
    display: grid;
    gap: 3px;
}

.support-widget-form label span {
    font-size: 11px;
    color: #334155;
}

.support-widget-form input,
.support-widget-form select,
.support-widget-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #c9d6e6;
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
    background: #fff;
    line-height: 1.25;
}

.support-widget-form input {
    height: 44px;
}

.support-widget-form select {
    height: 44px;
    background: #fff;
}

.support-widget-compose,
.support-compose {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex: 0 0 auto;
}

.support-widget-form.is-offline-start .support-widget-compose,
.support-widget-form.is-offline-start .support-compose,
.support-widget-form.support-offline-form .support-widget-compose,
.support-widget-form.support-offline-form .support-compose,
.support-widget-form.support-online-start .support-widget-compose,
.support-widget-form.support-online-start .support-compose {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.support-widget-form.is-offline-start .support-widget-compose button,
.support-widget-form.is-offline-start .support-compose button,
.support-widget-form.support-offline-form .support-widget-compose button,
.support-widget-form.support-offline-form .support-compose button,
.support-widget-form.support-online-start .support-widget-compose button,
.support-widget-form.support-online-start .support-compose button {
    width: 100%;
}

.support-widget-form.is-offline-start .support-widget-compose textarea,
.support-widget-form.is-offline-start .support-compose textarea,
.support-widget-form.support-offline-form .support-widget-compose textarea,
.support-widget-form.support-offline-form .support-compose textarea,
.support-widget-form.support-online-start .support-widget-compose textarea,
.support-widget-form.support-online-start .support-compose textarea {
    min-height: 88px;
    width: 100%;
}

.support-widget-compose textarea,
.support-compose textarea {
    min-height: 88px;
    max-height: 104px;
    resize: vertical;
}

.support-widget-compose button,
.support-compose button {
    border: 0;
    border-radius: 10px;
    background: #285f99;
    color: #fff;
    font-weight: 700;
    padding: 11px 14px;
    cursor: pointer;
    min-width: 92px;
    white-space: nowrap;
    line-height: 1.2;
}

.support-widget-form.is-offline-start .support-widget-compose button,
.support-widget-form.is-offline-start .support-compose button,
.support-widget-form.support-offline-form .support-widget-compose button,
.support-widget-form.support-offline-form .support-compose button {
    min-height: 44px;
    min-width: 0;
    width: 100%;
}

.support-widget-form.is-offline-start .support-widget-compose,
.support-widget-form.support-offline-form .support-widget-compose,
.support-widget-form.is-offline-start .support-compose,
.support-widget-form.support-offline-form .support-compose {
    align-items: stretch;
}

.support-widget-form.is-offline-start .support-widget-compose textarea,
.support-widget-form.support-offline-form .support-widget-compose textarea,
.support-widget-form.is-offline-start .support-compose textarea,
.support-widget-form.support-offline-form .support-compose textarea {
    flex: 1 1 auto;
}

.support-widget-form.is-offline-start .support-widget-compose button,
.support-widget-form.support-offline-form .support-widget-compose button,
.support-widget-form.is-offline-start .support-compose button,
.support-widget-form.support-offline-form .support-compose button {
    min-height: 48px;
}

.support-widget-form.support-online-start .support-widget-compose button,
.support-widget-form.support-online-start .support-compose button {
    min-height: 48px;
}

.support-widget-form.is-offline-start .support-widget-actions,
.support-widget-form.support-offline-form .support-widget-actions,
.support-widget-form.support-online-start .support-widget-actions {
    display: none;
}

.support-widget-actions {
    margin-top: 4px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.support-widget-close-chat {
    border: 1px solid #c9d6e6;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
}

.support-widget-new-conversation {
    border: 1px solid #285f99;
    border-radius: 10px;
    background: #fff;
    color: #285f99;
    font-weight: 700;
    padding: 10px 12px;
    cursor: pointer;
}

.support-widget-new-conversation:hover {
    background: #eef5fc;
}

.support-widget-status {
    min-height: 18px;
    margin-top: 4px;
    font-size: 13px;
    color: #475569;
}

.support-widget-status:empty {
    min-height: 0;
    margin-top: 0;
}

.support-widget-messages:empty {
    display: none;
}

.support-widget-form.is-closed .support-widget-compose,
.support-widget-form.is-closed .support-widget-initial-fields {
    display: none;
}

.support-widget-form.is-closed .support-widget-actions {
    display: none;
}

.support-widget-panel--dragging {
    user-select: none;
}

.support-widget-panel--dragging * {
    user-select: none;
}

.support-widget-header {
    cursor: move;
}

@media (max-width: 640px) {
    .support-widget {
        right: 16px;
        left: auto;
        bottom: calc(16px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        max-width: none;
        padding: 0;
        box-sizing: border-box;
    }

    .support-widget.support-widget--custom {
        top: auto;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        left: auto;
    }

    .support-widget-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(64px + env(safe-area-inset-bottom));
        top: auto;
        width: 100%;
        max-width: none;
        height: min(92vh, 720px);
        border-radius: 20px 20px 0 0;
    }

    .support-widget.support-widget--custom .support-widget-panel {
        top: auto;
        right: 0;
        bottom: calc(64px + env(safe-area-inset-bottom));
        left: 0;
        width: 100%;
        max-width: none;
        height: min(92vh, 720px);
        max-height: calc(100vh - 24px);
    }

    .support-widget.support-widget--start .support-widget-panel,
    .support-widget.support-widget--closed .support-widget-panel {
        height: auto;
        max-height: min(92vh, 720px);
    }

    .support-widget-header {
        padding: 16px 18px;
    }

    .support-widget-title {
        font-size: 24px;
        line-height: 1.1;
    }

    .support-widget-presence {
        font-size: 15px;
        line-height: 1.3;
    }

    .support-widget-close {
        width: 40px;
        height: 40px;
        font-size: 26px;
    }

    .support-widget-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom);
        flex: 1 1 auto;
        min-height: 0;
    }

    .support-widget.support-widget--start .support-widget-body,
    .support-widget.support-widget--closed .support-widget-body {
        flex: 0 0 auto;
    }

    .support-widget-messages {
        flex: 1 1 auto;
        min-height: 120px;
        padding: 12px 14px;
    }

    .support-widget-intro {
        padding: 12px 14px 6px;
        font-size: 14px;
        line-height: 1.4;
    }

    .support-widget-form {
        padding: 14px 16px 18px;
    }

    .support-widget.support-widget--start .support-widget-form,
    .support-widget.support-widget--closed .support-widget-form {
        padding-bottom: 14px;
    }

    .support-widget-initial-fields {
        gap: 8px;
        margin-bottom: 8px;
    }

    .support-widget-form label {
        gap: 4px;
    }

    .support-widget-form input,
    .support-widget-form select {
        height: 46px;
    }

    .support-widget-compose,
    .support-compose {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .support-widget-compose textarea,
    .support-compose textarea {
        min-height: 120px;
        max-height: 130px;
        width: 100%;
    }

    .support-widget-compose button,
    .support-compose button {
        width: 100%;
        min-height: 52px;
        min-width: 0;
        white-space: nowrap;
    }

    .support-widget-actions {
        gap: 8px;
        margin-top: 6px;
    }

    .support-widget-close-chat,
    .support-widget-new-conversation {
        width: 100%;
        min-height: 48px;
        padding: 10px 12px;
    }

    .support-widget.is-open .support-widget-toggle {
        display: none;
    }
}
