/* Role-scoped RH Tech palettes. Loaded after app.css, admin-parity.css, and page-level styles. */
:root {
  --role-primary: var(--teal);
  --role-primary-ink: #FFFFFF;
  --role-accent: var(--gold);
  --role-accent-ink: #1E2B26;
  --role-accent-soft: var(--mint);
  --status-success: #2F9E62;
  --status-warning: #D89B16;
  --status-danger: #C94736;
  --status-info: #2B87B8;
}

/* Management: professional blue and navy. */
:root[data-role="admin"] {
  color-scheme: light;
  --bg: #F3F6FB;
  --card: #FFFFFF;
  --ink: #142B45;
  --muted: #4C607A;
  --line: #CBD8EA;
  --soft: #E7EEF8;
  --edge: #223A5A;
  --stage: #EAF0F8;
  --teal: #1D4ED8;
  --teal2: #1D4ED8;
  --mint: #DFEAFE;
  --hero: #173B63;
  --heroink: #FFFFFF;
  --shadow: 3px 3px 0 var(--edge);
  --role-primary: #1D4ED8;
  --role-accent: #1D4ED8;
  --role-accent-ink: #FFFFFF;
  --role-accent-soft: #DFEAFE;
}

/* Teaching: retain the established green/teal and gold identity. */
:root[data-role="guru"] {
  color-scheme: light;
  --bg: #F1F5F2;
  --card: #FFFFFF;
  --ink: #1E2B26;
  --muted: #5B6B64;
  --line: #D3DDD7;
  --soft: #E4ECE7;
  --edge: #1E2B26;
  --stage: #F1F5F2;
  --teal: #4A7A66;
  --teal2: #4A7A66;
  --mint: #E4ECE7;
  --gold: #F1CF6E;
  --hero: #4A7A66;
  --heroink: #FFFFFF;
  --shadow: 3px 3px 0 var(--edge);
  --role-primary: #4A7A66;
  --role-accent: #F1CF6E;
  --role-accent-ink: #1E2B26;
  --role-accent-soft: #E4ECE7;
}

/* Learning: distinct violet/indigo palette. */
:root[data-role="siswa"] {
  color-scheme: light;
  --bg: #F6F4FC;
  --card: #FFFFFF;
  --ink: #282044;
  --muted: #655B7A;
  --line: #DED8EF;
  --soft: #EEEAF8;
  --edge: #352B5C;
  --stage: #EFECF8;
  --teal: #5B4BC4;
  --teal2: #5B4BC4;
  --mint: #E9E4FA;
  --hero: #382A75;
  --heroink: #FFFFFF;
  --shadow: 3px 3px 0 var(--edge);
  --role-primary: #5B4BC4;
  --role-accent: #5B4BC4;
  --role-accent-ink: #FFFFFF;
  --role-accent-soft: #E9E4FA;
}

/* Blue/navy dark mode. The blue action fill still has WCAG AA white-text contrast. */
:root[data-role="admin"][data-theme="dark"] {
  color-scheme: dark;
  --bg: #111B2B;
  --card: #17243A;
  --ink: #ECF3FF;
  --muted: #A8B8D1;
  --line: #334764;
  --soft: #24344D;
  --edge: #58749B;
  --stage: #0B1422;
  --teal: #8DB6F8;
  --teal2: #9BC0FB;
  --mint: #24344D;
  --hero: #172C49;
  --heroink: #ECF3FF;
  --role-primary: #2563EB;
  --role-accent: #2563EB;
  --role-accent-ink: #FFFFFF;
  --role-accent-soft: #24344D;
}

/* Keep teaching green/teal in dark mode, with a darker button fill for contrast. */
:root[data-role="guru"][data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1714;
  --card: #17211D;
  --ink: #EAF2ED;
  --muted: #AABBB1;
  --line: #304139;
  --soft: #202E28;
  --edge: #4D7666;
  --stage: #0A110E;
  --teal: #28634F;
  --teal2: #79C7A8;
  --mint: #20332D;
  --gold: #F1CF6E;
  --hero: #193D32;
  --heroink: #EAF2ED;
  --role-primary: #28634F;
  --role-accent: #F1CF6E;
  --role-accent-ink: #1E2B26;
  --role-accent-soft: #20332D;
}

/* Violet/indigo dark mode. */
:root[data-role="siswa"][data-theme="dark"] {
  color-scheme: dark;
  --bg: #111021;
  --card: #1A1930;
  --ink: #F1EEFF;
  --muted: #AAA2C8;
  --line: #393250;
  --soft: #26233F;
  --edge: #665B91;
  --stage: #0C0B18;
  --teal: #A99BFF;
  --teal2: #B9AEFF;
  --mint: #282443;
  --hero: #2B2350;
  --heroink: #F1EEFF;
  --role-primary: #6654D7;
  --role-accent: #6654D7;
  --role-accent-ink: #FFFFFF;
  --role-accent-soft: #282443;
}

/* Respect system dark mode where a user has not explicitly selected light. */
@media (prefers-color-scheme: dark) {
  :root[data-role="admin"]:not([data-theme="light"]),
  :root[data-role="admin"][data-theme="dark"] {
    color-scheme: dark;
    --bg: #111B2B; --card: #17243A; --ink: #ECF3FF; --muted: #A8B8D1;
    --line: #334764; --soft: #24344D; --edge: #58749B; --stage: #0B1422;
    --teal: #8DB6F8; --teal2: #9BC0FB; --mint: #24344D; --hero: #172C49; --heroink: #ECF3FF;
    --role-primary: #2563EB; --role-accent: #2563EB; --role-accent-ink: #FFFFFF; --role-accent-soft: #24344D;
  }
  :root[data-role="guru"]:not([data-theme="light"]),
  :root[data-role="guru"][data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F1714; --card: #17211D; --ink: #EAF2ED; --muted: #AABBB1;
    --line: #304139; --soft: #202E28; --edge: #4D7666; --stage: #0A110E;
    --teal: #28634F; --teal2: #79C7A8; --mint: #20332D; --gold: #F1CF6E; --hero: #193D32; --heroink: #EAF2ED;
    --role-primary: #28634F; --role-accent: #F1CF6E; --role-accent-ink: #1E2B26; --role-accent-soft: #20332D;
  }
  :root[data-role="siswa"]:not([data-theme="light"]),
  :root[data-role="siswa"][data-theme="dark"] {
    color-scheme: dark;
    --bg: #111021; --card: #1A1930; --ink: #F1EEFF; --muted: #AAA2C8;
    --line: #393250; --soft: #26233F; --edge: #665B91; --stage: #0C0B18;
    --teal: #A99BFF; --teal2: #B9AEFF; --mint: #282443; --hero: #2B2350; --heroink: #F1EEFF;
    --role-primary: #6654D7; --role-accent: #6654D7; --role-accent-ink: #FFFFFF; --role-accent-soft: #282443;
  }
}

/* Brand-bearing shared controls. Status and danger classes intentionally remain semantic. */
html[data-role] .gold,
html[data-role] .fab,
html[data-role] .pv,
html[data-role] .av {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}
html[data-role] .primary:not(.done) {
  background: var(--role-primary);
  color: var(--role-primary-ink);
}
html[data-role] .primary:not(.done):hover {
  filter: brightness(1.06);
}
html[data-role] .nb.on .pill {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}
html[data-role] button:focus-visible,
html[data-role] input:focus-visible,
html[data-role] select:focus-visible,
html[data-role] textarea:focus-visible,
html[data-role] a:focus-visible,
html[data-role] [tabindex]:focus-visible {
  outline-color: var(--role-primary);
}
html[data-role] input[type="range"],
html[data-role] input[type="checkbox"],
html[data-role] input[type="radio"] {
  accent-color: var(--teal2);
}

/* Teacher topbar/avatar and desktop active tab follow the established gold accent. */
html[data-role="guru"] .gdash-brand .av,
html[data-role="guru"] .gdash-desktop-nav a.is-on {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}

/* Student-specific accents; task/material type colors remain separate semantic cues. */
html[data-role="siswa"] .student-profile-link,
html[data-role="siswa"] .student-hero-link {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}
html[data-role="siswa"] .student-progress .progress-value {
  stroke: var(--role-accent);
}
html[data-role="siswa"] .student-desktop-nav a:hover,
html[data-role="siswa"] .student-desktop-nav a[aria-current="page"] {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}

/* Admin blue/navy actions and active navigation, limited to admin-only surfaces. */
html[data-role="admin"] .admin-button:not(.secondary):not(.danger),
html[data-role="admin"] .admin-page button:not(.secondary):not(.danger):not(.ib):not(.plain):not(:disabled),
html[data-role="admin"] .admin-page input[type="submit"]:not(:disabled) {
  background: var(--role-accent);
  border-color: var(--edge);
  color: var(--role-accent-ink);
}
html[data-role="admin"] .admin-button:not(.secondary):not(.danger):hover,
html[data-role="admin"] .admin-page button:not(.secondary):not(.danger):not(.ib):not(.plain):not(:disabled):hover,
html[data-role="admin"] .admin-page input[type="submit"]:not(:disabled):hover {
  filter: brightness(1.08);
}
html[data-role="admin"] .admin-desktop-nav a[aria-current="page"],
html[data-role="admin"] .admin-weekdays a[aria-current="date"],
html[data-role="admin"] .admin-mobile-nav > a[aria-current="page"],
html[data-role="admin"] .admin-mobile-nav details[open] > summary,
html[data-role="admin"] .admin-profile-avatar,
html[data-role="admin"] .management-identity-row .av,
html[data-role="admin"] .teacher-button--primary {
  background: var(--role-accent);
  color: var(--role-accent-ink);
}
html[data-role="admin"] .admin-weekdays a[aria-current="date"] small {
  color: var(--role-accent-ink);
}
html[data-role="admin"] .admin-desktop-nav a:hover,
html[data-role="admin"] .admin-mobile-menu a[aria-current="page"],
html[data-role="admin"] .admin-shell-icon:hover,
html[data-role="admin"] .teacher-link:hover,
html[data-role="admin"] .teacher-button:not(.teacher-button--danger):hover {
  background: var(--role-accent-soft);
  color: var(--ink);
}
html[data-role="admin"] .admin-success,
html[data-role="admin"] .status-saved {
  border-color: var(--status-success);
  color: #236B43;
}
html[data-role="admin"] .admin-success {
  background: color-mix(in srgb, var(--status-success) 12%, var(--card));
}
html[data-role="admin"] .pengelola .eyebrow {
  color: var(--teal2);
}
html[data-role="admin"] .pengelola .toolbar a,
html[data-role="admin"] .pengelola .btn:not(.danger) {
  background: var(--role-primary);
  color: #FFFFFF;
}
html[data-role="admin"][data-theme="dark"] .admin-success,
html[data-role="admin"][data-theme="dark"] .status-saved {
  color: #7DDBA4;
}

/* Keep the semantic green success, amber warning, and red error palettes distinct. */
html[data-role] .primary.done,
html[data-role] .admin-success,
html[data-role] .status-saved,
html[data-role] .teacher-notice--error,
html[data-role] .teacher-button--danger,
html[data-role] .danger,
html[data-role] .admin-errors,
html[data-role] .admin-error,
html[data-role] .del.armed,
html[data-role] .att button.on,
html[data-role] .att button.s-on,
html[data-role] .att button.a-on {
  /* Preserve the existing semantic state rules from app.css/admin-parity.css. */
}

@media (prefers-color-scheme: dark) {
  :root[data-role="admin"]:not([data-theme="light"]) .admin-success,
  :root[data-role="admin"]:not([data-theme="light"]) .status-saved {
    color: #7DDBA4;
  }
}
html[data-role="siswa"] #v-fav[style*="var(--gold)"] {
  color: var(--role-accent) !important;
}
