/* =====================================================================
   OstadTools — teacher space & back office (loaded after app.css)
   Teacher: light sidebar, indigo accents. Back office: deep navy sidebar.
   ===================================================================== */
:root {
  --primary: #3b5bdb;
  --primary-hover: #364fc7;
  --primary-soft: #edf1ff;
  --primary-text: #3249b8;
  --bg: #f5f6fb;
  --radius-lg: 16px;
  --accent: #f59f00;
  --accent-soft: #fff4db;
}
[data-bs-theme="dark"] { --primary: #7b93ff; --primary-hover: #95a8ff; --primary-soft: #1d2747; --primary-text: #b4c2ff; }

/* light sidebar (teacher) */
body.area-teacher { --sidebar-bg: #ffffff; --sidebar-text: #3a4160; --sidebar-muted: #9aa1b8; --sidebar-active: #edf1ff; }
[data-bs-theme="dark"] body.area-teacher { --sidebar-bg: #121826; --sidebar-text: #c9cfdc; --sidebar-muted: #7d8699; --sidebar-active: #1d2747; }
body.area-teacher .sidebar { border-inline-end: 1px solid var(--border); }
body.area-teacher .sidebar-brand { color: var(--text); }
body.area-teacher .nav-link-app:hover { background: var(--surface-2); color: var(--primary); }
body.area-teacher .nav-link-app.active { background: var(--sidebar-active); color: var(--primary-text); box-shadow: none; font-weight: 600; }
body.area-teacher .sidebar-footer { border-top-color: var(--border); }
body.area-admin { --sidebar-bg: #0f1430; --sidebar-active: #1d2552; }
.brand-mark { background: linear-gradient(135deg, #5c7cfa, #3b5bdb 60%, #364fc7); box-shadow: 0 6px 14px rgba(59, 91, 219, .3); }
.brand-name b { color: var(--primary); }
body.area-admin .brand-name b { color: #91a7ff; }
.nav-link-app .nav-badge { margin-inline-start: auto; font-size: .68rem; font-weight: 700; padding: .1em .5em; border-radius: 99px; background: var(--danger); color: #fff; }
.nav-link-app .nav-soon { margin-inline-start: auto; font-size: .62rem; font-weight: 700; padding: .12em .5em; border-radius: 99px; background: var(--accent-soft); color: #b45309; }
.nav-link-app .nav-lock { margin-inline-start: auto; opacity: .55; width: 14px; height: 14px; }
.nav-tool-ico { width: 24px; height: 24px; border-radius: 7px; display: inline-grid; place-items: center; background: color-mix(in srgb, var(--tc, #3b5bdb) 14%, transparent); color: var(--tc, #3b5bdb); flex: none; }
.nav-tool-ico .icon { width: 15px !important; height: 15px !important; }
.nav-tool-ico img { width: 16px; height: 16px; }
.nav-sub { display: grid; gap: 1px; margin: 2px 0 6px; padding-inline-start: 1.1rem; border-inline-start: 2px solid var(--border); margin-inline-start: 1.15rem; }
.nav-sub .nav-link-app { padding: .38rem .6rem; font-size: .84rem; }
.nav-sub .nav-link-app .icon { width: 16px; height: 16px; }
body.sidebar-collapsed .nav-sub { display: none; }

/* top bar */
.pack-pill { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .78rem; padding: .3em .75em; border-radius: 99px; color: var(--pc, #64748b); background: color-mix(in srgb, var(--pc, #64748b) 14%, transparent); border: 1px solid color-mix(in srgb, var(--pc, #64748b) 30%, transparent); white-space: nowrap; }
.pack-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mode-pill { font-size: .72rem; font-weight: 700; padding: .25em .7em; border-radius: 99px; background: var(--success-soft); color: var(--success); }
.mode-pill.sub { background: var(--primary-soft); color: var(--primary-text); }

/* banners */
.alert-strip { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; font-size: .9rem; border-bottom: 1px solid var(--border); }
.alert-strip .icon { flex: none; }
.alert-strip .btn { margin-inline-start: auto; }
.alert-strip.warn { background: var(--warning-soft); color: #8a4b06; }
.alert-strip.danger { background: var(--danger-soft); color: var(--danger); }
.alert-strip.info { background: var(--primary-soft); color: var(--primary-text); }
[data-bs-theme="dark"] .alert-strip.warn { color: var(--warning); }
.ann-card { position: relative; display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; border-radius: var(--radius-lg); border: 1px solid var(--border); background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }
.ann-card.offer { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.ann-card.ad { background: linear-gradient(135deg, #f3f0ff, var(--surface)); }
.ann-card img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex: none; }
.ann-card .ann-kind { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.ann-card .btn-close { position: absolute; top: .6rem; inset-inline-end: .6rem; }

/* teacher dashboard */
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.4rem 1.5rem; border-radius: 20px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #7048e8 0%, #3b5bdb 45%, #364fc7 100%); position: relative; overflow: hidden; margin-bottom: 1.25rem; }
.welcome::after { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255, 255, 255, .07); inset-inline-end: -60px; top: -90px; }
.welcome h1 { color: #fff; font-size: 1.45rem; margin: 0 0 .25rem; }
.welcome p { margin: 0; color: rgba(255, 255, 255, .85); }
.welcome .pack-pill { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .3); }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem; }
.tcard { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; color: var(--text); transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s; }
a.tcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); color: var(--text); border-color: color-mix(in srgb, var(--tc) 45%, var(--border)); }
.tcard-thumb { position: relative; aspect-ratio: 16 / 8; background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--tc) 24%, var(--surface)) 0%, color-mix(in srgb, var(--tc) 7%, var(--surface)) 60%); display: grid; place-items: center; overflow: hidden; }
.tcard-thumb img.cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tcard-icon { width: 60px; height: 60px; border-radius: 18px; background: var(--surface); color: var(--tc); display: grid; place-items: center; box-shadow: 0 10px 24px color-mix(in srgb, var(--tc) 30%, transparent); position: relative; z-index: 1; }
.tcard-icon .icon { width: 28px; height: 28px; }
.tcard-icon img { width: 34px; height: 34px; }
.tcard-body { padding: .95rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.tcard-body h3 { font-size: 1rem; margin: 0; }
.tcard-body p { font-size: .86rem; color: var(--text-muted); margin: 0; flex: 1; }
.tcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .6rem; font-size: .84rem; font-weight: 600; color: var(--tc); }
.tcard .tbadge { position: absolute; top: .7rem; inset-inline-end: .7rem; z-index: 2; font-size: .7rem; font-weight: 700; padding: .2em .65em; border-radius: 99px; background: var(--surface); color: var(--text-muted); box-shadow: var(--shadow-sm); }
.tcard .tbadge.soon { color: #b45309; background: var(--accent-soft); }
.tcard.locked .tcard-thumb { filter: grayscale(.65); opacity: .8; }
.tcard.locked .tcard-foot { color: var(--text-muted); }
.quick-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.qtile { display: flex; align-items: center; gap: .65rem; padding: .8rem .9rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; font-size: .9rem; transition: border-color .15s, transform .15s; }
.qtile:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.qtile .stat-icon { flex: none; }

/* subscription */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.plan { position: relative; border: 1.5px solid var(--border); border-radius: 18px; padding: 1.2rem; background: var(--surface); display: flex; flex-direction: column; gap: .6rem; }
.plan.current { border-color: var(--pc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 15%, transparent); }
.plan .price { font-size: 1.7rem; font-weight: 750; letter-spacing: -.02em; }
.plan .price small { font-size: .85rem; font-weight: 500; color: var(--text-muted); }
.plan ul { list-style: none; padding: 0; margin: 0; font-size: .88rem; display: grid; gap: .3rem; flex: 1; align-content: start; }
.plan ul li::before { content: "✓"; color: var(--success); font-weight: 700; margin-inline-end: .4rem; }
.plan ul li.soon { color: var(--text-muted); }
.plan .ribbon { position: absolute; top: -.7rem; inset-inline-end: 1rem; background: var(--primary); color: #fff; font-size: .7rem; font-weight: 700; padding: .2em .7em; border-radius: 99px; }
.sub-hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; }
.progress-time { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-time span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #7048e8); }
.bank-card { border: 1px dashed var(--border-strong); border-radius: 14px; padding: .9rem 1rem; background: var(--surface-2); }
.bank-card .rib { font-family: ui-monospace, Consolas, monospace; font-size: .95rem; letter-spacing: .03em; }
.upload-drop { border: 2px dashed var(--border-strong); border-radius: 16px; padding: 1.3rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; display: block; }
.upload-drop:hover, .upload-drop.drag { border-color: var(--primary); background: var(--primary-soft); }
.upload-drop img.preview { max-height: 180px; margin: .6rem auto 0; border-radius: 10px; }
@media (max-width: 991.98px) { .sub-hero { grid-template-columns: 1fr; } }

/* status badges */
.badge-status { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .22em .65em; border-radius: 99px; white-space: nowrap; }
.bs-success { background: var(--success-soft); color: var(--success); }
.bs-warning { background: var(--warning-soft); color: var(--warning); }
.bs-danger { background: var(--danger-soft); color: var(--danger); }
.bs-info { background: var(--info-soft); color: var(--info); }
.bs-secondary { background: var(--surface-3); color: var(--text-muted); }

/* floating contact button */
.contact-fab { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 1040; }
.contact-fab > button { width: 58px; height: 58px; border-radius: 50%; border: 0; color: #fff; background: linear-gradient(135deg, #5c7cfa, #3b5bdb); box-shadow: 0 12px 30px rgba(59, 91, 219, .45); display: grid; place-items: center; transition: transform .2s var(--ease); position: relative; }
.contact-fab > button:hover { transform: scale(1.06); }
.contact-fab > button .icon { width: 26px; height: 26px; }
.contact-fab .fab-dot { position: absolute; top: 2px; inset-inline-end: 2px; min-width: 20px; height: 20px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.contact-panel { position: absolute; bottom: 72px; inset-inline-end: 0; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 24px 60px rgba(16, 24, 40, .22); overflow: hidden; transform-origin: bottom right; animation: fabIn .2s var(--ease); }
[dir="rtl"] .contact-panel { transform-origin: bottom left; }
.contact-panel[hidden] { display: none; }
.contact-head { padding: 1rem 1.1rem; color: #fff; background: linear-gradient(135deg, #3b5bdb, #5f3dc4); }
.contact-head strong { display: block; font-size: 1rem; }
.contact-head span { font-size: .82rem; opacity: .85; }
.contact-body { padding: 1rem 1.1rem; display: grid; gap: .6rem; }
.btn-wa { background: #25a244; border-color: #25a244; color: #fff; }
.btn-wa:hover { background: #1e8a39; color: #fff; }
@keyframes fabIn { from { opacity: 0; transform: translateY(8px) scale(.97) } to { opacity: 1; transform: none } }

/* messages */
.thread { display: flex; flex-direction: column; gap: .7rem; max-height: 60vh; overflow-y: auto; padding: .25rem; }
.bubble { max-width: 78%; padding: .65rem .9rem; border-radius: 16px; font-size: .92rem; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--primary); color: #fff; border-end-end-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--surface-3); border-end-start-radius: 4px; }
.bubble .meta { display: block; font-size: .7rem; opacity: .75; margin-top: .25rem; }
.conv-item { display: flex; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); align-items: center; }
.conv-item:hover { background: var(--surface-2); color: var(--text); }
.conv-item.unread strong { color: var(--primary-text); }
.conv-item .count { margin-inline-start: auto; background: var(--primary); color: #fff; border-radius: 99px; font-size: .7rem; font-weight: 700; padding: .1em .55em; }

/* admin */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; color: var(--text); transition: border-color .15s; }
a.kpi:hover { border-color: var(--primary); color: var(--text); }
.kpi .k-label { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: .45rem; }
.kpi .k-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; }
.kpi .k-hint { font-size: .76rem; color: var(--text-subtle); }
.kpi.alert-k { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: linear-gradient(135deg, var(--warning-soft), var(--surface)); }
.table-app td .avatar { width: 30px; height: 30px; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters .form-control, .filters .form-select { width: auto; min-width: 140px; }
.mode-switch { display: flex; align-items: center; gap: .5rem; }
.err-trace { background: #0f1430; color: #d6dcf5; border-radius: 12px; padding: 1rem; font-size: .8rem; max-height: 420px; overflow: auto; white-space: pre; }
.thumb-sm { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--surface-3); display: inline-grid; place-items: center; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; vertical-align: middle; }
.proof-view img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.proof-view iframe { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 12px; }
