/* =============================================================================
   AcademyPilot — shared design tokens & components
   (brand colours are overwritten at runtime from Settings → white-label)
   ============================================================================= */
:root {
    --brand: #5b3df5;
    --brand-rgb: 91, 61, 245;
    --brand-dark: #3e2ab0;
    --brand-soft: #efecfe;
    --accent: #ff6b4a;
    --ink: #0e1027;
    --ink-2: #2a2d45;
    --muted: #646a82;
    --line: #e7e7f0;
    --bg: #f7f7fb;
    --card: #ffffff;
    --mint: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --sky: #0ea5e9;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(14, 16, 39, .06), 0 2px 8px rgba(14, 16, 39, .04);
    --shadow: 0 10px 30px -12px rgba(14, 16, 39, .18), 0 2px 6px rgba(14, 16, 39, .05);
    --shadow-lg: 0 30px 60px -20px rgba(14, 16, 39, .28);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
}

* { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--brand); }
.serif { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; }
.text-muted-2 { color: var(--muted) !important; }
::selection { background: rgba(var(--brand-rgb), .18); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- buttons ---------- */
.btn-ap {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font-weight: 700; font-size: .95rem; letter-spacing: -.005em;
    padding: .78rem 1.35rem; border-radius: 999px; border: 0;
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}
.btn-ap:active { transform: translateY(1px) scale(.99); }
.btn-ap.primary { background: var(--brand); color: #fff; box-shadow: 0 10px 24px -10px rgba(var(--brand-rgb), .8); }
.btn-ap.primary:hover { background: var(--brand-dark); color: #fff; transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(var(--brand-rgb), .85); }
.btn-ap.accent { background: var(--accent); color: #fff; box-shadow: 0 10px 24px -10px var(--accent); }
.btn-ap.accent:hover { filter: brightness(.95); color: #fff; transform: translateY(-2px); }
.btn-ap.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ap.ghost:hover { box-shadow: inset 0 0 0 1.5px rgba(var(--brand-rgb), .5); color: var(--brand); }
.btn-ap.soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-ap.soft:hover { background: rgba(var(--brand-rgb), .16); color: var(--brand-dark); }
.btn-ap.dark { background: var(--ink); color: #fff; }
.btn-ap.dark:hover { background: #000; color: #fff; transform: translateY(-2px); }
.btn-ap.sm { padding: .5rem .95rem; font-size: .85rem; }
.btn-ap.lg { padding: 1rem 1.7rem; font-size: 1.02rem; }
.btn-ap[disabled] { opacity: .55; pointer-events: none; }

.chip {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 700;
    padding: .28rem .65rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap;
}
.chip.mint { background: #dcfce7; color: #047857; }
.chip.amber { background: #fef3c7; color: #b45309; }
.chip.rose { background: #ffe4e6; color: #be123c; }
.chip.sky { background: #e0f2fe; color: #0369a1; }
.chip.gray { background: #eef0f5; color: #475069; }
.chip.dark { background: var(--ink); color: #fff; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s cubic-bezier(.2, .7, .2, 1), transform .8s cubic-bezier(.2, .7, .2, 1); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; } .reveal.d2 { transition-delay: .16s; } .reveal.d3 { transition-delay: .24s; } .reveal.d4 { transition-delay: .32s; }

/* ---------- toasts ---------- */
.ap-toasts { position: fixed; z-index: 3000; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.ap-toast {
    display: flex; gap: .65rem; align-items: flex-start; max-width: min(92vw, 460px);
    background: var(--ink); color: #fff; padding: .85rem 1.1rem; border-radius: 14px; font-size: .9rem; font-weight: 500;
    box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(16px) scale(.98); transition: all .35s cubic-bezier(.2, .8, .2, 1);
}
.ap-toast.show { opacity: 1; transform: none; }
.ap-toast i { font-size: 1.1rem; line-height: 1.3; }
.ap-toast.ok i { color: #34d399; } .ap-toast.info i { color: #7dd3fc; } .ap-toast.warn i { color: #fbbf24; } .ap-toast.ai i { color: #c4b5fd; }
.ap-toast a { color: #c4b5fd; font-weight: 700; }

/* ---------- demo navigation bar (sales-demo helper) ---------- */
.demo-bar {
    position: relative; z-index: 1100; background: #0b0c1d; color: #c9cbe0; font-size: .78rem;
    display: flex; align-items: center; gap: .9rem; padding: .45rem 1rem; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.demo-bar::-webkit-scrollbar { display: none; }
.demo-bar .db-tag { display: inline-flex; align-items: center; gap: .4rem; color: #fff; font-weight: 800; letter-spacing: .02em; }
.demo-bar .db-tag i { color: #a78bfa; }
.demo-bar .db-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.demo-bar a, .demo-bar button { color: #c9cbe0; text-decoration: none; background: none; border: 0; padding: .2rem .55rem; border-radius: 999px; font-weight: 600; font-size: .78rem; }
.demo-bar a:hover, .demo-bar button:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.demo-bar a.on { color: #fff; background: rgba(167, 139, 250, .22); }
.demo-bar .db-sp { flex: 1; }
.demo-bar .db-x { font-size: .95rem; padding: .1rem .4rem; }

/* ---------- avatar ---------- */
.av {
    --av: 38px; width: var(--av); height: var(--av); border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    font-weight: 800; font-size: calc(var(--av) * .36); color: #fff; letter-spacing: .02em;
    background: linear-gradient(135deg, var(--g1, var(--brand)), var(--g2, var(--accent)));
}

/* =============================================================================
   Chat widget (APBot)
   ============================================================================= */
.apc { --apc-w: 392px; font-family: var(--font); }
#apChat { position: fixed; right: 22px; bottom: 22px; z-index: 2000; }
.apc-launch {
    display: flex; align-items: center; gap: .7rem; border: 0; cursor: pointer; color: #fff; text-align: left;
    padding: .55rem 1.1rem .55rem .55rem; border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 18px 40px -14px rgba(var(--brand-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: transform .25s ease, box-shadow .25s ease; position: relative;
}
.apc-launch:hover { transform: translateY(-3px); }
.apc-launch-av {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.25rem;
    background: rgba(255, 255, 255, .18); position: relative;
}
.apc-launch-av::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55);
    animation: apcPulse 2.4s ease-out infinite;
}
@keyframes apcPulse { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }
.apc-launch-txt b { display: block; font-size: .95rem; line-height: 1.1; }
.apc-launch-txt small { opacity: .8; font-size: .74rem; }
.apc-badge { position: absolute; top: -4px; right: -2px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 3px #fff; }
.apc.open .apc-launch { transform: scale(.0); opacity: 0; pointer-events: none; }

.apc-nudge {
    position: absolute; right: 0; bottom: 78px; width: 290px; background: #fff; color: var(--ink); border-radius: 18px 18px 6px 18px;
    padding: .95rem 1.1rem; box-shadow: var(--shadow-lg); font-size: .9rem; line-height: 1.45; cursor: pointer;
    animation: apcIn .45s cubic-bezier(.2, .9, .3, 1.2);
}
.apc-nudge[hidden] { display: none; }
.apc-nudge-x { position: absolute; top: 4px; right: 8px; border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; }
@keyframes apcIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

.apc-panel {
    width: var(--apc-w); height: min(640px, calc(100vh - 110px)); background: #fff; border-radius: 24px; overflow: hidden;
    display: flex; flex-direction: column; box-shadow: 0 40px 80px -24px rgba(14, 16, 39, .45), 0 0 0 1px rgba(14, 16, 39, .06);
}
#apChat .apc-panel { position: absolute; right: 0; bottom: 0; transform-origin: bottom right; transform: scale(.6) translateY(30px); opacity: 0; pointer-events: none; transition: all .35s cubic-bezier(.2, .9, .3, 1.1); }
#apChat.open .apc-panel { transform: none; opacity: 1; pointer-events: auto; }
.apc-inline .apc-panel { width: 100%; height: 100%; box-shadow: none; border-radius: inherit; }

.apc-head {
    display: flex; align-items: center; gap: .75rem; padding: 1rem 1rem 1rem 1.1rem; color: #fff;
    background: radial-gradient(120% 140% at 0% 0%, rgba(255, 255, 255, .22), transparent 50%), linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.apc-av { width: 42px; height: 42px; border-radius: 14px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.apc-who { flex: 1; min-width: 0; }
.apc-who b { display: block; font-size: 1rem; }
.apc-who small { font-size: .74rem; opacity: .88; display: flex; align-items: center; gap: .35rem; }
.apc-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .3); }
.apc-icon { border: 0; background: rgba(255, 255, 255, .14); color: #fff; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.apc-icon:hover { background: rgba(255, 255, 255, .26); }

.apc-body { flex: 1; overflow-y: auto; padding: 1.1rem 1rem .6rem; background: linear-gradient(180deg, #f8f8fc, #fff 40%); display: flex; flex-direction: column; gap: .55rem; scroll-behavior: smooth; }
.apc-msg { display: flex; flex-direction: column; max-width: 88%; }
.apc-msg.in { animation: apcMsg .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes apcMsg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.apc-msg.user { align-self: flex-end; align-items: flex-end; }
.apc-bubble { padding: .65rem .9rem; border-radius: 18px; font-size: .9rem; line-height: 1.5; word-wrap: break-word; }
.apc-msg.bot .apc-bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; color: var(--ink-2); box-shadow: var(--shadow-sm); }
.apc-msg.user .apc-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.apc-msg.typing .apc-bubble { display: flex; gap: 4px; padding: .8rem .95rem; }
.apc-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: #b3b6cc; animation: apcDot 1.2s infinite; }
.apc-msg.typing span:nth-child(2) { animation-delay: .15s; } .apc-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes apcDot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.apc-msg.note { max-width: 100%; flex-direction: row; gap: .5rem; align-items: flex-start; font-size: .78rem; color: #5b21b6; background: #f5f3ff; border: 1px dashed #c4b5fd; border-radius: 12px; padding: .6rem .75rem; }
.apc-msg.note i { color: #7c3aed; margin-top: 2px; }
.apc-msg.note a { font-weight: 800; color: #6d28d9; white-space: nowrap; }

.apc-card { margin-top: .45rem; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-sm); width: 270px; max-width: 100%; }
.apc-card-top { height: 64px; padding: .7rem .9rem; display: flex; justify-content: space-between; align-items: flex-start; color: #fff; background: linear-gradient(135deg, var(--g1), var(--g2)); }
.apc-card-top i { font-size: 1.6rem; }
.apc-card-top span { font-size: .68rem; font-weight: 800; background: rgba(255, 255, 255, .22); padding: .2rem .5rem; border-radius: 999px; }
.apc-card-body { padding: .75rem .9rem .85rem; font-size: .86rem; }
.apc-card-body b { display: block; line-height: 1.3; margin-bottom: .35rem; }
.apc-card-meta { display: flex; gap: .7rem; color: var(--muted); font-size: .78rem; font-weight: 600; }
.apc-card-meta i { color: #f59e0b; }
.apc-card-batch { margin-top: .45rem; font-size: .78rem; color: var(--ink-2); }
.apc-card-batch em { color: var(--rose); font-style: normal; font-weight: 700; }
.apc-card-actions { display: flex; gap: .45rem; margin-top: .7rem; }
.apc-card-actions a, .apc-card-actions button { flex: 1; text-align: center; font-size: .78rem; font-weight: 700; padding: .45rem .5rem; border-radius: 10px; text-decoration: none; border: 0; }
.apc-card-actions a { background: var(--brand-soft); color: var(--brand-dark); }
.apc-card-actions button { background: var(--brand); color: #fff; }

.apc-batches { display: flex; flex-direction: column; gap: .4rem; margin-top: .45rem; width: 290px; max-width: 100%; }
.apc-batch { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'd s' 'm m'; gap: .15rem .5rem; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; font-size: .8rem; transition: border-color .15s, transform .15s; }
.apc-batch:hover { border-color: rgba(var(--brand-rgb), .55); transform: translateX(2px); }
.apc-batch .d { grid-area: d; } .apc-batch .d b { display: block; } .apc-batch .d small { color: var(--muted); }
.apc-batch .m { grid-area: m; color: var(--muted); font-size: .74rem; }
.apc-batch .s { grid-area: s; align-self: start; font-size: .7rem; font-weight: 800; color: #047857; background: #dcfce7; padding: .15rem .45rem; border-radius: 999px; }
.apc-batch .s.low { color: #be123c; background: #ffe4e6; }

.apc-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.apc-links a { font-size: .8rem; font-weight: 700; text-decoration: none; padding: .45rem .75rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); }
.apc-links a:hover { background: rgba(var(--brand-rgb), .18); }

.apc-chips { display: flex; gap: .4rem; padding: .35rem 1rem .5rem; overflow-x: auto; scrollbar-width: none; flex: none; }
.apc-chips::-webkit-scrollbar { display: none; }
.apc-chips:empty { display: none; }
.apc-chips button { flex: none; border: 1.5px solid rgba(var(--brand-rgb), .3); background: #fff; color: var(--brand-dark); font-size: .8rem; font-weight: 700; padding: .4rem .8rem; border-radius: 999px; transition: all .15s; }
.apc-chips button:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.apc-input { display: flex; gap: .5rem; padding: .6rem .8rem .5rem; border-top: 1px solid var(--line); flex: none; }
.apc-input input { flex: 1; border: 1.5px solid var(--line); border-radius: 14px; padding: .65rem .9rem; font-size: .92rem; outline: none; transition: border-color .15s; min-width: 0; }
.apc-input input:focus { border-color: rgba(var(--brand-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .1); }
.apc-input button { width: 44px; border: 0; border-radius: 14px; background: var(--brand); color: #fff; font-size: 1rem; }
.apc-input button:hover { background: var(--brand-dark); }
.apc-foot { text-align: center; font-size: .68rem; color: #9aa0b6; padding: 0 0 .55rem; flex: none; }
.apc-foot b { color: #6b7190; }

@media (max-width: 575.98px) {
    #apChat { right: 14px; bottom: 14px; }
    .apc-launch-txt { display: none; }
    .apc-launch { padding: .5rem; }
    #apChat.open { inset: 0; right: 0; bottom: 0; }
    #apChat.open .apc-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; }
    .apc-nudge { width: min(290px, calc(100vw - 30px)); bottom: 70px; }
}
