/* =========================================================================
 * Flow — CRM Assistenza (/chat)
 * Branded full-page shell. Keeps od-chat-* IDs; styles via .crm-chat-* wrappers.
 * ========================================================================= */

.crm-chat-main {
    --crm-teal: #0f766e;
    --crm-teal-mid: #0d9488;
    --crm-teal-soft: #ccfbf1;
    --crm-ink: #0f172a;
    --crm-muted: #64748b;
    --crm-surface: rgba(255, 255, 255, 0.92);
    --crm-radius: 18px;
    --crm-shadow: 0 18px 48px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(1200px 600px at 12% -10%, rgba(20, 184, 166, 0.28), transparent 55%),
        radial-gradient(900px 500px at 92% 8%, rgba(15, 118, 110, 0.18), transparent 50%),
        linear-gradient(165deg, #f0fdfa 0%, #e2e8f0 42%, #f8fafc 100%);
    color: var(--crm-ink);
    font-family: "DM Sans", system-ui, sans-serif;
}

.crm-chat-main::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230f766e' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: 0;
}

.crm-chat-main > * {
    position: relative;
    z-index: 1;
}

/* ----- Header ----- */
.crm-chat-main .app2-header {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    padding: 1rem 1.25rem 0.25rem;
}

.crm-chat-main .app2-header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    border-radius: 999px;
    background: var(--crm-surface);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(10px);
}

.crm-chat-main .app2-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--crm-ink);
}

.crm-chat-main .app2-logo-img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
}

.crm-chat-main .app2-logo-text {
    font-family: "Outfit", sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.crm-chat-main .app2-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.crm-chat-main .app2-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--crm-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.crm-chat-main .app2-icon-btn:hover {
    background: var(--crm-teal-soft);
    color: var(--crm-teal);
    border-color: rgba(15, 118, 110, 0.2);
}

.crm-chat-main .app2-dropdown {
    max-width: 720px;
    margin: 0.45rem auto 0;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: min(280px, calc(100% - 2.5rem));
    margin-left: auto;
    margin-right: 1.25rem;
    left: auto;
    transform: none;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--crm-shadow);
    overflow: hidden;
}

/* ----- Main column ----- */
.crm-chat-main .od-chat-main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 2.5rem;
    min-height: calc(100dvh - 5.5rem);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.crm-chat-hero {
    text-align: center;
    padding: 0.5rem 0.5rem 0.25rem;
}

.crm-chat-hero__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: "Outfit", sans-serif;
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--crm-ink);
    margin: 0 0 0.35rem;
    line-height: 1.15;
}

.crm-chat-hero__brand-mark {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
}

.crm-chat-hero__sub {
    margin: 0 auto;
    max-width: 28rem;
    font-size: 0.98rem;
    color: var(--crm-muted);
    font-weight: 500;
    line-height: 1.45;
}

.crm-chat-card {
    background: var(--crm-surface);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow);
    padding: 1.35rem 1.35rem 1.25rem;
    backdrop-filter: blur(12px);
}

.crm-chat-main .od-chat-setup .app2-step-header,
.crm-chat-main .od-chat-webhook-panel .app2-step-header {
    display: none; /* hero above replaces titles */
}

.crm-chat-main .app2-field {
    margin-bottom: 0.85rem;
}

.crm-chat-main .app2-field label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--crm-muted);
    margin-bottom: 0.35rem;
}

.crm-chat-main .app2-input,
.crm-chat-main .od-chat-textarea {
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    font-size: 0.95rem;
    padding: 0.7rem 0.85rem;
}

.crm-chat-main .app2-input[readonly] {
    background: #f8fafc;
    color: #334155;
}

.crm-chat-main .app2-btn-primary {
    width: 100%;
    margin-top: 0.35rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.98rem;
    padding: 0.85rem 1.1rem;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.crm-chat-main .app2-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.35);
}

.crm-chat-main .app2-btn-outline {
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: #fff;
    color: var(--crm-ink);
    font-weight: 600;
}

/* Banner */
.crm-chat-main .od-chat-banner--warn {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    font-weight: 500;
}

/* Live / webhook thread */
.crm-chat-main .od-chat-live,
.crm-chat-main .od-chat-webhook-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.crm-chat-main .od-chat-live:not([hidden]),
.crm-chat-main .od-chat-webhook-panel:not([hidden]) {
    display: flex;
}

.crm-chat-main .od-chat-live-head {
    align-items: center;
    margin-bottom: 0.85rem;
}

.crm-chat-main .od-chat-live-title {
    font-family: "Outfit", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.crm-chat-main .od-chat-thread {
    flex: 1;
    min-height: 16rem;
    max-height: none;
    background: #f1f5f9;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    padding: 1rem;
}

.crm-chat-main .od-chat-msg {
    margin-bottom: 0.65rem;
}

.crm-chat-main .od-chat-msg-bubble {
    border-radius: 16px;
    padding: 0.65rem 0.9rem;
    font-size: 0.92rem;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.crm-chat-main .od-chat-msg--user .od-chat-msg-bubble {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    border-bottom-right-radius: 5px;
}

.crm-chat-main .od-chat-msg--other .od-chat-msg-bubble {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom-left-radius: 5px;
}

.crm-chat-main .od-chat-composer--live {
    background: transparent;
    padding-top: 0.35rem;
}

.crm-chat-main .od-chat-composer {
    gap: 0.65rem;
}

.crm-chat-main .od-chat-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
}

@media (max-width: 540px) {
    .crm-chat-main .app2-header {
        padding: 0.75rem 0.75rem 0;
    }

    .crm-chat-main .od-chat-main {
        padding: 1rem 0.85rem 2rem;
    }

    .crm-chat-card {
        padding: 1.1rem;
    }

    .crm-chat-hero__brand {
        font-size: 1.55rem;
    }
}
