/**
 * SlideMind Chat Widget Styles
 *
 * Static CSS for the autonomous widget page (loaded inside SCORM/xAPI iframes).
 * Dynamic theme colors are set via inline :root custom properties in widget.php.
 *
 * @package SlideMind
 * @since 2.7.0
 */

/* ── Reset & Base ─────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

/* ── Light theme ──────────────────────────────────────── */
[data-theme="light"]{
    --sm-bg:#ffffff;
    --sm-bg-alt:#f8fafc;
    --sm-text:#1e293b;
    --sm-text-muted:#64748b;
    --sm-border:#e2e8f0;
    --sm-user-bg:var(--sm-primary);
    --sm-user-text:#ffffff;
    --sm-ai-bg:var(--sm-ai-bg-custom, #f1f5f9);
    --sm-ai-text:var(--sm-ai-text-custom, #1e293b);
    --sm-input-bg:#ffffff;
    --sm-shadow:0 1px 3px rgba(0,0,0,0.08);
}

/* ── Dark theme ───────────────────────────────────────── */
[data-theme="dark"]{
    --sm-bg:#0f172a;
    --sm-bg-alt:#1e293b;
    --sm-text:#e2e8f0;
    --sm-text-muted:#94a3b8;
    --sm-border:#334155;
    --sm-user-bg:var(--sm-primary);
    --sm-user-text:#ffffff;
    --sm-ai-bg:var(--sm-ai-bg-custom, #1e293b);
    --sm-ai-text:var(--sm-ai-text-custom, #e2e8f0);
    --sm-input-bg:#1e293b;
    --sm-shadow:0 1px 3px rgba(0,0,0,0.3);
}

html,body{height:100%;overflow:hidden}
body{
    font-family:var(--sm-font);
    font-size:14px;
    line-height:1.5;
    color:var(--sm-text);
    background:var(--sm-bg);
    display:flex;
    flex-direction:column;
}

/* ── Header ───────────────────────────────────────────── */
.sm-w-header{
    padding:12px 16px;
    background:var(--sm-primary);
    color:#fff;
    display:flex;
    align-items:center;
    gap:10px;
    flex-shrink:0;
}
.sm-w-header h1{font-size:15px;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sm-w-header button{
    background:rgba(255,255,255,0.2);
    border:none;
    color:#fff;
    width:28px;height:28px;
    border-radius:6px;
    cursor:pointer;
    font-size:14px;
    display:flex;align-items:center;justify-content:center;
    transition:background .15s;
}
.sm-w-header button:hover{background:rgba(255,255,255,0.35)}

/* ── Messages area ────────────────────────────────────── */
.sm-w-messages{
    flex:1;
    overflow-y:auto;
    padding:16px;
    display:flex;
    flex-direction:column;
    gap:12px;
}
.sm-w-messages::-webkit-scrollbar{width:4px}
.sm-w-messages::-webkit-scrollbar-thumb{background:var(--sm-border);border-radius:2px}

/* ── Message bubbles ──────────────────────────────────── */
.sm-w-msg{
    max-width:85%;
    padding:10px 14px;
    border-radius:var(--sm-radius);
    word-wrap:break-word;
    white-space:pre-wrap;
    animation:smFadeIn .2s ease;
}
.sm-w-msg--user{
    align-self:flex-end;
    background:var(--sm-user-bg);
    color:var(--sm-user-text);
    border-bottom-right-radius:4px;
}
.sm-w-msg--ai{
    align-self:flex-start;
    background:var(--sm-ai-bg);
    color:var(--sm-ai-text);
    border-bottom-left-radius:4px;
}
.sm-w-msg--error{
    align-self:center;
    background:#fef2f2;
    color:#dc2626;
    border:1px solid #fecaca;
    font-size:13px;
    text-align:center;
}
[data-theme="dark"] .sm-w-msg--error{
    background:#450a0a;
    color:#fca5a5;
    border-color:#7f1d1d;
}

/* ── Typing indicator ─────────────────────────────────── */
.sm-w-typing{
    align-self:flex-start;
    display:none;
    gap:4px;
    padding:12px 16px;
    background:var(--sm-ai-bg);
    border-radius:var(--sm-radius);
    border-bottom-left-radius:4px;
}
.sm-w-typing.active{display:flex}
.sm-w-typing span{
    width:6px;height:6px;
    background:var(--sm-text-muted);
    border-radius:50%;
    animation:smBounce 1.4s infinite ease-in-out both;
}
.sm-w-typing span:nth-child(1){animation-delay:-0.32s}
.sm-w-typing span:nth-child(2){animation-delay:-0.16s}

/* ── Quiz feedback ────────────────────────────────────── */
.sm-w-feedback{
    padding:12px 14px;
    border-radius:var(--sm-radius);
    background:var(--sm-ai-bg);
    color:var(--sm-ai-text);
}

/* ── Input area ───────────────────────────────────────── */
.sm-w-input{
    padding:12px 16px;
    border-top:1px solid var(--sm-border);
    display:flex;
    gap:8px;
    flex-shrink:0;
    background:var(--sm-bg);
}
.sm-w-input textarea{
    flex:1;
    resize:none;
    border:1px solid var(--sm-border);
    border-radius:8px;
    padding:8px 12px;
    font-family:var(--sm-font);
    font-size:14px;
    line-height:1.4;
    color:var(--sm-text);
    background:var(--sm-input-bg);
    outline:none;
    min-height:38px;
    max-height:120px;
    transition:border-color .15s;
}
.sm-w-input textarea:focus{border-color:var(--sm-primary)}
.sm-w-input textarea::placeholder{color:var(--sm-text-muted)}
.sm-w-input button{
    width:38px;height:38px;
    border:none;
    border-radius:8px;
    background:var(--sm-primary);
    color:#fff;
    cursor:pointer;
    display:flex;align-items:center;justify-content:center;
    flex-shrink:0;
    transition:background .15s;
}
.sm-w-input button:hover{background:var(--sm-primary-hover)}
.sm-w-input button:disabled{opacity:0.5;cursor:not-allowed}

/* ── Empty state ──────────────────────────────────────── */
.sm-w-empty{
    flex:1;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--sm-text-muted);
    font-size:13px;
    text-align:center;
    padding:24px;
}

/* ── Animations ───────────────────────────────────────── */
@keyframes smFadeIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
@keyframes smBounce{0%,80%,100%{transform:scale(0)}40%{transform:scale(1)}}

/* ── Session end banner (graceful close) ─────────────── */
.sm-w-session-end{
    align-self:center;
    background:var(--sm-bg-alt);
    color:var(--sm-text-muted);
    font-size:12px;
    text-align:center;
    padding:8px 16px;
    border-radius:20px;
    border:1px solid var(--sm-border);
    animation:smFadeIn .2s ease;
}

/* ── Accessibility ────────────────────────────────────── */
@media (prefers-reduced-motion:reduce){
    *{animation-duration:0.01ms !important;transition-duration:0.01ms !important}
}
