/* ================================================================
   ORS – style.css | PT MBK Ventura
   Design system – responsive, mobile-first
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --primary:        #1d4ed8;
  --primary-dark:   #1e40af;
  --primary-light:  #eff6ff;
  --secondary:      #0f172a;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #0891b2;
  --info-light:     #e0f2fe;
  --purple:         #7c3aed;
  --purple-light:   #ede9fe;

  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-dark:    #cbd5e1;

  --text:           #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --sidebar-w:      260px;
  --topbar-h:       56px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:      0 4px 16px rgba(0,0,0,.12);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.logo-title  { color: #fff; font-weight: 800; font-size: 1rem; display: block; }
.logo-sub    { color: #94a3b8; font-size: .65rem; display: block; }

.sidebar-user {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-name   { color: #f1f5f9; font-weight: 700; font-size: .82rem; }
.user-role   { color: #94a3b8; font-size: .7rem; margin-top: .15rem; }
.user-branch { color: #64748b; font-size: .68rem; margin-top: .15rem; }

.nav-section { padding: .5rem 0; flex: 1; }
.nav-section-label {
  padding: .5rem 1rem .25rem;
  font-size: .62rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1rem;
  color: #94a3b8;
  font-size: .78rem;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { color: #f1f5f9; background: rgba(255,255,255,.05); text-decoration: none; }
.nav-item.active { color: #fff; background: rgba(29,78,216,.3); border-left-color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 199; }
.sidebar-overlay.show { display: block; }

/* ── Main area ──────────────────────────────────────────────────── */
#main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.btn-menu-toggle { display: none; font-size: 1.3rem; background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: .25rem; }
.topbar-title  { font-weight: 700; font-size: .9rem; }
.topbar-breadcrumb { font-size: .78rem; color: var(--text-muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

/* ── Page content ───────────────────────────────────────────────── */
#page-content { padding: 1.25rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-weight: 700; font-size: .9rem; }
.card-body  { padding: 1.25rem; }

/* ── Stats grid ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex; align-items: center; gap: .875rem;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.green  { background: var(--success-light); }
.stat-icon.red    { background: var(--danger-light); }
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.purple { background: var(--purple-light); }
.stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-sub   { font-size: .68rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem;
  font-size: .78rem; font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-success   { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-danger    { background: var(--danger);   color: #fff; border-color: var(--danger); }
.btn-warning   { background: var(--warning);  color: #fff; border-color: var(--warning); }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-sm        { padding: .3rem .65rem; font-size: .72rem; }
.btn-lg        { padding: .6rem 1.2rem; font-size: .85rem; }
.w-full        { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: .875rem; }
.form-group label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .3rem; }
.req { color: var(--danger); }

input[type="text"], input[type="number"], input[type="date"], input[type="month"],
input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  padding: .45rem .65rem;
  font-size: .82rem;
  border: 1.5px solid var(--border-dark);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
input[readonly], .auto-filled { background: #f0f9ff; color: #0369a1; font-weight: 600; }
textarea { min-height: 80px; resize: vertical; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.input-group { display: flex; gap: .4rem; }
.input-group input { flex: 1; }

.hint { font-size: .68rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
thead tr { background: var(--surface-2); }
th {
  padding: .6rem .75rem;
  text-align: left;
  font-weight: 700;
  font-size: .72rem;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }

.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.text-muted  { color: var(--text-muted); }
.font-bold   { font-weight: 700; }
.text-mono   { font-family: monospace; font-size: .8rem; }

/* Highlighted rows */
.row-danger  td { background: #fff5f5 !important; }
.row-warning td { background: #fffbeb !important; }
.row-success td { background: #f0fdf4 !important; }
.row-yellow  td { background: #fef9c3 !important; }
.row-red     td { background: #fee2e2 !important; }
.row-holiday td { background: #e0f2fe !important; }

.negative { color: var(--danger); font-weight: 700; }
.positive { color: var(--success); font-weight: 700; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary); }

/* Spreadsheet table */
.spreadsheet-wrapper { overflow: auto; max-height: 70vh; }
.spreadsheet-table th, .spreadsheet-table td { padding: .25rem .35rem; }
.table-input {
  width: 100%; border: 1px solid transparent; background: transparent;
  padding: .2rem .3rem; font-size: .78rem; border-radius: 4px;
}
.table-input:focus { border-color: var(--primary); background: #fff; outline: none; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem;
  font-size: .65rem; font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-primary { background: var(--primary-light); color: #1d4ed8; }
.badge-muted   { background: #f1f5f9; color: #64748b; }
.badge-info    { background: var(--info-light); color: #0c4a6e; }

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-lg   { max-width: 720px; }
.modal-xl   { max-width: 900px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: .9rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); padding: .2rem .4rem; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--danger); }
.modal-body   { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .875rem 1.25rem; border-top: 1px solid var(--border); }

/* ── Toasts ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .4rem;
}
.toast {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1rem; border-radius: 8px;
  font-size: .8rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.success { background: #15803d; color: #fff; }
.toast.error   { background: #dc2626; color: #fff; }
.toast.warning { background: #d97706; color: #fff; }
.toast.info    { background: #0f172a; color: #fff; }
@keyframes toastIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ── Misc ───────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.mb-2    { margin-bottom: 1.25rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.approval-flow {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .75rem; background: var(--surface-2); border-radius: 8px;
}
.approval-step { display: flex; align-items: center; gap: .35rem; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800;
}
.step-dot.current { background: var(--primary); color: #fff; }
.step-dot.done    { background: var(--success); color: #fff; }
.step-dot.pending { background: var(--border-dark); color: var(--text-muted); }
.step-label  { font-size: .72rem; color: var(--text-secondary); }
.approval-arrow { color: var(--text-muted); font-size: .8rem; }

/* ideb results */
.ideb-ok     { background: var(--success-light); color: var(--success); font-weight: 700; padding: .15rem .4rem; border-radius: 4px; }
.ideb-tolak  { background: var(--danger-light);  color: var(--danger);  font-weight: 700; padding: .15rem .4rem; border-radius: 4px; }
.ideb-fill   { background: var(--warning-light); color: var(--warning); font-weight: 700; padding: .15rem .4rem; border-radius: 4px; }

/* SLA colors */
.sla-yellow { background: #fef08a; }
.sla-red    { background: #fca5a5; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  .btn-menu-toggle { display: flex; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  #topbar { padding: 0 .75rem; }
  #page-content { padding: .75rem; }
  .modal { max-width: 100%; margin: .5rem; max-height: 95vh; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .modal-lg, .modal-xl { max-width: 100%; }
}

@media print {
  #sidebar, #topbar, .btn, .modal-overlay { display: none !important; }
  #main { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}