/* ============================================================
   DPA DEMO BOARD — public, ephemeral chat widget
   Identity: a "chalkboard faculty panel" — deep chalkboard
   green, warm gold accent, parchment note for the guest's
   own messages. Self-contained so the host theme can't bleed in.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&display=swap');

#dpad-workspace, #dpad-workspace * {
    box-sizing: border-box;
}

#dpad-workspace {
    --dpad-board: #16211c;
    --dpad-board-deep: #101a15;
    --dpad-chalk: #eef1ea;
    --dpad-chalk-dim: #a9b6ac;
    --dpad-gold: #e8b64c;
    --dpad-line: #2a3a31;

    background: var(--dpad-board);
    color: var(--dpad-chalk);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 900px;
    margin: 28px auto;
    border-radius: 14px;
    border: 1px solid var(--dpad-line);
    box-shadow: 0 20px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(232,182,76,0.06);
    height: 720px;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* subtle chalk-dust texture */
#dpad-workspace::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 15% 10%, rgba(255,255,255,0.03) 0, transparent 35%),
        radial-gradient(circle at 85% 30%, rgba(232,182,76,0.04) 0, transparent 40%);
    z-index: 0;
}

/* ---------------------------------------------------------
   HEADER
   --------------------------------------------------------- */
.dpad-header {
    background: var(--dpad-board-deep);
    border-bottom: 1px solid var(--dpad-line);
    padding: 20px 24px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}
.dpad-title {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
    font-size: 21px;
    color: var(--dpad-chalk);
    letter-spacing: 0.2px;
}
.dpad-icon { margin-right: 6px; }
.dpad-subtitle {
    font-size: 12px;
    color: var(--dpad-chalk-dim);
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(232,182,76,0.35);
    display: inline-block;
    letter-spacing: 0.3px;
}
.dpad-status {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--dpad-gold);
    white-space: nowrap;
    padding-top: 3px;
}
.dpad-dot {
    display: inline-block;
    width: 7px; height: 7px;
    background: var(--dpad-gold);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 0 0 rgba(232,182,76,0.6);
    animation: dpadPulse 1.8s infinite;
}

/* ---------------------------------------------------------
   GUEST BANNER
   --------------------------------------------------------- */
.dpad-guest-banner {
    background: rgba(232,182,76,0.08);
    border-bottom: 1px solid var(--dpad-line);
    color: var(--dpad-chalk-dim);
    font-size: 12.5px;
    padding: 9px 24px;
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}

/* ---------------------------------------------------------
   STREAM
   --------------------------------------------------------- */
#dpad-stream {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px;
    position: relative;
    z-index: 1;
}
#dpad-stream::-webkit-scrollbar { width: 8px; }
#dpad-stream::-webkit-scrollbar-thumb { background: #23332a; border-radius: 4px; }
#dpad-stream::-webkit-scrollbar-track { background: transparent; }

.dpad-row {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    margin-bottom: 14px;
    animation: dpadFadeIn 0.25s ease;
}
.dpad-row.dpad-own { flex-direction: row-reverse; }

.dpad-avatar {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #1c2b23;
    border: 1.5px solid #3a4c41;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}

.dpad-bubble {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 13px;
    line-height: 1.5;
    font-size: 14.5px;
    word-wrap: break-word;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* Agents — chalk medallion bubbles */
.dpad-row.dpad-other .dpad-bubble {
    background: #1c2b23;
    color: #eef1ea;
    border: 1px solid var(--dpad-line);
    border-top-left-radius: 3px;
}
.dpad-sender {
    font-weight: 700;
    font-size: 12.5px;
    margin-bottom: 3px;
}

/* Guest's own messages — parchment note pinned to the board */
.dpad-row.dpad-own .dpad-bubble {
    background: #f4ecd8;
    color: #2b2416;
    border-top-right-radius: 3px;
}
.dpad-row.dpad-own .dpad-content { color: #2b2416; }

.dpad-content { white-space: pre-wrap; }

.dpad-system-row {
    text-align: center;
    font-size: 12px;
    color: var(--dpad-chalk-dim);
    background: rgba(255,255,255,0.03);
    border: 1px dashed var(--dpad-line);
    border-radius: 10px;
    padding: 6px 14px;
    margin: 12px auto;
    max-width: 82%;
}
.dpad-system-error { color: #ff9d8a; border-color: #5a3630; }

.dpad-typing {
    font-size: 12.5px;
    color: var(--dpad-chalk-dim);
    padding: 6px 4px;
    margin-bottom: 10px;
}
.dpad-typing-dot {
    display: inline-block;
    width: 5px; height: 5px;
    background: var(--dpad-gold);
    border-radius: 50%;
    margin-right: 3px;
    animation: dpadBlink 1.2s infinite ease-in-out;
}
.dpad-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.dpad-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ---------------------------------------------------------
   FOOTER / COMPOSER
   --------------------------------------------------------- */
.dpad-footer {
    padding: 14px 24px 18px;
    background: var(--dpad-board-deep);
    border-top: 1px solid var(--dpad-line);
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}
.dpad-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
#dpad-role-select {
    background: #1c2b23;
    color: var(--dpad-chalk);
    border: 1px solid var(--dpad-line);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
}
.dpad-hint { font-size: 11.5px; color: var(--dpad-chalk-dim); }

.dpad-input-wrapper {
    background: #1c2b23;
    border: 1px solid var(--dpad-line);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}
#dpad-input {
    background: transparent;
    border: none;
    color: var(--dpad-chalk);
    width: 100%;
    min-height: 50px;
    resize: vertical;
    outline: none;
    font-family: inherit;
    font-size: 14.5px;
}
#dpad-input::placeholder { color: #6c7a70; }

.dpad-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

#dpad-btn-send {
    background: transparent;
    border: 1px solid #3a4c41;
    color: var(--dpad-chalk);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
    font-size: 13px;
}
#dpad-btn-send:hover { background: #23332a; }

#dpad-btn-submit {
    background: var(--dpad-gold);
    border: none;
    color: #1c1608;
    padding: 7px 18px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.15s;
    font-size: 13px;
}
#dpad-btn-submit:hover { filter: brightness(1.08); box-shadow: 0 0 14px rgba(232,182,76,0.35); }
#dpad-btn-submit:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

.dpad-footer .dpad-meta {
    font-size: 11px;
    color: #6c7a70;
    margin-top: 9px;
    text-align: center;
}

@keyframes dpadFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes dpadBlink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}
@keyframes dpadPulse {
    0%   { box-shadow: 0 0 0 0 rgba(232,182,76,0.55); }
    70%  { box-shadow: 0 0 0 6px rgba(232,182,76,0); }
    100% { box-shadow: 0 0 0 0 rgba(232,182,76,0); }
}

@media (max-width: 600px) {
    /* Use nearly the full viewport instead of a narrow inset card */
    #dpad-workspace {
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        width: 100%;
    }

    .dpad-header {
        padding: 14px 16px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .dpad-title { font-size: 18px; line-height: 1.3; }
    .dpad-subtitle { font-size: 11px; }
    .dpad-status { align-self: flex-start; }

    .dpad-guest-banner { padding: 8px 16px; font-size: 12px; }

    #dpad-stream { padding: 14px 12px; }
    .dpad-bubble { max-width: 88%; font-size: 14px; padding: 9px 12px; }
    .dpad-avatar { width: 28px; height: 28px; font-size: 14px; }

    .dpad-footer { padding: 12px 12px 14px; }

    /* Role select gets its own full-width row instead of squeezing
       against the hint text — this is what was clipping "Interact as Stud…" */
    .dpad-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    #dpad-role-select {
        width: 100%;
        padding: 9px 10px;
        font-size: 14px;
    }
    .dpad-hint { font-size: 11px; }

    #dpad-input { min-height: 44px; font-size: 16px; } /* 16px prevents iOS auto-zoom on focus */

    /* Stack the two action buttons full-width and thumb-friendly
       instead of two cramped side-by-side buttons */
    .dpad-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    #dpad-btn-send, #dpad-btn-submit {
        width: 100%;
        padding: 11px 14px;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dpad-row, .dpad-dot, .dpad-typing-dot { animation: none; }
}
