/*
 * Application components on top of style.css: layout helpers, form layouts, quota-request details,
 * notifications and the settings screens. Colours come from the tokens in style.css only.
 */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 3000;
    padding: 10px 16px;
    background: var(--brand);
    color: var(--on-brand);
    border-radius: 0 0 var(--radius-sm) 0;
    font-weight: 600;
}

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

.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;
}

.button-reset {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/* ---------- Layout helpers ---------- */

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

.actions-row,
.action-buttons,
.action-btns {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.icon-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stack {
    display: grid;
    gap: 20px;
    align-content: start;
}

.stack > .card {
    margin: 0;
}

.layout-split {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.layout-split > .card {
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 18px;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
    grid-column: 1 / -1;
}

.form-hint {
    color: var(--muted);
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
}

/* A hint placed after a whole form-group sits under its field, not after the group's spacing. */
.form-group + .form-hint,
.field-error + .form-hint {
    margin-top: -10px;
    margin-bottom: 14px;
}

p.form-hint {
    margin: 0 0 14px;
}

.field-error {
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 500;
    margin-top: 6px;
}

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

.form-divider {
    margin: 24px 0;
    border: none;
    border-top: 1px solid var(--line);
}

.form-footer-tight {
    margin-top: 20px;
}

@media (max-width: 1100px) {
    .layout-split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Filter bars (GET forms above tables). */
.filter-form,
.filter-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.filter-form .form-group,
.filter-inline .form-group {
    flex: 1;
    min-width: 170px;
    margin-bottom: 0;
}

.filter-form .btn,
.filter-inline .btn {
    height: 42px;
}

/* ---------- Text utilities ---------- */

.text-muted {
    color: var(--muted);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-center {
    text-align: center;
}

.text-right,
td.number,
th.number,
.data-right {
    text-align: right;
}

.data-center {
    text-align: center;
}

.col-narrow,
.col-no {
    width: 56px;
}

.col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- Cards and details ---------- */

.card-header-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.card-header-split .card-title {
    margin: 0;
}

.tabs-spaced {
    margin-bottom: 20px;
}

.summary-box {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-soft), transparent 70%), var(--surface);
    border: 1px solid var(--line);
}

.summary-box-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.summary-box h3 {
    font-size: 1.6rem;
    font-weight: 800;
}

.summary-box p {
    color: var(--muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 6px;
}

.detail-grid > div {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.detail-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-weight: 700;
    font-size: 1.02rem;
    margin-top: 2px;
}

.reject-note {
    border-left: 4px solid var(--danger);
}

.reject-note-box {
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--danger-ink);
    margin-top: 8px;
}

.table-total td,
.table-total th {
    background: var(--surface-2);
    font-weight: 700;
    color: var(--ink);
}

.sisa-list {
    list-style: none;
    font-size: 0.8rem;
    display: grid;
    gap: 2px;
}

.sisa-list span {
    color: var(--muted);
}

/* ---------- Quota request form ---------- */

.jenis-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.jenis-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    background: var(--surface);
    transition: var(--transition);
}

.jenis-option:hover {
    border-color: var(--brand);
}

.jenis-option:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand-ink);
    box-shadow: var(--ring);
}

.jenis-option input {
    width: 18px;
    height: 18px;
}

.ketersediaan-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.ketersediaan-input-group {
    grid-column: 1 / -1;
    margin-top: 8px;
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ketersediaan-input-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
}

.ketersediaan-input-item label {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.ketersediaan-input-item input {
    width: 100px;
    text-align: center;
}

.ketersediaan-form-row {
    display: grid;
    grid-template-columns: 200px 1fr auto;
    gap: 15px;
    align-items: end;
}

.ketersediaan-form-row .form-group {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .ketersediaan-form-row {
        grid-template-columns: 1fr;
    }
}

/* ---------- Error page ---------- */

.error-title {
    font-size: 1.4rem;
    text-align: center;
}

.error-message {
    text-align: center;
    color: var(--muted);
    margin-top: 8px;
}

/* ---------- Notifications ---------- */

.notif-list {
    list-style: none;
    margin: 0 -22px -22px;
}

.notif-item {
    display: flex;
    gap: 14px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    transition: background 0.15s ease;
}

.notif-item:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.notif-item.unread {
    background: color-mix(in srgb, var(--brand-soft) 60%, transparent);
}

.notif-dot {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--surface-3);
    color: var(--muted);
    flex-shrink: 0;
}

.notif-item.unread .notif-dot {
    background: var(--brand);
    color: var(--on-brand);
}

.notif-body {
    flex: 1;
    min-width: 0;
}

.notif-body p {
    font-weight: 500;
    line-height: 1.45;
}

.notif-item.unread .notif-body p {
    font-weight: 700;
    color: var(--ink);
}

.notif-body time {
    font-size: 0.78rem;
    color: var(--muted);
}

.push-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.push-panel-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
}

.push-panel-icon .icon {
    width: 24px;
    height: 24px;
}

.push-panel-text {
    flex: 1;
    min-width: 220px;
}

.push-panel-text strong {
    display: block;
}

.push-panel-text span {
    color: var(--muted);
    font-size: 0.86rem;
}

/* ---------- Settings screens ---------- */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.settings-grid > .card {
    margin: 0;
}

@media (max-width: 1100px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.provider-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.order-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.order-step {
    position: relative;
    padding: 14px 16px 2px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.order-step-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.order-step-label b {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: var(--on-brand);
    font-size: 0.72rem;
}

@media (max-width: 640px) {
    .order-steps {
        grid-template-columns: 1fr;
    }
}

.copy-field {
    display: flex;
    gap: 8px;
}

.copy-field input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    color: var(--ink-2);
    word-break: break-all;
}

.event-matrix td:not(:first-child),
.event-matrix th:not(:first-child) {
    text-align: center;
    width: 140px;
}

.event-matrix td:first-child strong {
    display: block;
    color: var(--ink);
}

.event-matrix td:first-child small {
    color: var(--muted);
}

/* Switch: a styled checkbox. */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}

.switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--line-strong);
    transition: var(--transition);
}

.switch span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.switch input:checked + span {
    background: var(--brand);
}

.switch input:checked + span::after {
    transform: translateX(18px);
}

.switch input:focus-visible + span {
    box-shadow: var(--ring);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.steps-list {
    counter-reset: step;
    list-style: none;
    display: grid;
    gap: 10px;
}

.steps-list li {
    counter-increment: step;
    position: relative;
    padding-left: 36px;
    color: var(--ink-2);
    font-size: 0.9rem;
}

.steps-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Push message received while the page is open (webroot/js/push.js). */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    display: grid;
    gap: 2px;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    box-shadow: var(--shadow-lg);
    color: var(--ink-2);
    animation: fadeIn 0.25s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast strong {
    color: var(--ink);
}

.toast-hide {
    opacity: 0;
    transform: translateY(8px);
}

.error-shell {
    min-height: 100vh;
}

/* SVG icons inside the coloured icon tiles. */
.stat-icon .icon,
.summary-box-icon .icon {
    width: 24px;
    height: 24px;
}

.summary-box-icon {
    color: var(--brand);
}

.modal-header-icon .icon {
    width: 22px;
    height: 22px;
}

.modal-file-upload-icon {
    color: var(--brand);
}

.modal-file-upload-icon .icon {
    width: 30px;
    height: 30px;
}
