#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

/* === Move-to-top button (above chat) === */
.chat-scroll-top {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card, #ffffff);
    border: 1.5px solid var(--border, #e4e4e7);
    color: var(--fg, #18181b);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
}

.chat-scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-scroll-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: var(--primary, #10b981);
    color: var(--primary, #10b981);
}

.chat-scroll-top:active {
    transform: translateY(0);
}

html.dark .chat-scroll-top {
    background: #18181b;
    border-color: rgba(255, 255, 255, 0.1);
    color: #fafafa;
}

html.dark .chat-scroll-top:hover {
    border-color: var(--primary, #10b981);
    color: var(--primary, #10b981);
}

.chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window.hidden {
    display: none;
}

.chat-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #fafafa;
    background-image: url('/assets/images/Lomilink1.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 200px 200px;
    background-attachment: local;
    background-blend-mode: multiply;
    position: relative;
}

.chat-messages::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(250, 250, 250, 0.85);
    pointer-events: none;
}

.chat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    z-index: 1;
}

.chat-message.user {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    margin-left: auto;
    text-align: right;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.chat-message.ai {
    background: #ffffff;
    color: #18181b;
    border: 1px solid #e4e4e7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-input-container {
    display: flex;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #e4e4e7;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e4e4e7;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    background: #ffffff;
    color: #18181b;
}

#chat-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.chat-send {
    margin-left: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.chat-send:hover {
    opacity: 0.9;
}

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
    }
}

/* Dark mode support - matches html.dark styles from app.css */
html.dark .chat-window {
    background: #18181b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

html.dark .chat-messages {
    background-color: #0c0c0e;
}

html.dark .chat-messages::before {
    background: rgba(12, 12, 14, 0.85);
}

html.dark .chat-message.user {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: #09090b;
    box-shadow: 0 2px 6px rgba(52, 211, 153, 0.3);
}

html.dark .chat-message.ai {
    background: #18181b;
    color: #fafafa;
    border: 1px solid #27272a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html.dark .chat-input-container {
    background: #18181b;
    border-top: 1px solid #27272a;
}

html.dark #chat-input {
    background: #0c0c0e;
    border-color: #27272a;
    color: #fafafa;
}

html.dark #chat-input:focus {
    border-color: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

html.dark .chat-send {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: #09090b;
}
