/* Aurora — modern "Cool & Focused" theme for RemoteTeacher.
 * Reimplements the motif-* class contract with modern visuals.
 * Light by default; dark via <html data-theme="dark">. */

:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F1F3F7;
  --border: #E4E7EC;
  --text: #1E2433;
  --muted: #5B6472;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-contrast: #FFFFFF;
  --ok: #16A34A;
  --warn: #D97706;
  --err: #DC2626;
  --info: #2563EB;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --shadow-md: 0 4px 12px rgba(16,24,40,.10), 0 2px 4px rgba(16,24,40,.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --focus-ring: 0 0 0 3px rgba(79,70,229,.35);
}

[data-theme="dark"] {
  --bg: #0F1420;
  --surface: #1A2233;
  --surface-2: #222C40;
  --border: #2A3447;
  --text: #E6EAF2;
  --muted: #9AA4B6;
  --accent: #818CF8;
  --accent-hover: #A5B4FC;
  --accent-contrast: #0F1420;
  --ok: #4ADE80;
  --warn: #FBBF24;
  --err: #F87171;
  --info: #60A5FA;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.40), 0 1px 3px rgba(0,0,0,.50);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.40);
  --focus-ring: 0 0 0 3px rgba(129,140,248,.40);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
body { margin: 0; padding: 16px; }

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); margin: 0 0 10px; line-height: 1.25; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
h4, h5, h6 { font-size: 14px; }

p, ul, ol, dl, pre, blockquote, table { margin: 0 0 12px; }
ul, ol { padding-left: 22px; }
dt { font-weight: 700; } dd { margin: 0 0 6px 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:visited { color: var(--accent); }

small { font-size: 12px; }

hr { border: none; height: 1px; background: var(--border); margin: 14px 0; }

code, kbd, samp {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "DejaVu Sans Mono", "Courier New", monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}
pre {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "DejaVu Sans Mono", "Courier New", monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
mark { background: #FDE68A; color: #1E2433; padding: 0 3px; border-radius: 4px; }
blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0 0 12px;
}

/* ── Forms ─────────────────────────────────────────────── */
fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; margin: 0 0 12px; background: var(--surface); }
legend { font-weight: 700; padding: 0 6px; }
label { display: inline-block; margin-bottom: 4px; color: var(--text); }
.motif-form-row { margin-bottom: 14px; }
.motif-form-row > label { display: block; margin-bottom: 6px; font-weight: 600; }
.motif-full { width: 100%; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="tel"], input[type="url"], input[type="date"],
input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"],
textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
textarea { min-height: 88px; resize: vertical; }
select { padding-right: 28px; }
select[multiple] { padding-right: 8px; min-height: 88px; }

input[type="file"] { color: var(--text); font-size: 14px; }
input[type="color"] { padding: 0; width: 40px; height: 30px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }

input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; margin: 0 6px 0 0; cursor: pointer; }

input[type="range"] { accent-color: var(--accent); width: 180px; }

/* ── Buttons ───────────────────────────────────────────── */
button, input[type="button"], input[type="submit"], input[type="reset"], .motif-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  min-height: 38px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
button:hover, input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hover, .motif-btn:hover {
  background: var(--surface-2); border-color: var(--muted); text-decoration: none;
}
button:focus-visible, .motif-btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
button:active, .motif-btn:active, .motif-btn.is-active { transform: translateY(1px); }
button:disabled, .motif-btn:disabled { color: var(--muted); cursor: not-allowed; opacity: .65; }

.motif-btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
}
.motif-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.motif-btn-default { box-shadow: var(--focus-ring); }
.motif-btn-danger { color: #fff; background: var(--err); border-color: var(--err); }
.motif-btn-danger:hover { filter: brightness(.95); background: var(--err); }
.motif-btn-ok { color: #fff; background: var(--ok); border-color: var(--ok); }
.motif-btn-ok:hover { filter: brightness(.95); background: var(--ok); }
.motif-btn-sm { font-size: 12.5px; padding: 4px 10px; min-height: 30px; }

/* ── Tables ────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
thead th {
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.selected td, tbody tr[aria-selected="true"] td { background: var(--accent); color: var(--accent-contrast); }
caption { caption-side: top; font-weight: 700; text-align: left; padding: 6px 0; }

/* ── Window container (modernized desktop metaphor) ────── */
.motif-window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0;
  margin: 0 0 16px;
  overflow: hidden;
}
.motif-titlebar {
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-weight: 700;
  cursor: default;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.motif-window.motif-inactive > .motif-titlebar { color: var(--muted); }
.motif-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.motif-window-body { padding: 16px; background: var(--surface); }
.motif-window.motif-minimized > .motif-window-body { display: none; }
.motif-window.motif-maximized { position: fixed; inset: 12px; z-index: 100; margin: 0; overflow: auto; }

/* ── Menubar + dropdown ────────────────────────────────── */
.motif-menubar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}
.motif-menubar > * {
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  min-height: 0;
}
.motif-menubar > *:hover, .motif-menubar > *.is-active { background: var(--accent); color: var(--accent-contrast); text-decoration: none; }
.motif-menubar details.motif-dropdown { background: transparent; border: none; box-shadow: none; padding: 0; margin: 0; position: relative; }
.motif-menubar summary.motif-dropdown-toggle { padding: 7px 12px; cursor: pointer; font-weight: 600; border-radius: var(--radius-sm); list-style: none; user-select: none; }
.motif-menubar summary.motif-dropdown-toggle::-webkit-details-marker { display: none; }
.motif-menubar summary.motif-dropdown-toggle::after { content: ' \25BE'; font-size: 10px; margin-left: 4px; }
.motif-menubar details.motif-dropdown[open] > summary.motif-dropdown-toggle { background: var(--accent); color: var(--accent-contrast); }
.motif-dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); min-width: 180px; z-index: 50; }
.motif-dropdown-item { display: block; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; white-space: nowrap; }
.motif-dropdown-item:hover, .motif-dropdown-item:focus { background: var(--accent); color: var(--accent-contrast); outline: none; text-decoration: none; }

/* ── Toolbar / tabs ────────────────────────────────────── */
.motif-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 8px; display: flex; gap: 6px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.motif-toolbar-sep { width: 1px; height: 22px; margin: 0 6px; background: var(--border); }
.motif-tabs { display: flex; gap: 4px; padding: 0; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.motif-tab { background: transparent; padding: 8px 16px; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; font-family: inherit; font-size: 14px; color: var(--muted); }
.motif-tab:hover { color: var(--text); }
.motif-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.motif-tab-panel { display: none; padding: 12px 0; }
.motif-tab-panel.is-active { display: block; }

/* ── Messages / badges / progress ──────────────────────── */
.motif-msg { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 10px 12px; margin-bottom: 12px; }
.motif-msg-info { border-left-color: var(--info); } .motif-msg-ok { border-left-color: var(--ok); }
.motif-msg-warn { border-left-color: var(--warn); } .motif-msg-err { border-left-color: var(--err); }
.motif-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text); }
.motif-badge-info { background: var(--info); color: #fff; } .motif-badge-ok { background: var(--ok); color: #fff; }
.motif-badge-warn { background: var(--warn); color: #fff; } .motif-badge-err { background: var(--err); color: #fff; }
progress { appearance: none; -webkit-appearance: none; width: 220px; height: 10px; border: none; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
meter { width: 220px; height: 12px; }

/* ── Dialog / details ──────────────────────────────────── */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 0; }
dialog::backdrop { background: rgba(15,20,32,.45); backdrop-filter: blur(2px); }
details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 10px 14px; margin-bottom: 12px; }
summary { cursor: pointer; font-weight: 600; list-style: none; outline: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: '\25B6'; display: inline-block; margin-right: 8px; font-size: 10px; color: var(--muted); }
details[open] > summary::before { content: '\25BC'; }

/* ── Scrollbars (WebKit) ───────────────────────────────── */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Loader ────────────────────────────────────────────── */
.motif-loader { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: motif-spin .8s linear infinite; vertical-align: middle; }
@keyframes motif-spin { to { transform: rotate(360deg); } }

/* ── Layout helpers ────────────────────────────────────── */
.motif-row { display: flex; gap: 10px; } .motif-col { display: flex; flex-direction: column; gap: 10px; }
.motif-grow { flex: 1; } .motif-center { justify-content: center; align-items: center; } .motif-right { justify-content: flex-end; } .motif-wrap { flex-wrap: wrap; }
.motif-mt-0 { margin-top: 0; } .motif-mb-0 { margin-bottom: 0; }
.motif-muted { color: var(--muted); } .motif-hidden { display: none !important; }
.motif-code { font-family: ui-monospace, "SF Mono", "Cascadia Code", "Courier New", monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
