/* Nuveq brand on the Radzen "standard" theme. Brand blue #3D81C2, brand red #B94747 (logo).
   Buttons use a darker blue: white on #3D81C2 is only 4.1:1, on #2E6DAA it is 5.41:1.
   Brand red is reserved for danger states (missing IN/OUT, destructive actions). */
:root {
    --rz-primary: #2E6DAA;
    --rz-primary-light: #3D81C2;
    --rz-primary-lighter: rgba(61, 129, 194, 0.14);
    --rz-primary-dark: #275C90;
    --rz-primary-darker: #1F4B76;
    --rz-on-primary-lighter: #275C90;

    --rz-danger: #B94747;
    --rz-danger-light: #C76363;
    --rz-danger-lighter: rgba(185, 71, 71, 0.14);
    --rz-danger-dark: #9E3C3C;
    --rz-danger-darker: #8A3434;
    --rz-on-danger-lighter: #9E3C3C;

    /* Light sidebar like the Nuveq logo ground; the theme default is a dark panel with its own blue. */
    --rz-sidebar-background-color: var(--rz-white);
    --rz-sidebar-color: var(--rz-text-color);
    --rz-sidebar-border-inline-end: 1px solid var(--border);
    --rz-panel-menu-item-background-color: var(--rz-white);
    --rz-panel-menu-item-color: var(--rz-text-color);
    --rz-panel-menu-icon-color: var(--rz-text-secondary-color);
    --rz-panel-menu-item-border: none;
    --rz-panel-menu-item-hover-background-color: var(--rz-base-100);
    --rz-panel-menu-item-active-background-color: var(--rz-primary-lighter);
    --rz-panel-menu-item-active-color: var(--rz-on-primary-lighter);
    --rz-panel-menu-item-active-indicator: var(--rz-primary);
    --rz-panel-menu-item-2nd-level-background-color: var(--rz-white);
    --rz-panel-menu-item-2nd-level-hover-background-color: var(--rz-base-100);
    --rz-panel-menu-item-2nd-level-active-background-color: var(--rz-primary-lighter);
    --rz-panel-menu-item-2nd-level-active-color: var(--rz-on-primary-lighter);
    --rz-panel-menu-item-2nd-level-active-font-weight: 600;

    /* Secondary actions: neutral slate. The stock #5D89F7 left white button text below 4.5:1; #4A5563 gives 7.58:1. */
    --rz-secondary: #4A5563;
    --rz-secondary-light: #5B6675;
    --rz-secondary-lighter: rgba(74, 85, 99, 0.12);
    --rz-secondary-dark: #3B4450;
    --rz-secondary-darker: #2E353F;
    --rz-on-secondary-lighter: #3B4450;

    /* Links follow the brand blue instead of the secondary colour (6.38:1 on the page background). */
    --rz-link-color: var(--rz-primary-dark);
    --rz-link-hover-color: var(--rz-primary-darker);

    --input-border: #8A8F98; /* 3.25:1 on white, meets the 3:1 non-text minimum */

    /* Card, table and divider lines. */
    --border: var(--rz-base-300);
    --border-subtle: var(--rz-base-200);

    /* Late arrival (PRD §6.11: yellow), always shown with text. #5C4400 on #FCEFC7 is 8.02:1. */
    --late-background: #FCEFC7;
    --late-text: #5C4400;

    /* Missing IN/OUT (PRD §6.11: red), always shown with the words "Tidak ada". #7A1F1F on #F8D7D7 is about 7.7:1. */
    --missing-background: #F8D7D7;
    --missing-text: #7A1F1F;
}

/* Dark theme: the header toggle swaps Radzen's stylesheet to standard-dark, and these values follow it.
   Brand colors turn light, with dark text on buttons: no single dark blue passes 4.5:1 both behind white
   button text and as text on a dark page. Contrast is noted on each pair. */
:root:has(link[href*="standard-dark"]) {
    /* #8DB8E8 as text on #242527: 7.4:1; #0E1F33 on #8DB8E8: 8.0:1. */
    --rz-primary: #8DB8E8;
    --rz-primary-light: #A9CCF0;
    --rz-primary-lighter: rgba(141, 184, 232, 0.16);
    --rz-primary-dark: #A9CCF0;
    --rz-primary-darker: #C4DCF5;
    --rz-on-primary: #0E1F33;
    --rz-on-primary-lighter: #A9CCF0;

    /* #F29B9B as text on #242527: 7.3:1; #3A0F0F on #F29B9B: 7.9:1. */
    --rz-danger: #F29B9B;
    --rz-danger-light: #F5B0B0;
    --rz-danger-lighter: rgba(242, 155, 155, 0.16);
    --rz-danger-dark: #F5B0B0;
    --rz-danger-darker: #F8C6C6;
    --rz-on-danger: #3A0F0F;
    --rz-on-danger-lighter: #F5B0B0;

    /* #1B2029 on #C3CAD4: 9.9:1. */
    --rz-secondary: #C3CAD4;
    --rz-secondary-light: #D3D9E0;
    --rz-secondary-lighter: rgba(195, 202, 212, 0.14);
    --rz-secondary-dark: #D3D9E0;
    --rz-secondary-darker: #E2E6EB;
    --rz-on-secondary: #1B2029;
    --rz-on-secondary-lighter: #D3D9E0;

    /* Status text such as "Terhubung": #6FCF97 on #242527 is 8.1:1 (the theme's #008244 is 3.1:1). */
    --rz-success-dark: #6FCF97;

    --rz-sidebar-background-color: var(--rz-base-800);
    --rz-panel-menu-item-background-color: var(--rz-base-800);
    --rz-panel-menu-item-hover-background-color: var(--rz-base-700);
    --rz-panel-menu-item-2nd-level-background-color: var(--rz-base-800);
    --rz-panel-menu-item-2nd-level-hover-background-color: var(--rz-base-700);

    --border: var(--rz-base-600);
    --border-subtle: var(--rz-base-700);

    /* #F3D58A on #3A3016: 9.1:1; #F4B4B4 on #3F1E1E: 8.6:1. */
    --late-background: #3A3016;
    --late-text: #F3D58A;
    --missing-background: #3F1E1E;
    --missing-text: #F4B4B4;
}

/* The Radzen theme styles its components but leaves the page body on browser defaults. */
body {
    margin: 0;
    background: var(--rz-body-background-color);
    color: var(--rz-text-color);
    font-family: var(--rz-text-font-family);
}

h1:focus {
    outline: none;
}

/* App shell */
.app-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
    padding-inline: 0.25rem 1rem;
}

.app-logo {
    height: 26px;
    width: auto;
}

.app-title {
    padding-left: 0.75rem;
    border-left: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--rz-text-title-color);
}

.app-user {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.app-user-name {
    color: var(--rz-text-secondary-color);
}

.app-user form {
    margin: 0;
}

.app-user-link {
    margin-inline: 0.5rem;
    color: var(--rz-primary);
    font-size: 0.875rem;
}

.form-panel {
    max-width: 28rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
}

.form-success {
    margin: 0 0 1rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--rz-border-radius);
    background: var(--rz-success-lighter);
    color: var(--rz-on-success-lighter);
}

.app-content {
    padding: 1.5rem;
}

/* Plain links inside pages; Radzen components and styled links carry their own classes. */
.app-content a:not([class]) {
    color: var(--rz-link-color);
}

.app-content a:not([class]):hover {
    color: var(--rz-link-hover-color);
}

.page-title {
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--rz-text-title-color);
}

.page-intro {
    max-width: 60rem;
    margin: -0.5rem 0 1rem;
    color: var(--rz-text-secondary-color);
}

.page-action {
    margin-bottom: 1rem;
}

.device-card {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
}

.device-card header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.5rem;
}

.device-card h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.device-card header span {
    color: var(--rz-text-secondary-color);
    font-size: 0.875rem;
}

/* Same fixed columns in every device card, capped so the switch stays near the door name on wide screens. */
.door-table {
    width: 100%;
    max-width: 56rem;
    table-layout: fixed;
    border-collapse: collapse;
}

.door-table .door-number {
    width: 6rem;
}

.door-table .door-source {
    width: 16rem;
}

.door-table td:first-child {
    overflow-wrap: anywhere;
}

.door-table th,
.door-table td {
    padding: 0.5rem 0.25rem;
    border-top: 1px solid var(--border-subtle);
    text-align: left;
}

.door-table th {
    font-size: 0.875rem;
    color: var(--rz-text-secondary-color);
}

.switch-label {
    margin-left: 0.5rem;
    vertical-align: middle;
}

.assign-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.text-input,
.shift-table input[type="time"],
.num-input {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
    color: var(--rz-text-color);
    font: inherit;
}

.text-input {
    min-width: 16rem;
}

.text-input.short {
    min-width: 8rem;
    width: 9rem;
}

.num-input {
    width: 5.5rem;
}

.num-input.small {
    width: 4rem;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.table-scroll {
    overflow-x: auto;
}

.shift-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--rz-base-background-color);
}

.shift-table th,
.shift-table td {
    padding: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    text-align: left;
    vertical-align: top;
}

.break-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin: 0.375rem 0;
}

.hint {
    color: var(--rz-text-secondary-color);
    font-size: 0.875rem;
}

.section-title {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.detail-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1.5rem;
    margin: 0;
}

.detail-list dt {
    color: var(--rz-text-secondary-color);
}

.detail-list dd {
    margin: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.settings-form {
    display: grid;
    gap: 0.75rem;
    max-width: 34rem;
}

.settings-form label:not(.inline-check) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sync-overview {
    margin-bottom: 1rem;
}

/* Status words always carry text; colour only reinforces it. */
.status-ok {
    color: var(--rz-success-dark);
    font-weight: 600;
}

.status-warn {
    color: var(--late-text);
    font-weight: 600;
}

.status-bad {
    color: var(--rz-danger-dark);
    font-weight: 600;
}

.empty-state {
    max-width: 40rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
}

.empty-state p {
    margin: 0;
}

.empty-state p + p {
    margin-top: 0.5rem;
    color: var(--rz-text-secondary-color);
}

/* Attendance tones: colour always sits next to words (PRD §6.11). */
.tone-late,
.tone-missing {
    padding: 0.0625rem 0.375rem;
    border-radius: var(--rz-border-radius);
}

.tone-late {
    background: var(--late-background);
    color: var(--late-text);
}

.tone-missing {
    background: var(--missing-background);
    color: var(--missing-text);
}

.notice {
    max-width: 60rem;
    margin: 0 0 1rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--rz-border-radius);
    background: var(--late-background);
    color: var(--late-text);
}

.notice p {
    margin: 0 0 0.5rem;
}

.notice a {
    color: inherit;
    font-weight: 600;
}

/* Dashboard numbers: label first in the markup, number shown on top. */
.stat-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2.5rem;
    margin: 0 0 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
}

.stat-strip div {
    display: flex;
    flex-direction: column-reverse;
    min-width: 7rem;
}

.stat-strip dt {
    color: var(--rz-text-secondary-color);
    font-size: 0.875rem;
}

.stat-strip dd {
    margin: 0;
    color: var(--rz-text-title-color);
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.export-actions {
    align-items: center;
    margin: 0 0 1rem;
}

/* A link that looks like a button: navigation stays a real link (middle-click, new tab). */
.link-button {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--rz-primary);
    border-radius: var(--rz-border-radius);
    color: var(--rz-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.link-button:hover {
    background: var(--rz-primary-lighter);
}

.link-button:focus-visible {
    outline: 2px solid var(--rz-primary);
    outline-offset: 2px;
}

.link-button.primary {
    border-color: var(--rz-primary);
    background: var(--rz-primary);
    color: var(--rz-on-primary);
}

.link-button.primary:hover {
    border-color: var(--rz-primary-dark);
    background: var(--rz-primary-dark);
}

.block-label {
    display: block;
    max-width: 40rem;
}

/* Login: rendered without a circuit, so plain elements styled with the theme tokens. */
.login-shell {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--rz-body-background-color);
}

.login-card {
    width: 100%;
    max-width: 24rem;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--rz-base-background-color);
}

.login-logo {
    display: block;
    height: 40px;
    width: auto;
    margin-bottom: 1.25rem;
}

.login-card h1 {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--rz-text-title-color);
}

.login-form {
    display: grid;
    gap: 0.375rem;
}

.login-form label {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rz-text-color);
}

.login-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: var(--rz-border-radius);
    background: var(--rz-base-background-color);
    color: var(--rz-text-color);
    font: inherit;
}

.login-form input:focus-visible {
    border-color: var(--rz-primary);
    outline: 2px solid var(--rz-primary);
    outline-offset: 1px;
}

.login-form button {
    margin-top: 1.25rem;
    padding: 0.625rem 1rem;
    border: 0;
    border-radius: var(--rz-border-radius);
    background: var(--rz-primary);
    color: var(--rz-on-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.login-form button:hover {
    background: var(--rz-primary-dark);
}

.login-form button:focus-visible {
    outline: 2px solid var(--rz-primary-darker);
    outline-offset: 2px;
}

.login-error {
    margin: 0 0 1rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--rz-border-radius);
    background: var(--rz-danger-lighter);
    color: var(--rz-on-danger-lighter);
}

.login-error p {
    margin: 0;
}

.login-error .login-hint {
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.validation-message {
    font-size: 0.875rem;
    color: var(--rz-danger-dark);
}
