/* =====================================================
   InventarisKu - Admin Theme (mirroring Stokbox PHP)
   ===================================================== */

:root {
    --admin-bg: #f7f9fc;
    --admin-sidebar: #101828;
    --admin-sidebar-soft: #1d2939;
    --admin-text: #101828;
    --admin-muted: #667085;
    --admin-border: #e4e7ec;
    --admin-card: #ffffff;
    --admin-primary: #2563eb;
    --admin-success: #16a34a;
    --admin-warning: #f59e0b;
    --admin-danger: #dc2626;
}

body {
    min-height: 100vh;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.875rem;
}

a { text-decoration: none; }

/* === Layout === */
.admin-layout { min-height: 100vh; display: flex; }

.sidebar {
    width: 238px;
    flex: 0 0 238px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    background: var(--admin-sidebar);
    color: #ffffff;
    padding: 20px 14px;
    transition: width .2s ease, flex-basis .2s ease, padding .2s ease;
    overflow: hidden;
}
.sidebar.is-collapsed {
    width: 82px;
    flex-basis: 82px;
    padding: 20px 12px;
}
.brand-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}
.sidebar.is-collapsed .brand-box { justify-content: center; padding-left: 0; padding-right: 0; }
.brand-mark,
.brand-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #ffffff;
    color: var(--admin-sidebar);
    font-weight: 800;
    object-fit: contain;
    padding: 2px;
    flex: 0 0 auto;
}
.brand-text, .sidebar-link span, .sidebar-footer, .menu-label {
    transition: opacity .15s ease, width .15s ease;
}
.brand-text { min-width: 0; }
.brand-text .fw-bold, .brand-text .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.is-collapsed .brand-text,
.sidebar.is-collapsed .sidebar-link span,
.sidebar.is-collapsed .sidebar-footer { width: 0; opacity: 0; overflow: hidden; white-space: nowrap; }
.sidebar.is-collapsed .menu-label {
    height: 1px; margin: 18px 8px 8px; overflow: hidden;
    opacity: .35; color: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.menu-label {
    margin: 20px 10px 8px;
    color: #98a2b3;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.sidebar-menu { display: grid; gap: 3px; }
.sidebar-link {
    display: flex;
    align-items: center;
    font-size: 0.90rem;
    gap: 11px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #d0d5dd;
    font-weight: 600;
    white-space: nowrap;
}
.sidebar.is-collapsed .sidebar-link { justify-content: center; gap: 0; padding: 10px; }
.sidebar-link i { width: 20px; flex: 0 0 20px; text-align: center; font-size: 1rem; }
.sidebar-link:hover, .sidebar-link.active {
    background: var(--admin-sidebar-soft);
    color: #ffffff;
}
.sidebar-footer {
    margin-top: 10px;
    padding: 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #d0d5dd;
}
.sidebar-user-photo,
.sidebar-user-photo-placeholder {
    width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
    font-size: .8rem;
}
.sidebar-user-photo { object-fit: cover; background: #ffffff; }
.sidebar-user-photo-placeholder {
    display: grid; place-items: center;
    background: #ffffff; color: var(--admin-sidebar); font-weight: 800;
}

.main-area { flex: 1; min-width: 0; font-size: 0.90rem; }

.topbar {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 20px;
}
.topbar-sidebar-toggle {
    width: 32px; height: 32px; padding: 0; border-color: var(--admin-border);
}
.topbar-spacer { flex: 1; }

.content-area { padding: 20px; }
.page-heading-area { padding-bottom: 0; }
.page-heading {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding-bottom: 14px; border-bottom: 1px solid var(--admin-border);
}
.page-heading-action { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 auto; }
.page-title { font-size: 24px; font-weight: 800; margin-bottom: 1px; line-height: 1.2; }

.panel, .summary-card {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.04);
}
.summary-card { height: 100%; }
.summary-card-body { padding: 16px 20px; }
.icon-box {
    width: 44px; height: 44px; display: grid; place-items: center;
    border-radius: 8px; background: #eff6ff; color: var(--admin-primary); font-size: 20px;
}
.icon-box.success { background: #ecfdf3; color: var(--admin-success); }
.icon-box.warning { background: #fffbeb; color: var(--admin-warning); }
.icon-box.danger { background: #fef2f2; color: var(--admin-danger); }
.icon-box.info { background: #edf9ff; color: #0ea5e9; }
.icon-box.secondary { background: #f3f4f6; color: #6b7280; }

.activity-item { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--admin-border); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot {
    width: 10px; height: 10px; margin-top: 7px; border-radius: 999px;
    background: var(--admin-primary); flex: 0 0 auto;
}
.performance-chart { display: grid; gap: 12px; }
.performance-chart-row { display: grid; grid-template-columns: minmax(160px, 260px) 1fr auto; gap: 14px; align-items: center; }
.performance-chart-name { min-width: 0; }
.performance-chart-track { height: 13px; overflow: hidden; border-radius: 999px; background: #e5e7eb; }
.performance-chart-bar { height: 100%; min-width: 2px; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #16a34a); }
.performance-chart-value { min-width: 56px; text-align: right; }

.profile-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--admin-border);
    border-radius: 8px; background: #ffffff; color: var(--admin-text);
}
.user-menu-toggle { min-height: 42px; max-width: 280px; }
.user-menu-photo { object-fit: cover; }
.user-menu { min-width: 230px; border-color: var(--admin-border); border-radius: 8px; }
.notification-toggle {
    position: relative; width: 42px; height: 42px;
    border: 1px solid var(--admin-border); border-radius: 8px;
    background: #ffffff; color: var(--admin-text);
}
.notification-toggle .badge {
    position: absolute; top: -6px; right: -6px;
    min-width: 19px; height: 19px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px; border: 2px solid #ffffff; font-size: 10px;
}
.notification-menu {
    width: min(420px, calc(100vw - 32px));
    border-color: var(--admin-border); border-radius: 8px;
}
.notification-list { max-height: 360px; overflow-y: auto; }
.notification-item {
    display: block; padding: 11px 14px; color: var(--admin-text);
    border-top: 1px solid var(--admin-border);
}
.notification-item:hover { background: #f8fafc; color: var(--admin-text); }
.notification-item-code { font-size: 12px; font-weight: 800; color: var(--admin-warning); }
.user-menu .dropdown-item {
    display: flex; align-items: center; padding: .45rem .9rem; font-size: .9rem;
}

.avatar, .photo-placeholder {
    display: grid; place-items: center; border-radius: 8px;
    background: #eef2ff; color: #4338ca; font-weight: 800;
}
.avatar { width: 36px; height: 36px; }
.user-photo, .photo-placeholder { width: 44px; height: 44px; }
.preview-photo, .preview-placeholder { width: 88px; height: 88px; }
.user-photo, .preview-photo { object-fit: cover; border-radius: 8px; background: #eef2ff; }

.form-control, .form-select {
    border-radius: 2px;
    padding: .3rem .9rem;
    font-size: .875rem;
}
.form-label { font-weight: 600; font-size: .82rem; margin-bottom: .25rem; }

.select2-container--default .select2-selection--single {
    height: 31px; border: 1px solid var(--admin-border); border-radius: 2px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--admin-text); line-height: 29px; padding-left: .9rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 29px; }
.select2-dropdown { border-color: var(--admin-border); z-index: 1050; }
.select2-container--open .select2-dropdown--below { z-index: 1051; }
.select2-results__options { max-height: 200px; }
/* Cegah Select2 dropdown menimpa DataTable */
/* Jarak aman antara filter panel dan DataTable */
.panel + .panel { margin-top: 1rem; }
.dataTables_wrapper { position: relative; }

.filepond--root { font-family: inherit; margin-bottom: .5rem; }
.filepond--panel-root { background-color: #f8fafc; border: 1px dashed var(--admin-border); }

.btn {
    --bs-btn-padding-y: .25rem;
    --bs-btn-padding-x: .5rem;
    --bs-btn-font-size: .875rem;
    --bs-btn-border-radius: .25rem;
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .25rem;
}
.btn i { font-size: .875rem; line-height: 1; }
.btn-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; line-height: 1; }
.btn-sm { min-height: 28px; }

.dt-container, .dataTables_wrapper { color: var(--admin-text); }
.dataTables_wrapper .dataTables_filter input,
.dt-container .dt-search input {
    border: 1px solid var(--admin-border); border-radius: 8px;
    padding: .5rem .75rem;
}
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-length select {
    border: 1px solid var(--admin-border); border-radius: 8px;
    padding: .375rem 2rem .375rem .75rem;
}
.dataTables_wrapper .dataTables_filter input,
.dt-container .dt-search input { margin-left: .5rem; }
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-length select { margin: 0 .4rem; }
.dataTables_wrapper .page-link, .dt-container .page-link {
    color: var(--admin-sidebar); border-color: var(--admin-border);
}
.dataTables_wrapper .active > .page-link,
.dataTables_wrapper .page-link.active,
.dt-container .active > .page-link,
.dt-container .page-link.active {
    background: var(--admin-sidebar); border-color: var(--admin-sidebar); color: #ffffff;
}

.mobile-menu-button { display: none; }

/* === Login === */
.auth-body {
    min-height: 100vh;
    margin: 0;
    background: url('/static/img/bg-login.jpg') center/cover no-repeat;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.auth-wrap {
    width: 100%; max-width: 420px;
}
.auth-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(6px);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(16, 24, 40, 0.18);
    padding: 32px 28px;
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; }
.auth-brand h1 { font-size: 1.25rem; font-weight: 800; margin: 10px 0 2px; }
.auth-tagline { color: var(--admin-muted); font-size: .85rem; margin: 0; }

.error-display { margin: 16px 0 24px; }
.error-code {
    display: inline-block;
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(37, 99, 235, 0.15);
}
.auth-form .form-group { margin-bottom: 14px; }
.auth-form .input-group {
    display: flex; align-items: center;
    border: 1px solid var(--admin-border); border-radius: 6px; background: #ffffff;
    padding: 0 10px;
}
.auth-form .input-group i { color: var(--admin-muted); margin-right: 8px; }
.auth-form .input-group input {
    flex: 1; border: 0; outline: 0; padding: 9px 0; background: transparent;
}
.auth-form .input-group input:focus { box-shadow: none; }
.auth-form .btn-toggle-pass { background: none; border: 0; color: var(--admin-muted); cursor: pointer; }
.auth-form .btn-block { width: 100%; padding: 10px; font-size: .95rem; min-height: 42px; }
.auth-hint { text-align: center; color: var(--admin-muted); margin-top: 14px; }
.auth-hint code { background: #f1f5f9; padding: 1px 6px; border-radius: 3px; }

.spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Badges === */
.badge-role-admin { background: var(--admin-primary); color: #fff; }
.badge-role-staff { background: #6b7280; color: #fff; }
.badge-status-tersedia { background: #ecfdf3; color: #047857; }
.badge-status-hampir { background: #fffbeb; color: #b45309; }
.badge-status-habis { background: #fef2f2; color: #b91c1c; }
.badge-status-aktif { background: #ecfdf3; color: #047857; }
.badge-status-batal { background: #f3f4f6; color: #4b5563; }

/* === Tables === */
.table {
    font-size: .875rem;
    --bs-table-color: var(--admin-text);
}
.table thead th {
    background: #f8fafc;
    color: var(--admin-muted);
    font-size: .75rem;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--admin-border);
    padding: .65rem .9rem;
}
.table tbody td { vertical-align: middle; padding: .65rem .9rem; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table img.thumb-sm { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.table .icon-cell { width: 36px; height: 36px; display: inline-grid; place-items: center; background: #eff6ff; color: var(--admin-primary); border-radius: 6px; }

/* === Cards (panel) === */
.panel-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--admin-border);
}
.panel-title { font-weight: 700; font-size: 1rem; margin: 0; }
.panel-body { padding: 18px; }

/* === Modal === */
.modal-content { border: 1px solid var(--admin-border); border-radius: 8px; }
.modal-header { border-bottom: 1px solid var(--admin-border); padding: 14px 18px; }
.modal-footer { border-top: 1px solid var(--admin-border); padding: 12px 18px; }
.modal-title { font-weight: 700; font-size: 1rem; }

/* === Toast === */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1080; }
.toast-item {
    background: #ffffff; border: 1px solid var(--admin-border);
    border-left: 4px solid var(--admin-primary);
    border-radius: 6px; padding: 10px 14px; margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
    min-width: 260px; max-width: 360px;
    animation: slideIn .2s ease;
}
.toast-item.success { border-left-color: var(--admin-success); }
.toast-item.danger { border-left-color: var(--admin-danger); }
.toast-item.warning { border-left-color: var(--admin-warning); }
.toast-item .toast-title { font-weight: 700; font-size: .85rem; }
.toast-item .toast-msg { font-size: .82rem; color: var(--admin-muted); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === Icon picker (kategori) === */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto; padding: 6px; border: 1px solid var(--admin-border); border-radius: 6px; }
.icon-picker-item {
    width: 38px; height: 38px; display: grid; place-items: center;
    border: 1px solid var(--admin-border); border-radius: 6px;
    cursor: pointer; font-size: 1rem; color: var(--admin-text);
    background: #ffffff;
}
.icon-picker-item:hover { background: #f1f5f9; }
.icon-picker-item.active { background: var(--admin-primary); color: #ffffff; border-color: var(--admin-primary); }

/* === Item table (multi-item transaksi) === */
.item-table th { background: #f8fafc; }
.item-table .row-remove { color: var(--admin-danger); cursor: pointer; }

/* === Print-friendly === */
@media print {
    .sidebar, .topbar, .page-heading-action, .btn, .notification-toggle { display: none !important; }
    .admin-layout { display: block; }
    .main-area { width: 100%; }
    .panel { box-shadow: none; border: 0; }
}

/* === Responsive === */
@media (max-width: 991.98px) {
    .admin-layout { display: block; }
    .sidebar { width: 100%; flex-basis: auto; min-height: auto; position: static; padding: 16px; }
    .sidebar.is-collapsed { width: 100%; flex-basis: auto; padding: 16px; }
    .sidebar.is-collapsed .brand-box { justify-content: space-between; }
    .sidebar.is-collapsed .brand-text,
    .sidebar.is-collapsed .sidebar-link span,
    .sidebar.is-collapsed .sidebar-footer,
    .sidebar.is-collapsed .menu-label { width: auto; height: auto; opacity: 1; overflow: visible; color: inherit; white-space: normal; border-top: 0; }
    .sidebar.is-collapsed .sidebar-link { justify-content: flex-start; gap: 11px; padding: 10px 12px; }
    .topbar-sidebar-toggle { display: none; }
    .sidebar-menu-wrap { display: none; padding-top: 16px; }
    .sidebar-menu-wrap.show { display: block; }
    .brand-box { padding-bottom: 0; border-bottom: 0; }
    .mobile-menu-button { display: inline-flex; }
    .topbar { padding: 10px 20px; }
    .content-area { padding: 24px 20px; }
    .page-heading { flex-direction: column; align-items: stretch; }
    .page-heading-action { justify-content: flex-start; }
    .user-menu-toggle { max-width: 220px; }
    .performance-chart-row { grid-template-columns: 1fr; gap: 6px; }
    .performance-chart-value { min-width: 0; text-align: left; }
}

/* Utility */
.text-truncate-2 {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}
.cursor-pointer { cursor: pointer; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }
