/* =============================================================================
   SmartMaison — AI chat widget

   The widget is hidden by default and only revealed once the backend has
   confirmed it is enabled (see chat-widget.js). If the chat-service is not
   deployed, nothing is ever shown.
   ============================================================================= */

.sm-chat,
.sm-chat__launcher {
    display: none;
}

.sm-chat.is-available,
.sm-chat.is-available .sm-chat__launcher {
    display: block;
}

/* ---------------------------------------------------------------- launcher */
.sm-chat__launcher {
    position: fixed;
    right: clamp(1rem, 3vw, 2rem);
    bottom: clamp(1rem, 3vw, 2rem);
    z-index: 90;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 1px solid rgba(201, 169, 98, .45);
    border-radius: 50%;
    background: linear-gradient(140deg, #14181d 0%, #07080a 100%);
    color: #c9a962;
    cursor: pointer;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9), 0 0 40px -14px rgba(201, 169, 98, .5);
    transition: transform .4s cubic-bezier(0.22, 1, 0.36, 1), border-color .2s, color .2s;
}
.sm-chat__launcher:hover {
    transform: translateY(-3px);
    border-color: rgba(201, 169, 98, .9);
    color: #e7d3a1;
}
.sm-chat__launcher svg {
    width: 24px;
    height: 24px;
    display: block;
    margin: auto;
}
.sm-chat__launcher .sm-chat__icon-close { display: none; }

.sm-chat.is-open .sm-chat__launcher .sm-chat__icon-open { display: none; }
.sm-chat.is-open .sm-chat__launcher .sm-chat__icon-close { display: block; }

/* ------------------------------------------------------------------- panel */
.sm-chat__panel {
    position: fixed;
    right: clamp(1rem, 3vw, 2rem);
    bottom: calc(clamp(1rem, 3vw, 2rem) + 74px);
    z-index: 91;
    display: flex;
    flex-direction: column;
    width: min(388px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 8rem));
    border: 1px solid rgba(201, 169, 98, .22);
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(26, 31, 38, .97) 0%, rgba(11, 13, 16, .99) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .95);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .3s cubic-bezier(0.22, 1, 0.36, 1),
                transform .3s cubic-bezier(0.22, 1, 0.36, 1),
                visibility .3s;
}
.sm-chat.is-open .sm-chat__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* ------------------------------------------------------------------ header */
.sm-chat__header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid rgba(247, 243, 234, .07);
}
.sm-chat__header img { width: 32px; height: 32px; flex: none; border-radius: 50%; }
.sm-chat__title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.2rem;
    color: #f7f3ea;
    line-height: 1.2;
}
.sm-chat__status {
    display: block;
    font-family: 'Outfit', Arial, sans-serif;
    font-size: .62rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: #6a655d;
}
.sm-chat__close {
    margin-left: auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(247, 243, 234, .07);
    border-radius: 50%;
    background: transparent;
    color: #928d83;
    cursor: pointer;
    line-height: 1;
    transition: color .2s, border-color .2s;
}
.sm-chat__close:hover { color: #f7f3ea; border-color: rgba(201, 169, 98, .4); }

/* ------------------------------------------------------------------- body */
.sm-chat__log {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.sm-chat__msg {
    max-width: 86%;
    padding: .7rem 1rem;
    border-radius: 12px;
    font-family: 'Outfit', Arial, sans-serif;
    font-size: .92rem;
    font-weight: 300;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.sm-chat__msg--bot {
    align-self: flex-start;
    border: 1px solid rgba(247, 243, 234, .07);
    border-bottom-left-radius: 4px;
    background: rgba(247, 243, 234, .04);
    color: #cbc6bb;
}
.sm-chat__msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: linear-gradient(118deg, #a8863f 0%, #e7d3a1 46%, #c9a962 100%);
    color: #07080a;
    font-weight: 400;
}
.sm-chat__msg--error {
    align-self: flex-start;
    border: 1px solid rgba(201, 169, 98, .3);
    background: transparent;
    color: #928d83;
    font-style: italic;
}

/* Typing indicator */
.sm-chat__typing { display: inline-flex; gap: 5px; align-items: center; }
.sm-chat__typing i {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #c9a962;
    animation: smChatBlink 1.3s ease-in-out infinite;
}
.sm-chat__typing i:nth-child(2) { animation-delay: .18s; }
.sm-chat__typing i:nth-child(3) { animation-delay: .36s; }
@keyframes smChatBlink {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Suggested questions */
.sm-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: 0 1.1rem .5rem;
}
.sm-chat__suggestion {
    padding: .4rem .8rem;
    border: 1px solid rgba(201, 169, 98, .25);
    border-radius: 999px;
    background: transparent;
    color: #c9a962;
    font-family: 'Outfit', Arial, sans-serif;
    font-size: .75rem;
    font-weight: 300;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
}
.sm-chat__suggestion:hover {
    background: rgba(201, 169, 98, .1);
    color: #e7d3a1;
    border-color: rgba(201, 169, 98, .5);
}

/* ------------------------------------------------------------------- form */
.sm-chat__form {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    padding: .75rem 1.1rem 1.1rem;
    border-top: 1px solid rgba(247, 243, 234, .07);
}
.sm-chat__input {
    flex: 1;
    max-height: 110px;
    padding: .65rem .9rem;
    border: 1px solid rgba(247, 243, 234, .09);
    border-radius: 10px;
    background: rgba(247, 243, 234, .03);
    color: #f7f3ea;
    font-family: 'Outfit', Arial, sans-serif;
    font-size: .92rem;
    font-weight: 300;
    line-height: 1.5;
    resize: none;
    transition: border-color .2s;
}
.sm-chat__input::placeholder { color: #6a655d; }
.sm-chat__input:focus {
    outline: none;
    border-color: rgba(201, 169, 98, .5);
}
.sm-chat__send {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(118deg, #a8863f 0%, #e7d3a1 46%, #c9a962 100%);
    color: #07080a;
    cursor: pointer;
    transition: transform .2s, opacity .2s;
}
.sm-chat__send svg { width: 18px; height: 18px; display: block; margin: auto; }
.sm-chat__send:hover:not(:disabled) { transform: translateY(-1px); }
.sm-chat__send:disabled { opacity: .4; cursor: not-allowed; }

.sm-chat__legal {
    padding: 0 1.1rem .9rem;
    margin: 0;
    font-family: 'Outfit', Arial, sans-serif;
    font-size: .62rem;
    letter-spacing: .06em;
    color: #6a655d;
    text-align: center;
}

.sm-chat *:focus-visible {
    outline: 2px solid #e7d3a1;
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .sm-chat__panel {
        right: .5rem;
        left: .5rem;
        width: auto;
        height: min(72vh, calc(100vh - 7rem));
    }
}

@media (prefers-reduced-motion: reduce) {
    .sm-chat__launcher,
    .sm-chat__panel,
    .sm-chat__typing i { transition-duration: .001ms; animation: none; }
}
