/* Open Iconic removed (unused: NavMenu migrated to Font Awesome). */

/* Legal text markers remain readable and identifiable in both themes. */
mark.legal-confirmation {
    background-color: var(--warning);
    color: var(--warning-foreground);
    border-radius: var(--radius-sm);
    padding: .05em .15em;
    box-decoration-break: clone;
}

/* Design tokens come from Metasoftica.UI (metasoftica-ui.css + the duimet theme): color, radius,
   shadow, motion, layers and type scale. Do NOT redeclare a library token here or add a parallel
   scale; use var(--primary), var(--radius), var(--shadow-md), var(--duration-fast), var(--z-modal)...
   The variables below are the only site-specific ones: values the design system does not define. */
:root {
    /* Hover shade of a semantic color for site-styled elements (the Mts components have their own) */
    --duimet-primary-hover: color-mix(in oklab, var(--primary) 88%, black);
    --duimet-success-hover: color-mix(in oklab, var(--success) 88%, black);
    --duimet-warning-hover: color-mix(in oklab, var(--warning) 88%, black);
    --duimet-danger-hover: color-mix(in oklab, var(--destructive) 88%, black);

    /* Site chrome that must sit above page content (below the library toast layer, --z-toast) */
    --duimet-z-error-ui: 1000;
    --duimet-z-banner: 1050;
}

/* System (OS) dark mode is handled in JS (theme.js / ThemeService): on "System" mode the
   .dark class is added when the OS prefers dark, so the app AND the Metasoftica.UI components
   switch together. The old @media prefers-color-scheme block (a duplicate of the .dark block)
   was removed during the data-theme -> .dark migration. */

* {
    box-sizing: border-box;
}

html, body {
    /* Use the design-system font (Inter via --font-sans) so the whole app matches the Mts components. */
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--background);
    color: var(--foreground);
}

/* Remove any default layout styles */
.page, .sidebar {
    display: none !important;
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: inherit; /* a heading inside a colored header takes the header text color */
    margin-bottom: 1rem;
}

/* Bootstrap-era .bg-*/.text-* !important color overrides REMOVED (teardown): the design-system
   Tailwind utilities (bg-primary/bg-success/.../mts-text-success/...) from app.tw.css + metasoftica-ui
   tokens now own these; markup sets its own foreground (text-white / text-*-foreground). */

/* Utility classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, color-mix(in oklab, var(--primary) 55%, black) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Student ID badge (consolidado desde Home/MyResults .razor.css; rgba indigo -> tokens) */
.student-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: color-mix(in oklab, var(--primary) 10%, transparent);
    color: var(--primary);
    padding: 0.4rem 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: monospace;
    border: 1.5px solid color-mix(in oklab, var(--primary) 30%, transparent);
    margin-top: 0.5rem;
}

.student-id-badge i {
    font-size: 0.85rem;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

h1:focus {
    outline: none;
}

/* Additional contrast improvements for specific components */

/* Improved contrast for stat items in exam management */
.stat-item {
    padding: 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.stat-item:hover {
    background: var(--card);
    border-color: var(--border);
}

.stat-item i {
    margin-bottom: 0.5rem;
    display: block;
}

.stat-item i.text-primary {
    color: var(--primary) !important;
}

/* Assignment card improvements */
.assignment-overdue {
    border-left: 4px solid var(--destructive);
    background: color-mix(in oklab, var(--destructive) 10%, var(--background));
}

.assignment-due-soon {
    border-left: 4px solid var(--warning);
    background: color-mix(in oklab, var(--warning) 10%, var(--background));
}

.assignment-completed {
    border-left: 4px solid var(--success);
    background: color-mix(in oklab, var(--success) 10%, var(--background));
}

/* Improved contrast for small text and details */
.exam-details,
.assignment-info {
    background: var(--card);
    border-radius: calc(var(--radius) - 4px);
    padding: 1rem;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
}

/* Bootstrap-named structural base REMOVED (teardown): the app markup no longer renders any
   Bootstrap-named classes (.btn/.card/.alert/.badge/.table/.form-control/.modal-*/.dropdown-*). */

/* Link color moved to Styles/app.tailwind.css under @layer base so Tailwind utilities (text-white,
   text-*, in @layer utilities) can override it on links styled as buttons. Defining it unlayered here
   beat all Tailwind utilities (unlayered CSS > any @layer), which broke utility colors on <a>. */

.content {
    padding-top: 1.1rem;
}

.validation-message {
    color: var(--destructive);
    font-family: inherit; /* match the surrounding field font (was forcing a different family) */
    font-size: 0.75rem;   /* clearly smaller than the 0.875rem (text-sm) field text */
    line-height: 1rem;
    margin-top: 0.125rem;
}

/* MtsValidationSummary link styling + Mts control --input-background now ship in Metasoftica.UI 2.18.2
   (the Duimet interims for both were removed). */

#blazor-error-ui {
    background: color-mix(in oklab, var(--warning) 20%, var(--background));
    bottom: 0;
    border-top: 1px solid var(--border);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHZpZXdCb3g9IjAgMCA1NiA0OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjUgNi41TDIwLjUgMTIuNUwyNi41IDYuNUw3MJYOTYVMj4gODT0IjVMmN5PzFIIiBzdHJva2U9IiNEQjJEMzQiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==) no-repeat 1rem/1.8rem, var(--destructive);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--destructive-foreground);
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* Exam specific styles */
.exam-timer {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 10px;
    font-weight: bold;
}

.question-card {
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 20px;
    margin-bottom: 20px;
}

.answer-option {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.answer-option:hover {
    background-color: var(--muted);
}

.answer-option.selected {
    background-color: color-mix(in oklab, var(--info) 12%, var(--background));
    border-color: var(--info);
}

.exam-navigation {
    margin-top: 20px;
    padding: 15px;
    background: var(--muted);
    border-radius: 5px;
}

/* ============================================================================
   Impersonation Banner
   ============================================================================ */

.impersonation-banner {
    background: linear-gradient(135deg, var(--warning), var(--duimet-warning-hover));
    color: var(--warning-foreground);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-sm);
    z-index: var(--duimet-z-banner);
}

.impersonation-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* MtsLoadingButton 3.4.0 renders its default colors even with Variant=Surface. */
.impersonation-banner .impersonation-exit {
    color: inherit;
    background-color: oklch(from currentColor calc(1 - l) 0 0 / 0.15);
}

.impersonation-banner .impersonation-exit:hover:not(:disabled) {
    background-color: oklch(from currentColor calc(1 - l) 0 0 / 0.25);
}

.impersonation-banner i.fa-user-secret {
    font-size: 1.1rem;
}

@media (max-width: 576px) {
    .impersonation-banner {
        padding: 0.5rem;
    }

    .impersonation-banner-content {
        font-size: 0.8rem;
    }
}

/* ============================================================================
   Version Badge - follows BackToTop or the footer
   ============================================================================ */

.version-badge {
    position: fixed;
    top: var(--version-badge-top, 0px);
    left: var(--version-badge-left, 0px);
    font-size: 10px;
    padding: 2px 6px 2px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    z-index: var(--duimet-z-error-ui);
    display: flex;
    align-items: center;
    gap: 4px;
    visibility: hidden;
    white-space: nowrap;
    transition: top var(--duration-moderate) ease, left var(--duration-moderate) ease;
}

.version-badge.is-positioned {
    visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
    .version-badge {
        transition: none;
    }
}

.version-badge svg {
    flex-shrink: 0;
    display: block;
}

/* Fill the area between the public header and footer on the four auth pages. */
main > div:has(> #main-content > .page-layout-body > .auth-split-page) {
    display: flex;
    flex-direction: column;
}

#main-content:has(> .page-layout-body > .auth-split-page) {
    display: flex;
    flex: 1;
    isolation: isolate;
    background: color-mix(in oklab, var(--primary) 6%, var(--background));
}

#main-content:has(> .page-layout-body > .auth-split-page) > .page-layout-body {
    display: flex;
    flex-direction: column;
}

.auth-split-form [data-registration-consent] a {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.auth-split-form #mts-field-Captcha > .mts-captcha {
    max-width: none;
}

/* ============================================
   Register Page Styles - Flag Icons
   ============================================ */
.flag-icon {
    display: inline-block;
    width: 1.5em;
    height: 1em;
    margin-right: 0.5em;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    vertical-align: middle;
}

.flag-us { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23B22234"/><path d="M0,3.462h60M0,6.923h60M0,10.385h60M0,13.846h60M0,17.308h60M0,20.769h60M0,24.231h60M0,27.692h60" stroke="%23fff" stroke-width="2.308"/><rect width="24" height="17.308" fill="%233C3B6E"/></svg>'); }
.flag-mx { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="20" height="30" fill="%23006847"/><rect x="20" width="20" height="30" fill="%23fff"/><rect x="40" width="20" height="30" fill="%23CE1126"/></svg>'); }
.flag-es { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23AA151B"/><rect y="7.5" width="60" height="15" fill="%23F1BF00"/></svg>'); }
.flag-gb { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23012169"/><path d="M0,0L60,30M60,0L0,30" stroke="%23fff" stroke-width="6"/><path d="M0,0L60,30M60,0L0,30" stroke="%23C8102E" stroke-width="4"/><path d="M30,0v30M0,15h60" stroke="%23fff" stroke-width="10"/><path d="M30,0v30M0,15h60" stroke="%23C8102E" stroke-width="6"/></svg>'); }
.flag-de { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="10" fill="%23000"/><rect y="10" width="60" height="10" fill="%23D00"/><rect y="20" width="60" height="10" fill="%23FFCE00"/></svg>'); }
.flag-fr { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="20" height="30" fill="%23002395"/><rect x="20" width="20" height="30" fill="%23fff"/><rect x="40" width="20" height="30" fill="%23ED2939"/></svg>'); }
.flag-it { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="20" height="30" fill="%23009246"/><rect x="20" width="20" height="30" fill="%23fff"/><rect x="40" width="20" height="30" fill="%23CE2B37"/></svg>'); }
.flag-pt { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23FF0000"/><rect width="24" height="30" fill="%23006600"/></svg>'); }
.flag-ar { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="10" fill="%2375AADB"/><rect y="10" width="60" height="10" fill="%23fff"/><rect y="20" width="60" height="10" fill="%2375AADB"/></svg>'); }
.flag-br { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23009739"/><path d="M30,5L50,15L30,25L10,15Z" fill="%23FEDD00"/><circle cx="30" cy="15" r="5" fill="%23002776"/></svg>'); }
.flag-cl { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23fff"/><rect y="15" width="60" height="15" fill="%23D52B1E"/><rect width="24" height="15" fill="%230039A6"/></svg>'); }
.flag-co { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="15" fill="%23FCD116"/><rect y="15" width="60" height="7.5" fill="%23003893"/><rect y="22.5" width="60" height="7.5" fill="%23CE1126"/></svg>'); }
.flag-pe { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23fff"/><rect width="20" height="30" fill="%23D91023"/><rect x="40" width="20" height="30" fill="%23D91023"/></svg>'); }
.flag-ve { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="10" fill="%23FFCC00"/><rect y="10" width="60" height="10" fill="%23003893"/><rect y="20" width="60" height="10" fill="%23CF142B"/></svg>'); }
.flag-ec { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="15" fill="%23FFD100"/><rect y="15" width="60" height="7.5" fill="%230072C6"/><rect y="22.5" width="60" height="7.5" fill="%23EF3340"/></svg>'); }
.flag-jp { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23fff"/><circle cx="30" cy="15" r="9" fill="%23BC002D"/></svg>'); }
.flag-cn { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23DE2910"/></svg>'); }
.flag-in { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="10" fill="%23FF9933"/><rect y="10" width="60" height="10" fill="%23fff"/><rect y="20" width="60" height="10" fill="%23138808"/></svg>'); }
.flag-ca { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="15" height="30" fill="%23D52B1E"/><rect x="15" width="30" height="30" fill="%23fff"/><rect x="45" width="15" height="30" fill="%23D52B1E"/></svg>'); }
.flag-au { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 30"><rect width="60" height="30" fill="%23012169"/></svg>'); }

/* Custom dropdown styles for Register */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-toggle {
    width: 100%;
    /* Match the native inputs (bg-input-background / border-input-border) so combos and textboxes look the
       same; tokens keep it dark-mode safe (was hardcoded white + var(--border)). */
    background-color: var(--input-background);
    border: 1px solid var(--input-border);
    border-radius: 0.375rem;
    text-align: left;
    display: flex;
    align-items: center;
    padding: 0.5rem 2.25rem 0.5rem 0.5rem;
    position: relative;
}

.custom-dropdown-toggle:hover {
    border-color: var(--ring);
}

.custom-dropdown-toggle::after {
    content: "";
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-left: 0.3em solid transparent;
    pointer-events: none;
}

.custom-dropdown-input {
    border: none;
    outline: none;
    flex: 1;
    padding: 0 0.5rem;
    background: transparent;
    font-size: 0.875rem;
    color: var(--foreground);
}

.custom-dropdown-menu {
    position: absolute;
    z-index: 1000;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    box-shadow: var(--shadow-lg);
    margin-top: 0.125rem;
}

.custom-dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.custom-dropdown-item:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.custom-dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-flag-icon {
    width: 1.5em;
    height: 1em;
    margin-right: 0.5rem;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* Dark mode: app-level overrides (the Bootstrap-named .dark overrides were removed in teardown). */
.dark body,
/* MtsAppShell scrolls an inner container whose overflow-y:auto coerces overflow-x to auto, so any
   content slightly wider than the area shows a spurious horizontal scrollbar. The known offender is
   leftover Bootstrap-style negative-margin rows (e.g. Home.razor's `flex -mx-3`) whose former
   container padding (.container-fluid) is gone. Clip the content horizontally: `clip` does NOT create
   a scroll container, so vertical scroll stays on the shell and nested overflow-x:auto regions
   (DataTable) and position:sticky are unaffected; only the empty -mx-3 gutter overhang is trimmed. */
.main-content {
    overflow-x: clip;
    /* Containing block for absolutely-positioned descendants (e.g. MtsDataTable's sr-only live
       region). Without this they resolve to the initial containing block (html) and escape the app
       shell's inner scroll, stretching the document and producing a SECOND (browser) scrollbar. */
    position: relative;
}

.dark .main-content {
    background-color: var(--background);
    color: var(--foreground);
}

.dark h1, .dark h2, .dark h3,
.dark h4, .dark h5, .dark h6 {
    color: inherit;
}

/* Link foreground comes from library tokens/utilities in both modes. */

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: var(--background);
}

.dark ::-webkit-scrollbar-thumb {
    background: var(--border);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* The modal shell is rendered by MtsModalProvider, outside the player component's CSS scope. */
.mts-modal-backdrop:has(> .mts-modal [data-video-player]) {
    padding: 1rem;
}

.mts-modal:has([data-video-player]) {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2rem);
    overflow-wrap: anywhere;
}

.mts-modal > :has(> [data-video-player]) {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}

.mts-modal:has([data-video-player]) > :not(:has(> [data-video-player])) {
    flex-shrink: 0;
}

body:has(.mts-modal [data-video-player]) .version-badge {
    z-index: var(--z-floating);
}

@media (max-width: 639px) {
    .mts-modal-backdrop:has(> .mts-modal [data-video-player]) {
        padding: 0;
    }

    .mts-modal-backdrop > .mts-modal:has([data-video-player]) {
        --edition-video-modal-width: 100%;

        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
    }
}

/* ===== Accessibility: Focus Visible ===== */
/* FocusOnNavigate keeps the page heading announced without drawing a control outline. */
:focus-visible:not(h1[tabindex="-1"]):not(.mts-ring-control):not(.mts-ring-control > input):not(.peer):not(.mts-ck-input):not(.sr-only) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Accessibility: Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Accessibility: Skip Link ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 8px 16px;
    z-index: 1000;
    transition: top var(--duration-fast) ease;
}

.skip-link:focus {
    top: 0;
}
