/* AILA Showcase — shared styling */

:root {
  /* AILA brand — extracted from logo (3 dominant hues: violet / teal / cyan) */
  --aila-purple:   #7C3AED;
  --aila-purple-2: #8B5CF6;
  --aila-teal:     #14B8A6;
  --aila-teal-2:   #2DD4BF;
  --aila-cyan:     #22D3EE;
  --aila-deep:     #4C1D95;  /* dark violet, for surfaces on dark gradients */

  /* Legacy var names — re-mapped to new brand palette so existing components inherit. */
  --aila-blue:    var(--aila-purple);     /* primary */
  --aila-blue-2:  var(--aila-purple-2);   /* primary hover */
  --aila-accent:  var(--aila-teal);       /* accent (was orange) */

  --bg:           #f7f6fb;                /* very subtle violet tint instead of cool grey */
  --surface:      #ffffff;
  --border:       #e6e3ee;
  --text:         #1f1733;
  --text-muted:   #6a6379;

  /* Tier colors — kept distinct from brand to remain readable as data colors */
  --tier-strong:           #c0392b;
  --tier-transfer:         #8e44ad;
  --tier-scaffolded:       #16a085;
  --tier-representational: #95a5a6;

  /* Subject palette — kept blue/green/orange for perceptual differentiation
     (shifted slightly toward modern hues to harmonize with the brand). */
  --subject-math:    #2563eb;   /* indigo-blue */
  --subject-science: #059669;   /* emerald */
  --subject-reading: #ea580c;   /* warm orange */

  --shadow: 0 1px 2px rgba(30,20,60,.05), 0 4px 12px rgba(30,20,60,.06);
  --shadow-strong: 0 8px 24px rgba(30,20,60,.12);

  /* Brand gradient — useful for topbar accent strips, hero panels */
  --aila-gradient: linear-gradient(135deg, var(--aila-purple) 0%, var(--aila-cyan) 50%, var(--aila-teal) 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Cairo", "Tajawal", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
}

[dir="rtl"], .rtl, .ar { direction: rtl; text-align: right;
  font-family: "Cairo", "Tajawal", "Noto Sans Arabic", -apple-system, sans-serif;
  font-size: 16px; line-height: 1.7; }

a { color: var(--aila-blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); padding: 8px 14px; border-radius: 6px;
  color: var(--text);
}
button.primary { background: var(--aila-blue); color: white; border-color: var(--aila-blue); }
button.primary:hover { background: var(--aila-blue-2); }
button:disabled { opacity: .5; cursor: not-allowed; }

input[type=email], input[type=password], input[type=text] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; width: 100%; background: var(--surface);
}
input:focus { outline: 2px solid var(--aila-blue-2); outline-offset: -1px; }

/* App chrome */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--aila-purple); }
.topbar .brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--aila-purple); color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 800; letter-spacing: -1px;
}
.topbar .brand-mark-img {
  width: 32px; height: 32px; object-fit: contain;
  flex-shrink: 0;
}
/* Subtle brand accent line under the topbar */
.topbar { position: sticky; top: 0; z-index: 10; }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--aila-gradient); opacity: 0.85;
}
.topbar .ui-tabs { display: flex; gap: 4px; }
.topbar .ui-tabs a {
  padding: 6px 12px; border-radius: 6px; color: var(--text-muted);
  font-size: 13px; font-weight: 500;
}
.topbar .ui-tabs a.active { background: var(--bg); color: var(--text); }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }

.footer {
  padding: 24px; text-align: center; color: var(--text-muted);
  font-size: 12px; border-top: 1px solid var(--border); margin-top: 40px;
}
.footer .stamp { font-weight: 600; color: var(--aila-blue); }

/* Cards / panels */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px; box-shadow: var(--shadow);
}

/* Layouts */
.layout-3col { display: grid; grid-template-columns: 280px 1fr 320px;
  gap: 18px; padding: 18px 24px; max-width: 1700px; margin: 0 auto; }
.layout-1col { max-width: 1280px; margin: 0 auto; padding: 18px 24px; }

@media (max-width: 1200px) {
  .layout-3col { grid-template-columns: 240px 1fr; gap: 14px; padding: 14px 18px; }
  .layout-3col .right,
  .layout-3col > aside:last-child { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
  .layout-3col { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
}

/* Topbar adaptive — brand text shrinks/hides on small screens */
@media (max-width: 768px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .brand span:not(.brand-mark-img) { font-size: 13px; }
  .topbar .ui-tabs a { padding: 5px 8px; font-size: 12px; }
  .topbar .user { font-size: 11px; gap: 6px; }
}
@media (max-width: 520px) {
  .topbar .brand span:not(.brand-mark-img) { display: none; }
  .topbar .ui-tabs { gap: 2px; }
}

/* Tables overflow gracefully on narrow screens */
@media (max-width: 768px) {
  .aila-table { font-size: 12px; }
  .aila-table th, .aila-table td { padding: 7px 9px; }
  .question-text { font-size: 16px; padding: 14px; }
  .options { gap: 6px; }
  .option { padding: 10px 12px; }
}

/* Pedagogy tags */
.pedagogy-section { margin-top: 16px; }
.pedagogy-section h3 { font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); margin: 18px 0 8px; font-weight: 600; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: #eef2f7; color: var(--text); margin: 2px 4px 2px 0;
}
.tag .tag-label { color: var(--text-muted); font-size: 11px; }
.tag .tag-value { font-weight: 600; }
.citation { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-style: italic; }

/* Subject pills */
.subject-pill { display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: white; }
.subject-pill.math    { background: var(--subject-math); }
.subject-pill.science { background: var(--subject-science); }
.subject-pill.reading { background: var(--subject-reading); }

/* Tier dots */
.tier-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.tier-dot.strong           { background: var(--tier-strong); }
.tier-dot.transfer         { background: var(--tier-transfer); }
.tier-dot.scaffolded       { background: var(--tier-scaffolded); }
.tier-dot.representational { background: var(--tier-representational); }

/* Index list */
.index-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 140px); overflow-y: auto; }
.index-item { padding: 10px 12px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.index-item:hover { background: #f1f4f8; }
.index-item.active { background: var(--aila-blue); color: white; border-color: var(--aila-blue); }
.index-item.active .meta { color: rgba(255,255,255,0.85); }
.index-item .qid { font-family: "SF Mono", Menlo, monospace; font-size: 12px; }
.index-item .meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Question card */
.question-text { font-size: 18px; line-height: 1.8; padding: 20px;
  background: #fafbfc; border-left: 3px solid var(--aila-blue);
  border-radius: 6px; margin-bottom: 18px; }
[dir=rtl] .question-text { border-left: none; border-right: 3px solid var(--aila-blue); }
.options { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.option {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: 6px;
  cursor: default;
}
.option.correct { border-color: #2e8b57; background: #e9f7ef;
  border-width: 2px; }
.option .label { font-weight: 700; color: var(--text-muted); margin-right: 8px; }
[dir=rtl] .option .label { margin-right: 0; margin-left: 8px; }

.visual-wrap { margin: 16px 0; padding: 16px; background: #fafbfc; border-radius: 6px; text-align: center; }
.visual-wrap svg { max-width: 100%; height: auto; }

/* AILA table renderer — used for question.table data */
.aila-table-desc {
  font-size: 13px; color: var(--text-muted); margin: 6px 0; font-style: italic;
}
.aila-table-wrap {
  margin: 14px 0; padding: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; overflow-x: auto;
}
.aila-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  font-family: -apple-system, "Cairo", "Tajawal", sans-serif;
}
.aila-table th, .aila-table td {
  padding: 10px 14px; border: 1px solid var(--border); text-align: center;
  white-space: nowrap;
}
.aila-table th {
  background: color-mix(in srgb, var(--aila-purple) 8%, white);
  color: var(--aila-purple); font-weight: 700;
  border-bottom: 2px solid color-mix(in srgb, var(--aila-purple) 30%, transparent);
}
.aila-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--aila-cyan) 4%, white); }
.aila-table tbody tr:hover td        { background: color-mix(in srgb, var(--aila-teal) 8%, white); }
.aila-table tbody td:first-child {
  font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--aila-teal) 6%, white) !important;
}

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #5B21B6 0%, #1E1B4B 50%, #134E4A 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-wrap::before {
  /* Soft radial accent in cyan to echo the logo */
  content: ""; position: absolute; top: -200px; left: -200px;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34,211,238,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.login-wrap::after {
  content: ""; position: absolute; bottom: -200px; right: -200px;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(45,212,191,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  background: var(--surface); padding: 40px 36px; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,5,40,0.45); width: 100%; max-width: 400px;
  position: relative; z-index: 1;
}
.login-card .brand-mark-img {
  width: 56px; height: 56px; object-fit: contain;
  margin: 0 auto 18px; display: block;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--aila-purple); text-align: center; }
.login-card .sub { text-align: center; }
.login-card .sub { color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; color: var(--text-muted);
  margin: 14px 0 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.login-card .err { color: #c0392b; font-size: 13px; margin: 12px 0; min-height: 18px; }

/* Analytical */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.chart-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin: 0 0 8px; font-weight: 600; }
.chart-panel canvas { max-height: 260px; }
.graph-panel { margin-top: 24px; }
.graph-panel svg { background: #fafbfc; border-radius: 8px; }
.graph-controls { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.graph-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,50,0.5); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal { background: var(--surface); border-radius: 10px; max-width: 700px;
  width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-close { float: right; cursor: pointer; color: var(--text-muted); font-size: 20px;
  background: transparent; border: none; padding: 0; }
[dir=rtl] .modal-close { float: left; }

/* Loading */
.loading { color: var(--text-muted); font-style: italic; text-align: center; padding: 40px; }
.error { color: #c0392b; padding: 12px; background: #fdedec; border-radius: 6px; margin: 12px 0; }
