/* ══════════════════════════════════════════════════════════════════════
   EDUkalEDAD Portal UI: one design layer for the Teacher and Admin portals

   Loaded LAST in <head> on every teacher and admin page, with
   <body class="ui-teacher"> or <body class="ui-admin">. Each page still has
   its own styles; this layer evens out what they did differently, so both
   portals read as one product:
     1. tokens (DESIGN.md: Trust Blue #2563EB, Deep Navy sidebar)
     2. typeface (Plus Jakarta Sans everywhere)
     3. sidebar: same navy, same menu items, same active state
     4. admin top bar: one slim sticky bar on every console page, with the
        same clock and profile chip
     5. tables, focus rings
   Elder-facing screens (pages/elder, the activity and lesson previews in the
   teacher tools) never load this file.
   ══════════════════════════════════════════════════════════════════════ */

/* 1. Tokens */
:root {
    --ui-font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --ui-primary: #2563eb;
    --ui-primary-hover: #1d4ed8;
    --ui-primary-soft: #eff6ff;
    --ui-primary-border: #bfdbfe;
    --ui-sidebar: #123466;
    --ui-sidebar-accent: #93c5fd;
    --ui-text: #0f172a;
    --ui-muted: #64748b;
    --ui-border: #e2e8f0;
    --ui-surface: #f8fafc;
    --ui-brand-cyan: #06b6d4; /* the "EDU" of the EDUkalEDAD wordmark only */
}

/* Shared skeletons for data-backed teacher and admin views. */
.ui-skeleton {
    display: block;
    border-radius: 7px;
    background: linear-gradient(90deg, #e8eef6 25%, #f6f8fb 50%, #e8eef6 75%);
    background-size: 200% 100%;
    animation: ui-skeleton-shimmer 1.35s ease-in-out infinite;
}

.ui-skeleton-card {
    box-sizing: border-box;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--ui-border);
    border-radius: 14px;
    background: #ffffff;
    pointer-events: none;
}

.ui-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@keyframes ui-skeleton-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

html[data-theme="dark"] .ui-skeleton {
    background-color: #334155;
    background-image: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
}

html[data-theme="dark"] .ui-skeleton-card {
    background: #1e293b;
    border-color: #475569;
}

@media (prefers-reduced-motion: reduce) {
    .ui-skeleton { animation: none; }
}

/* 2. Typeface */
body.ui-teacher,
body.ui-admin {
    font-family: var(--ui-font);
}

:where(.ui-teacher, .ui-admin) :where(button, input, select, textarea) {
    font-family: inherit;
}

/* 3. Sidebar: the admin console takes the teacher portal's navy and menu style */
body.ui-admin .sidebar {
    background: var(--ui-sidebar);
}

body.ui-admin .nav-item {
    color: rgba(255, 255, 255, 0.72);
    border-radius: 10px;
}

body.ui-admin .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Current page: a light panel with an accent edge, the same in both portals */
body.ui-admin .nav-item.active,
body.ui-teacher .nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--ui-sidebar-accent);
}

body.ui-admin .brand-name .c {
    color: var(--ui-brand-cyan);
}

/* 4. Admin top bar: slim and sticky on every console page (the Teachers page pattern).
   Pages whose bar used to be a floating card have their content in .main-content > .page-body. */
body.ui-admin .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 64px;
    margin: 0;
    padding: 10px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 0;
    border-bottom: 1px solid var(--ui-border);
    border-radius: 0;
    box-shadow: none;
}

body.ui-admin .topbar-titles h1,
body.ui-admin .page-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.3;
    color: var(--ui-text);
}

body.ui-admin .topbar-titles p,
body.ui-admin .page-subtitle {
    margin: 1px 0 0;
    font-size: 12px;
    color: var(--ui-muted);
}

body.ui-admin .main-content {
    padding: 0;
    min-width: 0;
}

body.ui-admin .main-content > .page-body {
    padding: 28px 32px 40px;
}

/* Clock and profile chip: one look on every page */
body.ui-admin .live-clock {
    font-family: var(--ui-font);
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0;
    color: #475569;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    padding: 6px 12px;
    white-space: nowrap;
}

body.ui-admin .admin-profile,
body.ui-admin .admin-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 100px;
    padding: 4px 12px 4px 4px;
}

body.ui-admin .admin-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ui-primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    body.ui-admin .topbar {
        padding: 8px 14px;
    }

    body.ui-admin .main-content > .page-body {
        padding: 20px 16px 32px;
    }

    body.ui-admin .live-clock {
        display: none;
    }
}

/* 5. Tables and focus.
   Header cells without an alignment of their own line up with their column
   (the browser centres them by default); any alignment a page sets still wins. */
:where(.ui-teacher, .ui-admin) :where(th) {
    text-align: start;
}

:where(.ui-teacher, .ui-admin) :where(a, button, [role="button"], input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 2px;
}

/* 6. "How this works" disclosures: a page's explanations stay one click away.
   <details class="ui-info"><summary>How this works</summary><div class="ui-info-body">…</div></details>
   Own tokens (--uinfo-*): some teacher tools define --ui-* tokens of their own. */
:root {
    --uinfo-accent: #1d4ed8;
    --uinfo-accent-soft: #eff6ff;
    --uinfo-accent-border: #bfdbfe;
    --uinfo-panel: #f8fafc;
    --uinfo-border: #e2e8f0;
    --uinfo-text: #334155;
}

html[data-theme="dark"] {
    --uinfo-accent: #93c5fd;
    --uinfo-accent-soft: rgba(96, 165, 250, 0.14);
    --uinfo-accent-border: rgba(96, 165, 250, 0.35);
    --uinfo-panel: #16213a;
    --uinfo-border: #2b3a5a;
    --uinfo-text: #cbd5e1;
}

.ui-info {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
}

.ui-info > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px 4px 6px;
    border: 1px solid var(--uinfo-accent-border);
    border-radius: 999px;
    background: var(--uinfo-accent-soft);
    color: var(--uinfo-accent);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.ui-info > summary::-webkit-details-marker {
    display: none;
}

.ui-info > summary::before {
    content: 'i';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--uinfo-accent);
    color: var(--uinfo-accent-soft);
    font: italic 700 12px/1 Georgia, 'Times New Roman', serif;
    flex-shrink: 0;
}

html[data-theme="dark"] .ui-info > summary::before {
    color: #0b1220;
}

.ui-info > summary::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-left: 2px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s;
}

.ui-info[open] > summary::after {
    transform: translateY(1px) rotate(-135deg);
}

.ui-info > summary:hover {
    border-color: var(--uinfo-accent);
}

.ui-info-body {
    max-width: 760px;
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid var(--uinfo-border);
    border-radius: 10px;
    background: var(--uinfo-panel);
    color: var(--uinfo-text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    text-align: left;
}

.ui-info-body > * + * {
    margin-top: 8px;
}

.ui-info-body ul,
.ui-info-body ol {
    margin: 0;
    padding-left: 20px;
}

.ui-info-body li + li {
    margin-top: 4px;
}

.ui-info-body strong {
    color: inherit;
    font-weight: 700;
}

/* iPhone Safari zooms the whole page into any field under 16px when it is tapped (sign-in pages too).
   Phone-sized layouts only, iOS only (-webkit-touch-callout exists only there). */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 767.98px), (max-height: 500px) {
        :where(.ui-teacher, .ui-admin) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea) {
            font-size: 16px !important;
        }
    }
}
