/*
 * Modern UI layer — Sistem Informasi Persediaan Barang Gudang
 * Loaded after the legacy Atlantis theme so the existing PHP modules remain compatible.
 */
:root {
  --ui-primary: #3156d3;
  --ui-primary-dark: #203a99;
  --ui-secondary: #6574cd;
  --ui-accent: #20b486;
  --ui-warning: #f4b740;
  --ui-danger: #e45858;
  --ui-ink: #17213b;
  --ui-muted: #71809b;
  --ui-bg: #f5f7fb;
  --ui-card: #ffffff;
  --ui-border: #e8edf5;
  --ui-shadow: 0 12px 36px rgba(31, 48, 85, 0.08);
  --ui-radius: 18px;
  --ui-radius-sm: 12px;
}

html { scroll-behavior: smooth; }
body {
  overflow-x: hidden;
  background: var(--ui-bg);
  color: var(--ui-ink);
  font-family: Lato, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a, input, select, textarea { touch-action: manipulation; }
a { color: var(--ui-primary); }
a:hover { color: var(--ui-primary-dark); }
:focus-visible { outline: 3px solid rgba(49, 86, 211, .32); outline-offset: 2px; }

/* App shell */
.main-header { box-shadow: 0 4px 18px rgba(24, 39, 75, .08); z-index: 1030; }
.logo-header { min-height: 72px; display: flex; align-items: center; padding: 0 22px; }
.logo-header .logo { display: inline-flex; align-items: center; min-width: 0; }
.logo-header .navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 18px; white-space: nowrap; }
.logo-header .navbar-brand i { font-size: 22px; }
.brand-short { display: none; }
.navbar-header { min-height: 72px; }
.navbar-header .container-fluid { padding-left: 24px; padding-right: 24px; }
.app-topbar-title { color: rgba(255,255,255,.86); font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.avatar-sm-top { width: 40px; height: 40px; }
.avatar-sm-top .avatar-title { font-size: 14px; }
.dropdown-user { border: 0; border-radius: var(--ui-radius-sm); box-shadow: var(--ui-shadow); overflow: hidden; }
.dropdown-user .user-box { padding: 18px; background: linear-gradient(135deg, #f7f9ff, #eef2ff); }
.dropdown-user .u-text h4 { font-size: 15px; font-weight: 800; color: var(--ui-ink); }
.dropdown-user .dropdown-item { padding: 11px 18px; font-size: 13px; }

.sidebar { box-shadow: 8px 0 30px rgba(31, 48, 85, .04); }
.sidebar .sidebar-wrapper { padding-top: 12px; }
.sidebar .user { margin: 0 16px 16px; padding: 16px; border-radius: var(--ui-radius-sm); background: linear-gradient(135deg, rgba(49,86,211,.13), rgba(101,116,205,.08)); }
.sidebar .user .info a { color: var(--ui-ink); }
.sidebar .user-level { color: var(--ui-muted); font-weight: 600; }
.nav-secondary > .nav-section { margin-top: 18px; }
.nav-secondary .text-section { color: #9aa6bd; font-size: 10px; letter-spacing: .13em; font-weight: 800; }
.nav-secondary .nav-item > a { min-height: 46px; margin: 3px 12px; padding: 11px 14px; border-radius: 12px; color: #64718b; transition: background .2s ease, color .2s ease, transform .2s ease; }
.nav-secondary .nav-item > a i { width: 22px; font-size: 15px; }
.nav-secondary .nav-item > a p { font-size: 13px; font-weight: 700; }
.nav-secondary .nav-item:not(.active) > a:hover { background: #f0f3fb; color: var(--ui-primary); transform: translateX(2px); }
.nav-secondary .nav-item.active > a { background: linear-gradient(135deg, var(--ui-primary), var(--ui-secondary)); color: #fff; box-shadow: 0 8px 18px rgba(49,86,211,.22); }
.nav-secondary .nav-collapse { margin: 0 12px 6px 47px; padding: 4px 0 4px 14px; border-left: 1px solid #e2e8f3; }
.nav-secondary .nav-collapse li a { min-height: 34px; padding: 7px 10px; border-radius: 8px; color: #78859d; font-size: 12px; font-weight: 600; }
.nav-secondary .nav-collapse li.active a, .nav-secondary .nav-collapse li a:hover { background: #edf1ff; color: var(--ui-primary); }
.nav-secondary .nav-collapse .sub-item { margin-left: 0; }

.main-panel { background: var(--ui-bg); min-height: calc(100vh - 72px); }
.content { padding: 0 0 30px; }
.page-inner { max-width: 1440px; margin: 0 auto; }
.panel-header { position: relative; overflow: hidden; }
.panel-header:after { content: ""; position: absolute; width: 320px; height: 320px; right: -100px; top: -170px; border-radius: 50%; background: rgba(255,255,255,.08); pointer-events: none; }
.panel-header .page-inner { position: relative; z-index: 1; }
.panel-header .page-title { font-size: clamp(22px, 2.5vw, 30px); font-weight: 800; letter-spacing: -.025em; }
.panel-header .page-inner { padding-top: 38px !important; padding-bottom: 90px !important; }
.page-inner.mt--5 { margin-top: -54px !important; position: relative; z-index: 2; }

.card { border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow); background: var(--ui-card); overflow: hidden; }
.card .card-header { background: transparent; border-bottom: 1px solid var(--ui-border); padding: 20px 24px 14px; }
.card .card-title { color: var(--ui-ink); font-size: 16px; font-weight: 800; line-height: 1.35; }
.card .card-body { padding: 22px 24px; }
.card-stats { transition: transform .2s ease, box-shadow .2s ease; }
.card-stats:hover { transform: translateY(-3px); box-shadow: 0 18px 38px rgba(31, 48, 85, .12); }
.card-stats .card-category { color: var(--ui-muted); font-weight: 700; font-size: 12px; }
.card-stats .card-title { font-size: 28px; margin-top: 5px; }
.icon-big2, .icon-big { border-radius: 14px; }
.row-card-no-pd { margin-left: -8px; margin-right: -8px; }
.row-card-no-pd > [class*="col-"] { padding-left: 8px; padding-right: 8px; }

/* Forms and actions */
.form-group label, .form-group .control-label { color: #53617a; font-size: 12px; font-weight: 800; }
.form-control, .custom-select, .chosen-container-single .chosen-single { min-height: 44px; border: 1px solid #dfe6f1; border-radius: 10px; color: var(--ui-ink); background-color: #fbfcfe; box-shadow: none; }
.form-control { padding: 10px 13px; }
.form-control:focus, .custom-select:focus { border-color: var(--ui-primary); box-shadow: 0 0 0 4px rgba(49,86,211,.1); background: #fff; }
textarea.form-control { min-height: 96px; }
.chosen-container { width: 100% !important; }
.chosen-container-single .chosen-single { height: 44px; padding: 11px 13px; line-height: 20px; }
.chosen-container-active.chosen-with-drop .chosen-single, .chosen-container-active .chosen-single { border-color: var(--ui-primary); box-shadow: 0 0 0 4px rgba(49,86,211,.1); }
.btn { min-height: 42px; border-radius: 10px; padding: 10px 17px; font-size: 12px; font-weight: 800; letter-spacing: .01em; transition: transform .2s ease, box-shadow .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary, .btn-secondary { background: linear-gradient(135deg, var(--ui-primary), var(--ui-secondary)); border-color: var(--ui-primary); box-shadow: 0 8px 16px rgba(49,86,211,.18); }
.btn-success { box-shadow: 0 8px 16px rgba(32,180,134,.18); }
.btn-danger { box-shadow: 0 8px 16px rgba(228,88,88,.16); }
.btn-default { border: 1px solid #dfe6f1; background: #fff; color: #64718b; }
.btn-round { border-radius: 999px; }
.form-action, .form-button, .table-action { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.alert { border: 0; border-radius: 12px; box-shadow: 0 8px 24px rgba(31,48,85,.07); }
.badge { border-radius: 999px; padding: 6px 9px; font-weight: 800; }

/* Data tables remain usable for wide warehouse data on small screens. */
.table-responsive { border: 1px solid var(--ui-border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.table { margin-bottom: 0; color: #4c5b75; }
.table thead th { background: #f7f9fd; color: #65728b; border-top: 0; border-bottom: 1px solid var(--ui-border); font-size: 11px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.table td { border-color: #edf1f6; vertical-align: middle; font-size: 12px; }
.table-hover tbody tr:hover { background: #f8faff; }
.dataTables_wrapper { padding: 0; }
.report-page > .card + .card { margin-top: 18px; }
.report-page .table-responsive { overflow-x: auto; }
.report-page .dataTables_scrollBody { overflow-x: auto !important; }
.empty-report-state { margin-top: 12px; padding: 14px; border-radius: 10px; color: var(--ui-muted); background: #f7f9fd; text-align: center; font-size: 12px; }

.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select { border: 1px solid #dfe6f1; border-radius: 8px; min-height: 36px; padding: 6px 10px; }
.dataTables_wrapper .dataTables_filter input:focus { outline: none; border-color: var(--ui-primary); box-shadow: 0 0 0 3px rgba(49,86,211,.1); }
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { color: var(--ui-muted); font-size: 11px; font-weight: 700; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 8px !important; border: 0 !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--ui-primary) !important; color: #fff !important; }

.footer { background: transparent; border-top: 1px solid var(--ui-border); padding: 18px 24px; }
.footer .copyright { color: var(--ui-muted); font-size: 11px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 2000; padding: 10px 14px; color: #fff; background: var(--ui-primary); border-radius: 8px; transition: top .2s ease; }
.skip-link:focus { top: 12px; }

@media (max-width: 991.98px) {
  .logo-header { padding: 0 15px; }
  .navbar-header .container-fluid { padding-left: 15px; padding-right: 15px; }
  .content { padding-bottom: 18px; }
  .page-inner { padding-left: 15px !important; padding-right: 15px !important; }
  .panel-header .page-inner { padding-top: 30px !important; padding-bottom: 75px !important; }
  .card .card-header { padding: 17px 18px 13px; }
  .card .card-body { padding: 18px; }
}

@media (max-width: 767.98px) {
  .main-header { position: sticky; top: 0; }
  .report-page .card-header .card-title { overflow-wrap: anywhere; }
  .report-page .row > [class*="col-"] { margin-bottom: 10px; }
  .report-page .row > [class*="col-"]:last-child { margin-bottom: 0; }
  .report-page .btn { width: 100%; }

  .navbar-header { display: none; }
  .logo-header { min-height: 62px; }
  .logo-header .navbar-brand { font-size: 16px; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .topbar-toggler { display: none !important; }
  .nav-toggle { display: none !important; }
  .sidenav-toggler { display: inline-flex !important; margin-left: auto; color: #fff; }
  .sidebar { transform: translate3d(-100%, 0, 0); transition: transform .25s ease; z-index: 1040; width: 280px; top: 62px; height: calc(100vh - 62px); }
  body.sidebar-open .sidebar { transform: translate3d(0, 0, 0); }
  body.sidebar-open:after { content: ""; position: fixed; inset: 62px 0 0; background: rgba(15, 27, 57, .48); z-index: 1035; }
  .main-panel { width: 100%; min-height: calc(100vh - 62px); }
  .page-inner.mt--5 { margin-top: -40px !important; }
  .panel-header .page-inner { padding-bottom: 65px !important; }
  .panel-header .page-title { font-size: 22px; }
  .row-card-no-pd { margin-left: -5px; margin-right: -5px; }
  .row-card-no-pd > [class*="col-"] { padding-left: 5px; padding-right: 5px; }
  .card-stats { margin-bottom: 10px; }
  .card-stats .card-title { font-size: 24px; }
  .card .card-body { padding: 15px; }
  .form-action, .form-button, .table-action { width: 100%; }
  .form-action .btn, .form-button .btn, .table-action .btn { flex: 1 1 auto; }
  .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { float: none; text-align: left; margin-bottom: 10px; }
  .dataTables_wrapper .dataTables_filter input { width: min(100%, 220px); margin-left: 0; }
  .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { float: none; text-align: left; margin-top: 10px; }
  .footer { padding: 15px; }
  .footer .copyright { text-align: center; margin: 0 !important; }
}

.opname-filter { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.opname-filter .form-group { min-width: 190px; }
.opname-table .form-control { min-width: 105px; }
.opname-difference { min-width: 64px; font-weight: 800; }
.import-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 190px; padding: 22px; border: 2px dashed #d8e0f0; border-radius: 16px; background: #f8faff; text-align: center; }
.import-dropzone > i { color: #31a36f; font-size: 42px; }
.import-dropzone label { margin: 0; color: var(--ui-primary); font-size: 15px; font-weight: 800; cursor: pointer; }
.import-dropzone input { max-width: 100%; font-size: 12px; }
.import-dropzone small { color: var(--ui-muted); }
.import-help-card { height: 100%; background: linear-gradient(145deg, #fff, #f6f8ff); }
.role-permissions-title { margin: 22px 0 10px; color: var(--ui-ink); font-size: 13px; font-weight: 800; }
.role-permission-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 280px; overflow-y: auto; padding: 4px; }
.role-permission-item { display: flex; align-items: flex-start; gap: 9px; margin: 0; padding: 10px; border: 1px solid var(--ui-border); border-radius: 10px; background: #fbfcff; cursor: pointer; }
.role-permission-item input { margin-top: 3px; accent-color: var(--ui-primary); }
.role-permission-item strong, .role-permission-item small { display: block; }
.role-permission-item strong { color: var(--ui-ink); font-size: 11px; }
.role-permission-item small { margin-top: 3px; color: var(--ui-muted); font-size: 10px; }

.profile-upload-layout { display: flex; align-items: center; gap: 24px; }
.profile-avatar-preview { flex: 0 0 auto; }
.profile-avatar-xl { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; border: 5px solid #eef2ff; box-shadow: 0 12px 28px rgba(49,86,211,.16); background: #f3f6fb; }
.profile-upload-copy { min-width: 0; }
.profile-upload-copy h5 { color: var(--ui-ink); font-size: 18px; font-weight: 800; }
.profile-upload-copy .small { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.profile-file-input:focus + .invalid-feedback { outline: 2px solid var(--ui-primary); }
.profile-form-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--ui-border); padding-top: 18px; }
.profile-help-card { height: calc(100% - 0px); background: linear-gradient(145deg, #fff, #f6f8ff); }
.profile-help-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 16px; border-radius: 13px; color: var(--ui-primary); background: #eaf0ff; font-size: 18px; }
.profile-help-card h5 { color: var(--ui-ink); font-weight: 800; }
.profile-help-card p { font-size: 13px; line-height: 1.7; }
@media (max-width: 767.98px) {
  .opname-filter .form-group { flex: 1 1 100%; }
  .opname-filter .btn { flex: 1 1 auto; }
  .role-permission-list { grid-template-columns: 1fr; }
  .profile-upload-layout { align-items: flex-start; gap: 16px; }
  .profile-avatar-xl { width: 94px; height: 94px; }
  .profile-upload-copy h5 { font-size: 16px; }
  .profile-form-actions .btn { flex: 1 1 100%; }
  .profile-help-card { margin-top: 12px; }
}
@media (max-width: 420px) {
  .panel-header .page-title { font-size: 20px; }
  .card .card-title { font-size: 14px; }
  .btn { padding-left: 13px; padding-right: 13px; }
  .form-action .btn, .form-button .btn, .table-action .btn { width: 100%; flex-basis: 100%; }
  .modal-dialog { margin: 12px; }
}

/* Gudang Assistant */
.ai-assistant-card { overflow: hidden; border: 1px solid #e5e9f2; }
.ai-assistant-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ai-status-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #31a36f; box-shadow: 0 0 0 5px rgba(49,163,111,.12); }
.ai-assistant-messages { display: flex; flex-direction: column; gap: 12px; max-height: 330px; overflow-y: auto; padding: 4px 2px 14px; scroll-behavior: smooth; }
.ai-message { display: flex; align-items: flex-end; gap: 9px; max-width: 88%; }
.ai-message-user { align-self: flex-end; justify-content: flex-end; }
.ai-message-assistant { align-self: flex-start; }
.ai-message-avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px; color: #3156d3; background: #eaf0ff; font-size: 13px; }
.ai-message-bubble { padding: 10px 13px; border: 1px solid #e3e8f3; border-radius: 14px 14px 14px 4px; color: #27324a; background: #f7f9fd; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-message-user .ai-message-bubble { border-color: #3156d3; border-radius: 14px 14px 4px 14px; color: #fff; background: #3156d3; }
.ai-message-loading .ai-message-bubble { color: #667085; font-style: italic; }
.ai-quick-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin: 3px 0 13px; }
.ai-quick-prompt { border: 1px solid #dfe5ef; border-radius: 999px; color: #3156d3; background: #f8faff; font-size: 11px; }
.ai-assistant-form { display: flex; align-items: flex-end; gap: 9px; }
.ai-assistant-form textarea { min-height: 46px; resize: vertical; }
.ai-assistant-form .ai-send-button { white-space: nowrap; }
@media (max-width: 575.98px) {
  .ai-message { max-width: 96%; }
  .ai-assistant-form { align-items: stretch; flex-direction: column; }
  .ai-assistant-form .ai-send-button { width: 100%; }
}

.dashboard-stat-link { cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.dashboard-stat-link:hover, .dashboard-stat-link:focus-visible { transform: translateY(-3px); box-shadow: 0 18px 38px rgba(31, 48, 85, .14); }
.dashboard-stat-link:focus-visible { outline: 3px solid rgba(49, 86, 211, .32); outline-offset: 3px; }

/* Floating flash notifications */
.alert-notify { position: fixed !important; top: 18px; right: 18px; left: auto; width: min(420px, calc(100vw - 36px)); z-index: 2000; animation: flash-notify-in .22s ease-out; }
@keyframes flash-notify-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 575.98px) { .alert-notify { top: 12px; right: 12px; width: calc(100vw - 24px); } }
