/* ────────────────────────────────────────────────────────────────
   ARABOO LMS — AI HELP DESK
   Consumes global design tokens from _tokens.css. Scoped under
   .ahd-root so the shortcode can sit inside any host page chrome
   without leaking into surrounding content.
   ──────────────────────────────────────────────────────────────── */

.ahd-root {
    width: 100%;
    max-width: 100%;
    margin: 24px 0;
    padding: 22px 24px 24px;
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--sage-pale, #E0EAE9);
    border-radius: var(--radius-md, 14px);
    box-shadow: var(--shadow-sm, 0 2px 6px rgba(22, 54, 59, 0.08));
    font-family: var(--font-chrome, 'Poppins', system-ui, sans-serif);
    color: var(--ink, #355157);
    line-height: 1.55;
    box-sizing: border-box;
}
.ahd-root *, .ahd-root *::before, .ahd-root *::after { box-sizing: border-box; }

/* ── Header ─────────────────────────────────────────────────── */
.ahd-head {
    display: flex; align-items: center; gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--sage-pale, #E0EAE9);
    margin-bottom: 18px;
}
.ahd-head-icon {
    width: 42px; height: 42px;
    flex-shrink: 0;
    border-radius: var(--radius-sm, 8px);
    background: var(--surface-mint, #EDF7F6);
    color: var(--teal-primary, #1F9F94);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.ahd-head-text { min-width: 0; }
.ahd-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--ink-deep, #16363B);
    letter-spacing: -0.005em;
}
.ahd-head-ar {
    margin: 2px 0 0;
    font-family: var(--font-arabic, 'Noto Sans Arabic', sans-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft, #5E7A7E);
}

/* ── Lock card (logged-out fallback) ───────────────────────── */
.ahd-locked {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    text-align: center;
    padding: 28px 20px;
    background: var(--surface-mint, #EDF7F6);
    border-radius: var(--radius-sm, 8px);
}
.ahd-locked i {
    font-size: 36px;
    color: var(--teal-primary, #1F9F94);
}
.ahd-locked p { margin: 0; color: var(--ink-soft, #5E7A7E); font-size: 14px; }
.ahd-cta {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 4px;
    padding: 8px 18px;
    border-radius: var(--radius-sm, 8px);
    background: var(--teal-primary, #1F9F94);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}
.ahd-cta:hover { background: var(--ink-deep, #16363B); color: #FFFFFF; }

/* ── Form ──────────────────────────────────────────────────── */
.ahd-form { display: flex; flex-direction: column; gap: 10px; }
.ahd-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--sage-pale, #E0EAE9);
    border-radius: var(--radius-sm, 8px);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink-deep, #16363B);
    resize: vertical;
    min-height: 80px;
    transition: border-color .15s, box-shadow .15s;
}
.ahd-input::placeholder { color: var(--ink-muted, #8AA2A4); }
.ahd-input:focus {
    outline: none;
    border-color: var(--teal-primary, #1F9F94);
    box-shadow: 0 0 0 3px rgba(31, 159, 148, 0.15);
}
.ahd-actions {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.ahd-meta {
    font-size: 12px;
    color: var(--ink-muted, #8AA2A4);
    font-variant-numeric: tabular-nums;
}

/* Buttons carry an aw-* prefix so Funcare's catch-all submit/button
   sage paint doesn't grab them on the front-end. */
.ahd-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border: 0;
    border-radius: var(--radius-sm, 8px);
    background: var(--btn-bg, #7CAE7C);
    color: #FFFFFF !important;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 700 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    cursor: pointer;
    transition: background .15s, transform .12s;
}
.ahd-btn:hover {
    background: var(--btn-bg-hover, #62A062);
    transform: translateY(-1px);
}
.ahd-btn:disabled,
.ahd-btn.is-busy {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}
.ahd-btn-primary i { font-size: 16px; }

/* ── Response area ─────────────────────────────────────────── */
.ahd-response {
    margin-top: 16px;
    padding: 16px 18px;
    border-radius: var(--radius-sm, 8px);
    background: var(--surface-mint, #EDF7F6);
    border: 1px solid var(--sage-pale, #E0EAE9);
    color: var(--ink, #355157);
    font-size: 14.5px;
    line-height: 1.6;
}
.ahd-response[dir="rtl"] {
    font-family: var(--font-arabic, 'Noto Sans Arabic', sans-serif);
    font-size: 16px;
    text-align: right;
}
.ahd-response p { margin: 0 0 12px; }
.ahd-response p:last-child { margin-bottom: 0; }
.ahd-response ol,
.ahd-response ul {
    margin: 8px 0 12px;
    padding-inline-start: 22px;
}
.ahd-response li { margin-bottom: 4px; }
.ahd-response strong { color: var(--ink-deep, #16363B); }
.ahd-response code {
    padding: 1px 6px;
    background: rgba(31, 159, 148, 0.12);
    color: var(--teal-primary, #1F9F94);
    border-radius: 4px;
    font-family: var(--font-mono, monospace);
    font-size: 0.9em;
}

/* Figure (image embed) — click to lightbox */
.ahd-figure {
    margin: 14px 0;
    padding: 0;
    text-align: center;
}
.ahd-figure img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--sage-pale, #E0EAE9);
    background: var(--surface, #FFFFFF);
    display: inline-block;
    cursor: zoom-in;
    transition: transform .15s, box-shadow .15s;
}
.ahd-figure img:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md, 0 6px 18px rgba(22, 54, 59, 0.10));
}

/* ── Lightbox overlay ──────────────────────────────────────── */
.ahd-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483600;     /* sit above admin bars + theme chrome */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.84);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    cursor: zoom-out;
    box-sizing: border-box;
}
.ahd-lightbox.is-open {
    opacity: 1;
    pointer-events: auto;
}
.ahd-lightbox-stage {
    position: relative;
    max-width: min(1200px, 96vw);
    max-height: 92vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ahd-lightbox img {
    display: block;
    max-width: 100%;
    max-height: 92vh;
    width: auto;
    height: auto;
    border-radius: var(--radius-md, 14px);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    background: #FFFFFF;
    cursor: default;
}
.ahd-lightbox-close {
    position: absolute;
    top: -16px; right: -16px;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 0;
    background: #FFFFFF;
    color: var(--ink-deep, #16363B);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.ahd-lightbox-close:hover { background: var(--surface-mint, #EDF7F6); }
.ahd-lightbox-caption {
    position: absolute;
    left: 0; right: 0; bottom: -34px;
    text-align: center;
    color: rgba(255, 255, 255, 0.78);
    font-size: 12.5px;
    font-family: var(--font-chrome, 'Poppins', system-ui, sans-serif);
}
@media (max-width: 540px) {
    .ahd-lightbox { padding: 12px; }
    .ahd-lightbox-close { top: -10px; right: -10px; width: 36px; height: 36px; }
}

/* Loading + error states */
.ahd-loading,
.ahd-error {
    display: flex; align-items: center; gap: 8px;
    color: var(--ink-soft, #5E7A7E);
    font-size: 14px;
}
.ahd-loading i { color: var(--teal-primary, #1F9F94); font-size: 18px; }
.ahd-error    { color: var(--accent-coral, #E97A4F); }
.ahd-error i  { font-size: 18px; }
.ph-spin      { animation: ahd-spin 1s linear infinite; }
@keyframes ahd-spin { to { transform: rotate(360deg); } }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 540px) {
    .ahd-root { padding: 18px 16px 20px; margin: 16px 12px; }
    .ahd-head h3 { font-size: 16px; }
    .ahd-input   { font-size: 14.5px; }
    .ahd-actions { flex-wrap: wrap; }
}
