/* ============================================================
   ME03 AI Chat Widget — chat-widget.css
   Option D: Off-white light background. Draggable + resizable.
   ============================================================ */

/* ── Trigger button ─────────────────────────────────────── */
#me03-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99990;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #FFC500;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
#me03-chat-trigger:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,0.36); }
#me03-chat-trigger svg   { width: 26px; height: 26px; fill: #0A0A0A; pointer-events: none; }

/* ── Widget window — positioned by JS ───────────────────── */
#me03-chat-window {
    position: fixed;
    z-index: 99991;
    background: #F9F9F9;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    border: 1px solid rgba(0,0,0,0.12);
    /* No transition on size/position — instant for drag feel */
}
#me03-chat-window.me03-open { display: flex; }

/* Fullscreen override */
#me03-chat-window.me03-fullscreen {
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* ── Resize handles — all 8 directions ──────────────────── */
.me03-resize-handle {
    position: absolute;
    z-index: 10;
}

/* Edges */
.me03-resize-n  { top: 0;    left: 8px;  right: 8px;  height: 8px; cursor: n-resize; }
.me03-resize-s  { bottom: 0; left: 8px;  right: 8px;  height: 8px; cursor: s-resize; }
.me03-resize-e  { right: 0;  top: 8px;   bottom: 8px; width: 8px;  cursor: e-resize; }
.me03-resize-w  { left: 0;   top: 8px;   bottom: 8px; width: 8px;  cursor: w-resize; }

/* Corners */
.me03-resize-ne { top: 0;    right: 0;   width: 14px; height: 14px; cursor: ne-resize; }
.me03-resize-nw { top: 0;    left: 0;    width: 14px; height: 14px; cursor: nw-resize; }
.me03-resize-se { bottom: 0; right: 0;   width: 14px; height: 14px; cursor: se-resize; }
.me03-resize-sw { bottom: 0; left: 0;    width: 14px; height: 14px; cursor: sw-resize; }

/* Visual resize indicator bottom-right corner */
.me03-resize-se::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(0,0,0,0.2);
    border-bottom: 2px solid rgba(0,0,0,0.2);
    border-radius: 1px;
}

/* ── Crisis bar ─────────────────────────────────────────── */
#me03-crisis-bar {
    background: #0A0A0A;
    border-bottom: 2px solid #FFC500;
    padding: 7px 14px;
    font-size: 11px;
    font-weight: 700;
    color: #FFC500;
    text-align: center;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    user-select: none;
}
#me03-crisis-bar a { color: #FFC500; text-decoration: underline; }

/* ── Header (drag zone) ─────────────────────────────────── */
#me03-chat-header {
    background: #0A0A0A;
    padding: 12px 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid #FFC500;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}
#me03-chat-header:active { cursor: grabbing; }
#me03-chat-header-title  { display: flex; align-items: center; gap: 10px; pointer-events: none; }

#me03-chat-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #FFC500;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
#me03-chat-avatar svg { width: 18px; height: 18px; fill: #0A0A0A; }
#me03-chat-name   { font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 13px; color: #FFFFFF; line-height: 1.2; }
#me03-chat-status { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 1px; }

/* ── Header controls ────────────────────────────────────── */
#me03-chat-controls { display: flex; align-items: center; gap: 2px; }
#me03-chat-controls button {
    background: none; border: none; cursor: pointer;
    padding: 5px; color: rgba(255,255,255,0.45);
    display: flex; align-items: center;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    pointer-events: all;
}
#me03-chat-controls button:hover { color: #FFC500; background: rgba(255,197,0,0.1); }
#me03-chat-controls button svg {
    width: 15px; height: 15px;
    fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#me03-chat-close svg  { width: 17px; height: 17px; }
#me03-chat-close:hover { color: #FFFFFF !important; background: rgba(255,255,255,0.1) !important; }

/* ── Messages ───────────────────────────────────────────── */
#me03-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #F9F9F9;
}
#me03-chat-messages::-webkit-scrollbar       { width: 4px; }
#me03-chat-messages::-webkit-scrollbar-track { background: transparent; }
#me03-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

.me03-bubble {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}
.me03-bubble-user {
    align-self: flex-end;
    background: #FFC500;
    color: #0A0A0A;
    font-weight: 600;
    border-bottom-right-radius: 3px;
}
.me03-bubble-agent {
    align-self: flex-start;
    background: #FFFFFF;
    color: #0A0A0A;
    border-bottom-left-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.me03-bubble-agent a       { color: #B38A00; text-decoration: underline; font-weight: 600; }
.me03-bubble-agent a:hover { color: #0A0A0A; }
.me03-bubble-error {
    align-self: flex-start;
    background: #FFF0F0;
    color: #CC2200;
    border: 1px solid rgba(200,0,0,0.2);
    border-bottom-left-radius: 3px;
    font-size: 12px;
}

/* Typing indicator */
#me03-typing {
    display: none;
    align-self: flex-start;
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-radius: 12px;
    border-bottom-left-radius: 3px;
    padding: 10px 14px;
    gap: 5px;
    align-items: center;
}
#me03-typing.me03-visible { display: flex; }
.me03-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(0,0,0,0.25);
    animation: me03Bounce 1.2s ease-in-out infinite;
}
.me03-dot:nth-child(2) { animation-delay: 0.2s; }
.me03-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes me03Bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); background: #FFC500; }
}

/* ── Input area ─────────────────────────────────────────── */
#me03-chat-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
    background: #FFFFFF;
    flex-shrink: 0;
}
#me03-chat-form { display: flex; gap: 8px; align-items: flex-end; }
#me03-chat-input {
    flex: 1 1 auto;
    background: #F2F2F2;
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 'Open Sans', sans-serif;
    color: #0A0A0A;
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.18s;
}
#me03-chat-input::placeholder { color: rgba(0,0,0,0.35); }
#me03-chat-input:focus        { border-color: #FFC500; }

#me03-chat-send {
    flex-shrink: 0;
    width: 48px; height: 48px;
    background: #FFC500;
    border: none; border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.18s, transform 0.12s;
}
#me03-chat-send:hover    { background: #E6B000; }
#me03-chat-send:active   { transform: scale(0.93); }
#me03-chat-send:disabled { background: rgba(255,197,0,0.35); cursor: not-allowed; }
#me03-chat-send svg      { width: 24px; height: 24px; fill: #0A0A0A; }

#me03-chat-disclaimer {
    text-align: center;
    font-size: 10px;
    color: rgba(0,0,0,0.3);
    margin-top: 6px;
    letter-spacing: 0.03em;
}

/* ── Welcome message ────────────────────────────────────── */
#me03-chat-welcome {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px 20px; text-align: center;
    gap: 10px;
    color: rgba(0,0,0,0.55);
    font-size: 13px; line-height: 1.55;
}
#me03-chat-welcome strong {
    color: #0A0A0A;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px; font-weight: 700;
}

/* ── Fullscreen input scale-up ──────────────────────────── */
#me03-chat-window.me03-fullscreen #me03-chat-footer  { padding: 16px 24px 20px; }
#me03-chat-window.me03-fullscreen #me03-chat-input   { font-size: 16px; padding: 14px 18px; }
#me03-chat-window.me03-fullscreen #me03-chat-send    { width: 56px; height: 56px; }
#me03-chat-window.me03-fullscreen #me03-chat-send svg { width: 28px; height: 28px; }
#me03-chat-window.me03-fullscreen #me03-chat-messages { padding: 24px 32px; max-width: 860px; margin: 0 auto; width: 100%; box-sizing: border-box; }
#me03-chat-window.me03-fullscreen .me03-bubble        { font-size: 15px; max-width: 72%; }

/* ── Mobile: always full-width at bottom ────────────────── */
@media (max-width: 480px) {
    #me03-chat-window {
        left: 0 !important; right: 0 !important;
        bottom: 0 !important; top: auto !important;
        width: 100% !important;
        height: 75dvh !important;
        border-radius: 12px 12px 0 0 !important;
        border: none !important;
    }
    .me03-resize-handle { display: none; }
    #me03-chat-trigger  { bottom: 16px; right: 16px; }
}
