/* ═══════════════════════════════════════════════════════════════
   ORSİAD AI Chat Widget  —  Forest green / wood-tone palette
   Supports prefers-color-scheme: dark
   ═══════════════════════════════════════════════════════════════ */

/* ── Custom properties ───────────────────────────────────────── */
:root {
    --oa-green:      #3a7d44;
    --oa-green-dk:   #2a5c30;
    --oa-wood:       #8b5e3c;
    --oa-wood-lt:    #c4956a;
    --oa-bg:         #ffffff;
    --oa-surface:    #f5f7f2;
    --oa-border:     #d4dfd4;
    --oa-text:       #1a2e1a;
    --oa-text-muted: #5a7060;
    --oa-user-bg:    #3a7d44;
    --oa-user-text:  #ffffff;
    --oa-bot-bg:     #eef3ec;
    --oa-bot-text:   #1a2e1a;
    --oa-shadow:     0 8px 32px rgba(0,0,0,.18);
    --oa-radius:     16px;
    --oa-launcher-size: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --oa-bg:         #1c251e;
        --oa-surface:    #243027;
        --oa-border:     #354a38;
        --oa-text:       #e8f0e8;
        --oa-text-muted: #8aab8a;
        --oa-user-bg:    #2a5c30;
        --oa-bot-bg:     #243027;
        --oa-bot-text:   #e8f0e8;
    }
}

/* ── Widget container ─────────────────────────────────────────── */
#orsiad-ai-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
}

/* ── Launcher button ─────────────────────────────────────────── */
#orsiad-ai-launcher {
    width:  var(--oa-launcher-size);
    height: var(--oa-launcher-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--oa-green), var(--oa-green-dk));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--oa-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    outline-offset: 3px;
}

#orsiad-ai-launcher:hover  { transform: scale(1.08); box-shadow: 0 12px 36px rgba(0,0,0,.25); }
#orsiad-ai-launcher:active { transform: scale(.96); }

/* ── Chat modal ──────────────────────────────────────────────── */
#orsiad-ai-modal {
    position: absolute;
    bottom: calc(var(--oa-launcher-size) + 14px);
    right: 0;
    width:  370px;
    max-height: 560px;
    background: var(--oa-bg);
    border: 1px solid var(--oa-border);
    border-radius: var(--oa-radius);
    box-shadow: var(--oa-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.85) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s;
}

#orsiad-ai-modal.orsiad-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────────────── */
.orsiad-modal-header {
    background: linear-gradient(135deg, var(--oa-green), var(--oa-green-dk));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.orsiad-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.orsiad-modal-icon { font-size: 22px; }

.orsiad-modal-title strong {
    display: block;
    font-size: 15px;
    line-height: 1.2;
}

.orsiad-modal-title small {
    font-size: 11px;
    opacity: .8;
}

.orsiad-close-btn {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.orsiad-close-btn:hover { background: rgba(255,255,255,.35); }

/* ── Messages area ───────────────────────────────────────────── */
#orsiad-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--oa-surface);
}

#orsiad-messages::-webkit-scrollbar { width: 4px; }
#orsiad-messages::-webkit-scrollbar-thumb { background: var(--oa-border); border-radius: 2px; }

/* ── Starter prompts ─────────────────────────────────────────── */
.orsiad-starters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 8px;
}

.orsiad-starters p {
    font-size: 12px;
    color: var(--oa-text-muted);
    text-align: center;
    margin: 0 0 4px;
}

.orsiad-starter-btn {
    background: var(--oa-bg);
    border: 1px solid var(--oa-border);
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 13px;
    color: var(--oa-green-dk);
    cursor: pointer;
    text-align: left;
    transition: background .15s, border-color .15s;
    line-height: 1.4;
}

.orsiad-starter-btn:hover {
    background: #e6f2e6;
    border-color: var(--oa-green);
}

@media (prefers-color-scheme: dark) {
    .orsiad-starter-btn { color: #a8d5a8; }
    .orsiad-starter-btn:hover { background: #2a3e2d; }
}

/* ── Message bubbles ─────────────────────────────────────────── */
.orsiad-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    gap: 4px;
    animation: orsiad-pop .18s ease;
}

@keyframes orsiad-pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.orsiad-msg.user  { align-self: flex-end; }
.orsiad-msg.bot   { align-self: flex-start; }

.orsiad-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    line-height: 1.55;
    font-size: 14px;
    word-break: break-word;
}

.orsiad-msg.user .orsiad-bubble {
    background: var(--oa-user-bg);
    color: var(--oa-user-text);
    border-bottom-right-radius: 4px;
}

.orsiad-msg.bot .orsiad-bubble {
    background: var(--oa-bot-bg);
    color: var(--oa-bot-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--oa-border);
}

/* Markdown inside bot bubbles */
.orsiad-bubble p         { margin: 0 0 6px; }
.orsiad-bubble p:last-child { margin-bottom: 0; }
.orsiad-bubble strong    { font-weight: 700; }
.orsiad-bubble a         { color: var(--oa-green); word-break: break-all; }
.orsiad-bubble a:hover   { text-decoration: underline; }
.orsiad-bubble ul, .orsiad-bubble ol { padding-left: 18px; margin: 4px 0; }

/* ── Typing indicator ─────────────────────────────────────────── */
.orsiad-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 13px;
    background: var(--oa-bot-bg);
    border: 1px solid var(--oa-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.orsiad-typing span {
    width: 7px;
    height: 7px;
    background: var(--oa-text-muted);
    border-radius: 50%;
    animation: orsiad-bounce 1.2s infinite;
}

.orsiad-typing span:nth-child(2) { animation-delay: .2s; }
.orsiad-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes orsiad-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* ── Footer / Input ──────────────────────────────────────────── */
.orsiad-modal-footer {
    padding: 10px 12px 8px;
    background: var(--oa-bg);
    border-top: 1px solid var(--oa-border);
    flex-shrink: 0;
}

.orsiad-input-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#orsiad-input {
    flex: 1;
    border: 1px solid var(--oa-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    background: var(--oa-surface);
    color: var(--oa-text);
    max-height: 100px;
    overflow-y: auto;
    transition: border-color .15s;
    font-family: inherit;
}

#orsiad-input:focus { border-color: var(--oa-green); }

#orsiad-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--oa-green);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}

#orsiad-send-btn:hover   { background: var(--oa-green-dk); }
#orsiad-send-btn:disabled { background: var(--oa-border); cursor: default; }

.orsiad-disclaimer {
    font-size: 10px;
    color: var(--oa-text-muted);
    text-align: center;
    margin: 6px 0 0;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 440px) {
    #orsiad-ai-widget { bottom: 16px; right: 16px; }
    #orsiad-ai-modal  { width: calc(100vw - 32px); right: -8px; }
}
