/* =====================================================================
   COMPONENTS.CSS — shared UI pieces
   Buttons, cards, tables, forms, status pills, pagination, modal skin.
   Defined once here, consumed by module pages starting Phase 1 — no
   module markup references these classes yet as of Phase 0.
   See simaset-redesign-strategy.md §3 / §6 / §7.
===================================================================== */

/* ── CARDS ───────────────────────────────────────────────────────── */
.app-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
}

.app-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    color: var(--text-primary);
}

.app-card-body { padding: 20px; }

/* ── KPI CARDS ───────────────────────────────────────────────────── 
   Originated in dashboard.css (Phase 1), moved here since more than
   one module reuses it now (per §6 — shared, so it belongs here). */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--brand-accent-muted);
    color: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.kpi-icon--active  { background: rgba(95, 185, 138, 0.14); color: var(--status-active); }
.kpi-icon--danger  { background: rgba(217, 120, 120, 0.14); color: var(--status-danger); }
.kpi-icon--warning { background: rgba(201, 164, 90, 0.14); color: var(--status-warning); }
.kpi-icon--neutral { background: rgba(107, 112, 120, 0.14); color: var(--status-neutral); }

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── KPI CARDS — compact modifier ────────────────────────────────── 
   For accessory placements (a page-header stat strip) where the full
   dashboard-sized card would be too wide/heavy — same component,
   smaller footprint. */
.page-header-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header-stats--end {
    justify-content: flex-end;
}

.kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.kpi-card--compact {
    padding: 8px 14px;
    gap: 10px;
}

.kpi-card--compact .kpi-icon {
    width: 30px;
    height: 30px;
    font-size: 13px;
}

.kpi-card--compact .kpi-value {
    font-size: 17px;
}

.kpi-card--compact .kpi-label {
    font-size: 11px;
    margin-top: 0;
    white-space: nowrap;
}

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.app-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.app-btn-primary {
    background: var(--brand-accent);
    color: var(--surface-base);
}
.app-btn-primary:hover { background: var(--brand-accent-hover); }

.app-btn-secondary {
    background: var(--surface-raised);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
.app-btn-secondary:hover { background: var(--surface-base); }

.app-btn-danger {
    background: transparent;
    border-color: var(--status-danger);
    color: var(--status-danger);
}
.app-btn-danger:hover { background: rgba(217, 120, 120, 0.12); }

.app-btn-warning {
    background: transparent;
    border-color: var(--status-warning);
    color: var(--status-warning);
}
.app-btn-warning:hover { background: rgba(201, 164, 90, 0.12); }

/* Approve actions (Phase 4f) — same outline shape as danger/warning,
   just toned with --status-active since there was no positive-action
   button variant yet (every existing primary action used the neutral
   brand-accent .app-btn-primary instead). */
.app-btn-success {
    background: transparent;
    border-color: var(--status-active);
    color: var(--status-active);
}
.app-btn-success:hover { background: rgba(95, 185, 138, 0.12); }

.app-btn-sm { padding: 5px 12px; font-size: 12px; }

/* Icon-only buttons (Phase 4g) — square aspect instead of .app-btn-sm's
   rectangular text padding, which left icon-only buttons (first used
   in asset/data.php's Detail/Edit/Delete row actions) off-center in a
   too-wide box. Combine with .app-btn-sm for the row-action size (e.g.
   class="app-btn app-btn-secondary app-btn-sm app-btn-icon"); the icon
   itself still needs a title + aria-label since the text is gone. */
.app-btn-icon {
    padding: 0;
    width: 30px;
    height: 30px;
    justify-content: center;
    gap: 0;
}

/* ── FORMS ───────────────────────────────────────────────────────── */
.form-card {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 24px;
}

.admin-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Required-field marker — themed instead of Bootstrap's bright
   .text-danger. Started life scoped to asset.css as .asset-required
   (only the asset module marked required fields at the time); a
   second module needing it (perawatan) promotes it to shared here.
   .asset-required kept as a compatibility alias so the already-shipped
   asset module markup doesn't need touching. */
.field-required,
.asset-required {
    color: var(--status-danger);
}

.admin-form-input,
.admin-form-select,
.admin-form-textarea {
    width: 100%;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    padding: 9px 12px;
    line-height: 1.5;
    transition: border-color var(--transition);
}

.admin-form-input:focus,
.admin-form-select:focus,
.admin-form-textarea:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px var(--brand-accent-muted);
}

.admin-form-textarea { min-height: 100px; resize: vertical; }

.form-field { margin-bottom: 16px; }

/*
|--------------------------------------------------------------------------
| Detail list — label:value rows, replaces raw Bootstrap
| table-borderless for read-only field displays. First used on the
| asset QR page; detail.php will want the same shape for spec fields.
|--------------------------------------------------------------------------
*/

.detail-list {
    width: 100%;
}

.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    width: 35%;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-value {
    color: var(--text-primary);
}

/* Inline field error, consumed by admin.js's showFieldError() once wired in */
.field-error {
    font-size: 12px;
    color: var(--status-danger);
    margin-top: 4px;
}

/* ── FILE UPLOAD — styled trigger + image preview ──────────────────
   First real file-input need to get proper treatment (previously a
   raw unstyled <input type="file">, inconsistent across browsers).
   Generic, not perawatan-specific — any future upload field (e.g. an
   approval-module evidence photo) reuses this. Preview generation
   itself is client-side (FileReader, no upload) via admin.js's
   initFileUpload(). */
.file-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: -1px;
}

.file-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-upload-name {
    font-size: 13px;
    color: var(--text-muted);
}

.file-preview {
    margin-top: 10px;
}

.file-preview-item {
    position: relative;
    display: inline-block;
}

.file-preview-item img {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.file-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--status-danger);
    color: #fff;
    border: 2px solid var(--surface-raised);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
}

/* ── CHECKBOX ────────────────────────────────────────────────────────
   First real checkbox need in the app (input_perawatan.php's Jenis
   Pekerjaan list) — generic, so it lives here rather than getting a
   module prefix; any future module can reuse it. */
.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.checkbox-field:hover { border-color: var(--brand-accent); }

.checkbox-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-accent);
    flex-shrink: 0;
}

.checkbox-field span {
    font-size: 13px;
    color: var(--text-primary);
}

/* ── DATA TABLE ──────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.35;
}

.data-table thead th {
    background: var(--surface-sidebar);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    height: 36px;
}

.data-table tbody tr:nth-child(even) { background: var(--surface-raised); }

/* Left-border accent + faint tint instead of a solid full-row fill —
   reads calmer at high row density. */
.data-table tbody tr:hover {
    background: var(--brand-accent-muted);
    box-shadow: inset 3px 0 0 var(--brand-accent);
}

.data-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

/* ── SORTABLE COLUMN HEADERS ─────────────────────────────────────── 
   Applied to every column except Aksi. */
.data-table th.th-sort a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
}

.data-table th.th-sort a:hover { color: var(--text-primary); }

.data-table th.th-sort.active a { color: var(--text-primary); }

.data-table th.th-sort .sort-icon {
    font-size: 10px;
    color: var(--text-muted);
}

.data-table th.th-sort.active .sort-icon { color: var(--brand-accent); }

/* ── TABLE TOOLBAR / SEARCH ──────────────────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    min-width: 260px;
}

.table-search i { color: var(--text-muted); font-size: 12px; }

.table-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    padding: 2px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition);
}

.table-search-btn:hover { color: var(--brand-accent); background: var(--brand-accent-muted); }
.table-search-btn i { color: inherit; }

.table-search input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    width: 100%;
}

.table-search input::placeholder { color: var(--text-muted); }

.table-search:focus-within {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px var(--brand-accent-muted);
}

/* ── STATUS PILLS ────────────────────────────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill--active  { background: rgba(95, 185, 138, 0.14); color: var(--status-active); }
.status-pill--danger  { background: rgba(217, 120, 120, 0.14); color: var(--status-danger); }
.status-pill--warning { background: rgba(201, 164, 90, 0.14); color: var(--status-warning); }
.status-pill--neutral { background: rgba(107, 112, 120, 0.14); color: var(--status-neutral); }

/*
|--------------------------------------------------------------------------
| Info banner — themed replacement for raw Bootstrap .alert-info.
| Same accent-rail chrome idiom as the modal (Option B), so it reads as
| part of this system rather than a default Bootstrap component.
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| Banner — themed replacement for raw Bootstrap .alert-*. Generalized
| from .info-banner (kept below as a compatibility alias so already-
| shipped usages don't break) into a base + status-tone modifiers, since
| the asset entry form needs success/error/warning variants too — same
| accent-rail chrome idiom as the modal (Option B).
|--------------------------------------------------------------------------
*/

.banner,
.info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--brand-accent);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.info-banner--top-margin {
    margin-top: 12px;
}

.banner i,
.info-banner i {
    color: var(--brand-accent);
    font-size: 14px;
}

.banner--success { border-left-color: var(--status-active); }
.banner--success i { color: var(--status-active); }

.banner--danger { border-left-color: var(--status-danger); }
.banner--danger i { color: var(--status-danger); }

.banner--warning { border-left-color: var(--status-warning); }
.banner--warning i { color: var(--status-warning); }

/* ── PAGINATION ──────────────────────────────────────────────────── */
.app-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 16px;
}

.app-pagination .page-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.app-pagination .page-btn:hover { background: var(--surface-raised); color: var(--text-primary); border-color: var(--text-muted); }
.app-pagination .page-btn.active { background: var(--brand-accent); color: var(--surface-base); border-color: var(--brand-accent); }
.app-pagination .page-btn.disabled { opacity: 0.35; pointer-events: none; }
.app-pagination .page-ellipsis { color: var(--text-muted); font-size: 13px; padding: 0 4px; }

/* ── MODAL — custom engine (Option B: accent rail + monospace tag) ──
   Replaces Bootstrap's native modal. Driven by admin.js's openModal()/
   closeModal()/closeAllModals() — the element carrying the modal's id
   IS the backdrop; admin.js toggles `.active` on it directly.
   See simaset-redesign-strategy.md §11 (Phase 2 modal decision). */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 180ms ease;
}

.modal-backdrop.active {
    display: flex;
    opacity: 1;
}

.app-modal {
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--surface-raised);
    border-left: 3px solid var(--brand-accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    color: var(--text-primary);
    padding: 20px 22px;
    transform: scale(0.96);
    opacity: 0;
    transition: transform 180ms ease, opacity 180ms ease;
}

.modal-backdrop.active .app-modal {
    transform: scale(1);
    opacity: 1;
}

.app-modal--lg { max-width: 640px; }

.app-modal-tag {
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--brand-accent);
    margin-bottom: 6px;
}

.app-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.app-modal-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.app-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    transition: color var(--transition);
}

.app-modal-close:hover { color: var(--text-primary); }

.app-modal-body { display: flex; flex-direction: column; }

.app-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ── CONFIRM-DELETE MODAL — shared, Phase 4 decision #3 ──────────────
   Not perawatan-specific despite being introduced here — any module's
   delete action can reuse `confirmDelete()` (admin.js) + this markup
   shape, per §6 governance (named for what it is, not what module
   uses it first). Built on the same app-modal/openModal/closeModal
   engine above, not a new one-off. `.app-modal--danger` is a general
   modifier for any destructive-confirmation modal, not delete-only. */
.app-modal--danger { border-left-color: var(--status-danger); }

.confirm-delete-body {
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 4px 0 8px;
}

.confirm-delete-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(217, 120, 120, 0.12);
    color: var(--status-danger);
    font-size: 20px;
}

.confirm-delete-message {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0;
}

/* ── CONFIRM-APPROVE MODAL — shared, Phase 4f ─────────────────────────
   Same app-modal/openModal/closeModal engine + confirmDelete()'s exact
   shape (admin.js's confirmApprove()), just success-toned instead of
   danger-toned since Approve is a positive, non-destructive action.
   templates/confirm_approve_modal.php is the markup partner. */
.app-modal--success { border-left-color: var(--status-active); }

.confirm-approve-body {
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 4px 0 8px;
}

.confirm-approve-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(95, 185, 138, 0.12);
    color: var(--status-active);
    font-size: 20px;
}

.confirm-approve-message {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0;
}

/* ── REJECT MODAL — shared, Phase 4f ──────────────────────────────────
   Genuinely different shape from confirm-delete/confirm-approve: this
   one holds real input (the required alasan_reject textarea), not just
   a static confirm message + link, so its body is a <form> posting to
   approval/reject.php rather than a bare <a href>. templates/
   reject_modal.php is the markup partner; admin.js's openRejectModal()
   sets the form's action/hidden fields before opening it, since the
   same markup is reused from both modules/approval/index.php and
   modules/perawatan/detail.php with a different target path. */
.reject-modal-message {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0 0 14px;
}

/* ── WIP / COMING SOON PANEL ─────────────────────────────────────── */
/* Used by templates/wip.php for modules not built yet (currently:
   perawatan, approval). Was hardcoded (#eef2ff/#4f46e5/#1f2937/#6b7280)
   in admin.css, never themed — drained here and repointed at tokens so
   it actually responds to the light/dark toggle instead of staying a
   fixed light-mode indigo panel regardless of theme. Icon/badge use
   the brand accent (not a status color) — "coming soon" isn't a
   good/bad axis, same reasoning as tenant's untoned `paket` cards. */

.wip-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.wip-icon {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: var(--brand-accent-muted);
    color: var(--brand-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 22px;
}

.wip-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.wip-desc {
    color: var(--text-secondary);
    max-width: 420px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.wip-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--brand-accent);
    background: var(--brand-accent-muted);
    border-radius: 20px;
    padding: 5px 14px;
    margin-bottom: 14px;
}