/* Isolated storefront chat — overrides theme/Bootstrap resets */
#ihouse-chat-root,
#ihouse-chat-root *,
#ihouse-chat-root *::before,
#ihouse-chat-root *::after {
    box-sizing: border-box;
}

#ihouse-chat-root {
    position: fixed;
    z-index: 99999;
    bottom: 24px;
    right: 24px;
    left: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    direction: rtl;
    text-align: right;
}

#ihouse-chat-root button,
#ihouse-chat-root input,
#ihouse-chat-root form {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

#ihouse-chat-root .ihouse-chat__toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 14px !important;
    background: #1d1d1f !important;
    color: #fff !important;
    border: none !important;
    border-radius: 999px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 13px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.2 !important;
}

#ihouse-chat-root .ihouse-chat__toggle-label {
    font-size: 13px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    line-height: 1.2 !important;
}

#ihouse-chat-root .ihouse-chat__toggle:hover {
    background: #333 !important;
}

#ihouse-chat-root .ihouse-chat__toggle i {
    font-size: 18px;
    line-height: 1;
}

#ihouse-chat-root .ihouse-chat__panel {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    left: auto;
    width: min(380px, calc(100vw - 32px));
    height: min(520px, calc(100vh - 120px));
    max-height: 520px;
    background: #fff !important;
    color: #1d1d1f !important;
    border-radius: 16px !important;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
    border: 1px solid #e5e5ea;
}

#ihouse-chat-root .ihouse-chat__panel[hidden] {
    display: none !important;
}

#ihouse-chat-root .ihouse-chat__top {
    flex: 0 0 auto;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: #1d1d1f !important;
    color: #fff !important;
    min-height: 0;
}

#ihouse-chat-root .ihouse-chat__title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #fff !important;
    line-height: 1.3 !important;
    font-family: inherit !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

#ihouse-chat-root .ihouse-chat__subtitle {
    display: block;
    margin: 4px 0 0 !important;
    padding: 0 !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    color: rgba(255, 255, 255, 0.65) !important;
    line-height: 1.4 !important;
}

#ihouse-chat-root .ihouse-chat__close {
    flex: 0 0 auto;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: 22px !important;
    line-height: 32px !important;
    text-align: center;
    cursor: pointer;
}

#ihouse-chat-root .ihouse-chat__close:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

#ihouse-chat-root .ihouse-chat__messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 12px !important;
    margin: 0 !important;
    background: #f5f5f7 !important;
    list-style: none !important;
}

#ihouse-chat-root .ihouse-chat__bubble {
    display: block;
    max-width: 88%;
    margin: 0 0 10px !important;
    padding: 10px 12px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    word-break: break-word;
    background: #fff;
    border: 1px solid #e5e5ea;
    color: #1d1d1f;
}

#ihouse-chat-root .ihouse-chat__bubble--bot {
    margin-inline-end: auto !important;
    margin-inline-start: 0 !important;
}

#ihouse-chat-root .ihouse-chat__bubble--user {
    background: #007aff !important;
    border-color: #007aff !important;
    color: #fff !important;
    margin-inline-start: auto !important;
    margin-inline-end: 0 !important;
}

#ihouse-chat-root .ihouse-chat__bubble--loading {
    background: #fff !important;
    color: #666 !important;
    font-style: italic;
}

#ihouse-chat-root .ihouse-chat__bubble a {
    color: #007aff;
    text-decoration: underline;
}

#ihouse-chat-root .ihouse-chat__bubble--user a {
    color: #fff;
}

#ihouse-chat-root .ihouse-chat__bubble strong,
#ihouse-chat-root .ihouse-chat__bubble b,
#ihouse-chat-root .ihouse-chat__bubble h1,
#ihouse-chat-root .ihouse-chat__bubble h2,
#ihouse-chat-root .ihouse-chat__bubble h3,
#ihouse-chat-root .ihouse-chat__bubble h4,
#ihouse-chat-root .ihouse-chat__bubble h5,
#ihouse-chat-root .ihouse-chat__bubble h6 {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    background: transparent !important;
    border: none !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

#ihouse-chat-root .ihouse-chat__bubble ul {
    margin: 8px 0 0 !important;
    padding: 0 18px 0 0 !important;
    list-style: disc !important;
}

#ihouse-chat-root .ihouse-chat__bubble li {
    margin: 4px 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

#ihouse-chat-root .ihouse-chat__suggestions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e5e5ea;
}

#ihouse-chat-root .ihouse-chat__suggestions-title {
    display: block;
    margin: 0 0 6px !important;
    padding: 0 !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    line-height: 1.4 !important;
    color: #6e6e73 !important;
    background: transparent !important;
    letter-spacing: normal !important;
    text-transform: none !important;
}

#ihouse-chat-root .ihouse-chat__suggestions a {
    display: block;
    margin-top: 4px;
    padding: 0 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    color: #007aff !important;
    text-decoration: none !important;
    background: transparent !important;
}

#ihouse-chat-root .ihouse-chat__suggestions a:hover {
    text-decoration: underline !important;
}

#ihouse-chat-root .ihouse-chat__form {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
    border-top: 1px solid #e5e5ea !important;
    background: #fff !important;
}

#ihouse-chat-root .ihouse-chat__input {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 42px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    border: 1px solid #d2d2d7 !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: #1d1d1f !important;
    font-size: 14px !important;
    line-height: 42px !important;
    box-shadow: none !important;
    appearance: none;
    -webkit-appearance: none;
}

#ihouse-chat-root .ihouse-chat__input:focus {
    outline: none;
    border-color: #007aff !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2) !important;
}

#ihouse-chat-root .ihouse-chat__send {
    flex: 0 0 42px !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #007aff !important;
    color: #fff !important;
    border: none !important;
    border-radius: 10px !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

#ihouse-chat-root .ihouse-chat__send:hover:not(:disabled) {
    background: #0066d6 !important;
}

#ihouse-chat-root .ihouse-chat__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#ihouse-chat-root .ihouse-chat__send i {
    font-size: 16px;
    line-height: 1;
    margin: 0;
}

#ihouse-chat-root .ihouse-chat__bubble--prompt {
    background: #f0f4f8 !important;
    color: #1a1a1a !important;
    border: 1px dashed #94a3b8 !important;
    max-width: 100% !important;
    font-size: 10px !important;
    line-height: 1.35 !important;
}

#ihouse-chat-root .ihouse-chat__prompt-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#ihouse-chat-root .ihouse-chat__prompt-stack-head,
#ihouse-chat-root .ihouse-chat__prompt-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

#ihouse-chat-root .ihouse-chat__prompt-stack-title {
    font-weight: 600;
    font-size: 10px !important;
    color: #475569;
}

#ihouse-chat-root .ihouse-chat__prompt-panel {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    padding: 6px;
}

#ihouse-chat-root .ihouse-chat__prompt-panel-title {
    font-size: 9px !important;
    font-weight: 600 !important;
    color: #334155;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

#ihouse-chat-root .ihouse-chat__copy-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    line-height: 1;
}

#ihouse-chat-root .ihouse-chat__copy-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

#ihouse-chat-root .ihouse-chat__copy-btn--done {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

#ihouse-chat-root .ihouse-chat__copy-btn i {
    font-size: 10px;
    pointer-events: none;
}

#ihouse-chat-root .ihouse-chat__prompt-debug {
    margin: 0;
    font-size: 10px !important;
    line-height: 1.35;
}

#ihouse-chat-root .ihouse-chat__prompt-debug > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 10px !important;
    color: #475569;
    margin-bottom: 6px;
}

#ihouse-chat-root .ihouse-chat__debug-block {
    margin-bottom: 8px;
}

#ihouse-chat-root .ihouse-chat__debug-block strong {
    display: block;
    margin-bottom: 3px;
    color: #334155;
    font-size: 9px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

#ihouse-chat-root .ihouse-chat__debug-list {
    margin: 0;
    padding: 0 0 0 18px;
    direction: ltr;
    text-align: left;
}

#ihouse-chat-root .ihouse-chat__debug-list code {
    font-size: 10px;
}

#ihouse-chat-root .ihouse-chat__debug-empty {
    margin: 0;
    font-size: 10px;
    color: #64748b;
    direction: ltr;
    text-align: left;
}

#ihouse-chat-root .ihouse-chat__debug-raw {
    margin-top: 8px;
}

#ihouse-chat-root .ihouse-chat__debug-raw summary {
    font-size: 9px !important;
    color: #64748b;
}

#ihouse-chat-root .ihouse-chat__prompt-panel .ihouse-chat__prompt-pre {
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 9px !important;
    direction: ltr;
    text-align: left;
}

#ihouse-chat-root .ihouse-chat__prompt-pre {
    margin: 0;
    padding: 6px;
    max-height: 180px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 9px !important;
    direction: ltr;
    text-align: left;
}

#ihouse-chat-root .ihouse-chat__actions {
    flex: 0 0 auto;
    padding: 0 12px 8px;
    background: #fff;
}

#ihouse-chat-root .ihouse-chat__human-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 8px 12px;
    border: 1px dashed #007aff;
    border-radius: 10px;
    background: #f0f7ff;
    color: #007aff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#ihouse-chat-root .ihouse-chat__human-btn:hover {
    background: #e3f0ff;
}

#ihouse-chat-root .ihouse-chat__bubble--agent {
    margin-inline-start: auto !important;
    margin-inline-end: 0 !important;
    background: #007aff !important;
    border-color: #007aff !important;
    color: #fff !important;
}

#ihouse-chat-root .ihouse-chat__bubble--agent a {
    color: #fff !important;
    text-decoration: underline !important;
}

#ihouse-chat-root .ihouse-chat__bubble--system {
    background: #fff3cd !important;
    border-color: #ffc107 !important;
    font-style: italic;
}

@media (max-width: 480px) {
    #ihouse-chat-root {
        right: 12px;
        bottom: 12px;
    }

    #ihouse-chat-root .ihouse-chat__toggle-label {
        display: none;
    }

    #ihouse-chat-root .ihouse-chat__panel {
        width: calc(100vw - 24px);
        height: min(70vh, 520px);
    }
}
