/*
 * Additions to style.css for the CakePHP version: inline SVG icons, accessibility helpers,
 * form errors rendered by FormHelper (config/app_form.php) and error pages.
 */

.icon {
    width: 1.1em;
    height: 1.1em;
    flex-shrink: 0;
    vertical-align: -0.15em;
}

/* Bottom bar on phones and tablets: main pages plus the button that opens the sidebar. */
.bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 900;
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgb(0 0 0 / 6%);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 60px;
    padding: 0.375rem 0.25rem;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.bottom-nav-item .icon {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.active,
.bottom-nav-item[aria-expanded='true'] {
    color: var(--primary);
}

.bottom-nav-item:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}

/* Room for the bottom bar, so the footer is not hidden behind it. */
.main-content:has(~ .bottom-nav) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

@media (min-width: 1024px) {
    .bottom-nav {
        display: none;
    }

    .main-content:has(~ .bottom-nav) {
        padding-bottom: 0;
    }
}

@media print {
    .bottom-nav {
        display: none;
    }
}

.nav-item .icon {
    width: 20px;
    height: 20px;
}

.icon-lg {
    width: 2rem;
    height: 2rem;
    color: var(--gray-400);
    margin-bottom: 0.5rem;
}

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

.inline-form {
    display: inline;
    margin: 0;
}

.file-upload {
    display: block;
    position: relative;
}

.file-upload .icon-lg {
    display: block;
    margin: 0 auto 0.5rem;
}

/* The file input stays keyboard reachable (style.css hid it with display:none). */
.file-upload input.visually-hidden {
    display: block;
}

.file-upload:focus-within {
    border-color: var(--primary);
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

ul.autocomplete-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nomor-preview {
    background: var(--gray-100);
    font-weight: 600;
}

/* ------------------------------------------------------------------ Theme */

.logo-on-dark,
.theme-icon-sun {
    display: none;
}

:root[data-theme="dark"] .logo-on-light,
:root[data-theme="dark"] .theme-icon-moon {
    display: none;
}

:root[data-theme="dark"] .logo-on-dark,
:root[data-theme="dark"] .theme-icon-sun {
    display: inline-flex;
}

:root[data-theme="dark"] img.logo-on-dark {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo-on-light,
    :root:not([data-theme="light"]) .theme-icon-moon {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-icon-sun {
        display: inline-flex;
    }

    :root:not([data-theme="light"]) img.logo-on-dark {
        display: block;
    }
}

.content-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.theme-toggle:hover {
    background: var(--gray-100);
    color: var(--text);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle-floating {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

/* ------------------------------------------------------------------ Sign-in & account pages */

.auth-left {
    background:
        radial-gradient(circle at 0% 0%, var(--primary-soft), transparent 45%),
        radial-gradient(circle at 100% 100%, var(--primary-soft), transparent 40%),
        var(--bg);
}

.auth-column {
    width: 100%;
    max-width: 440px;
}

/* Room for the floating theme button above the card on phones. */
@media (max-width: 767.98px) {
    .auth-left {
        padding-top: 4.5rem;
    }
}

.auth-column .login-card {
    max-width: none;
}

.login-card .login-header {
    margin-bottom: 1.5rem;
}

.login-card .login-logo {
    max-width: 190px;
}

.login-card .login-header h1 {
    margin: 1.25rem 0 0.375rem;
    font-size: 1.375rem;
}

.login-card .login-header p {
    max-width: 32ch;
    margin: 0 auto;
    line-height: 1.5;
}

.auth-footer {
    margin-top: 1.25rem;
    color: var(--subtle);
    font-size: 0.75rem;
    text-align: center;
}

/* An input with an icon at the start and, optionally, a button at the end (show password). */
.input-icon {
    position: relative;
    flex: 1;
    min-width: 0;
}

.input-icon > svg {
    position: absolute;
    top: 50%;
    left: 0.875rem;
    width: 18px;
    height: 18px;
    color: var(--subtle);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-icon > .form-control {
    padding-left: 2.625rem;
}

.input-icon.has-action > .form-control {
    padding-right: 3rem;
}

.input-icon:focus-within > svg {
    color: var(--primary);
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--subtle);
    transform: translateY(-50%);
    cursor: pointer;
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
    background: var(--gray-100);
    color: var(--primary);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button > .btn {
    flex-shrink: 0;
}

.form-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.link-small {
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0 1rem;
    color: var(--subtle);
    font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}

.auth-switch {
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
}

.auth-switch a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.auth-switch svg {
    width: 16px;
    height: 16px;
}

/* The employee found for an NIP, or the account a link belongs to. */
.nip-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid var(--primary-ring);
    border-radius: var(--radius);
    background: var(--primary-soft);
}

.nip-result[hidden] {
    display: none;
}

.nip-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    font-size: 0.8125rem;
    font-weight: 700;
}

.nip-detail {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.nip-detail small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.nip-result.is-error {
    border-color: var(--danger-border);
    background: var(--danger-soft);
}

.nip-result.is-error .nip-avatar {
    background: var(--danger);
    color: var(--on-solid);
}

.nip-result.is-error strong {
    color: var(--danger-text);
}

/* Steps of a flow in the brand panel. */
.auth-steps {
    padding: 1.5rem;
    border: 1px solid rgb(255 255 255 / 0.2);
    border-radius: var(--radius-lg);
    background: rgb(255 255 255 / 0.08);
}

.auth-steps h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 700;
}

.auth-steps ol {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.auth-steps li {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0 0.875rem;
    counter-increment: step;
}

.auth-steps li::before {
    content: counter(step);
    display: inline-flex;
    grid-row: span 2;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--lime);
    color: #12321a;
    font-weight: 800;
}

.auth-steps span {
    color: rgb(255 255 255 / 0.8);
    font-size: 0.875rem;
}

.registration-status {
    justify-content: space-between;
    flex-wrap: wrap;
}

.decision-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.reject-form {
    display: flex;
    gap: 0.5rem;
    flex: 1 1 16rem;
}

.reject-form .form-control {
    min-width: 0;
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--muted);
}

.card-header h3 .badge {
    margin-left: 0.5rem;
    vertical-align: middle;
}

.info-box {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: var(--gray-100);
}

.redirect-uri {
    overflow-wrap: anywhere;
}

.send-order {
    margin: 0;
    padding-left: 1.25rem;
}

/* A button aligned with the inputs of its row (the label row is left empty). */
.form-row.align-end {
    align-items: end;
}

@media (min-width: 768px) {
    .form-row.align-end {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

.edited-by {
    color: var(--warning);
}

.edited-by svg {
    width: 0.85em;
    height: 0.85em;
    vertical-align: -0.1em;
}

output.nomor-preview {
    display: block;
    min-height: 2.5rem;
    overflow-wrap: anywhere;
}

.format-input {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

ul.format-vars {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: 0.5rem 1rem;
}

.format-vars li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.format-vars .btn {
    flex-shrink: 0;
}

.result-box {
    margin-top: 0;
}

.result-box .copy-btn {
    color: var(--dark);
}

.info-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
}

.info-list dt {
    color: var(--gray-600);
}

.info-list dd {
    font-weight: 600;
}

.report-filter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
}

.report-filter-submit .btn {
    width: 100%;
}

.report-filter .form-group {
    margin-bottom: 0;
}

/* Kinds of letter in the report filter: checkboxes in a wrapping row. */
.jenis-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 1rem 0 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.jenis-filter legend {
    width: 100%;
    margin-bottom: 0.25rem;
}

/* A dropdown of checkboxes: <details> keeps it usable without JavaScript; app.js closes it on outside click. */
.multi-select {
    position: relative;
    flex: 1 1 100%;
    min-width: 0;
}

.multi-select summary {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.multi-select summary::-webkit-details-marker {
    display: none;
}

.multi-select summary span:not(.visually-hidden) {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.multi-select-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    min-width: 100%;
    padding: 0.25rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

.multi-select-menu .check-option:first-child {
    border-bottom: 1px solid var(--border);
}

/* "Tampilkan 10/25/..." rows-per-page choice next to a search. */
.per-page {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 40%;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.875rem;
}

.per-page select {
    width: auto;
    min-width: 5rem;
}

@media (min-width: 768px) {
    .per-page {
        flex: 0 0 auto;
    }
}

.check-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    cursor: pointer;
}

.check-option input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.report-section-title {
    margin: 1rem 0 0.5rem;
}

a.tab {
    text-decoration: none;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 3000;
    padding: 0.625rem 1rem;
    background: var(--primary);
    color: var(--on-primary);
    border-radius: 0 0 var(--radius-sm) 0;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    color: var(--gray-500);
    font-size: 0.8rem;
}

.field-error {
    margin-top: 0.25rem;
    color: var(--danger);
    font-size: 0.85rem;
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.sidebar-footer form {
    margin: 0;
}

.error-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.error-message {
    color: var(--gray-600);
    text-align: center;
}

.error-shell .auth-left {
    flex: 1;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* Radio choices shown as a segmented control; the radio stays focusable for keyboard users. */
.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.choice {
    position: relative;
    display: block;
    flex: 1 1 auto;
    cursor: pointer;
}

/* The short name of a kind replaces its full name on phones. */
.choice-short {
    display: none;
    text-decoration: none;
}

@media (max-width: 575.98px) {
    .choice-full {
        display: none;
    }

    .choice-short {
        display: inline;
    }
}

.choice input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.choice > span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    color: var(--gray-700);
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.choice:hover > span {
    border-color: var(--primary);
}

.choice input:checked + span {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.choice input:focus-visible + span {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.autocomplete-meta {
    display: block;
    color: var(--gray-600);
    font-size: 0.75rem;
}

.autocomplete-item.selected .autocomplete-meta {
    color: inherit;
}

.import-box {
    padding: 1rem;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
    background: var(--light);
}

.import-errors {
    margin: 0.5rem 0 0 1.25rem;
}

@media (min-width: 768px) {
    .form-row-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
