/* ============================================================
   SiPro — Shared Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1a56db;   --primary-h:  #1648c0;   --primary-bg: #eff6ff;
  --success:    #057a55;   --success-h:  #046c4e;   --success-bg: #f0fdf4;
  --danger:     #e02424;   --danger-h:   #c81e1e;   --danger-bg:  #fef2f2;
  --warn:       #b45309;   --warn-bg:    #fffbeb;
  --purple:     #6b21a8;   --purple-bg:  #f3e8ff;
  --text:       #111928;   --muted:      #6b7280;
  --border:     #e5e7eb;   --bg:         #f3f4f6;   --white:      #ffffff;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.07);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.2);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ============================================================
   NAVBAR
   ============================================================ */
nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo { width: 36px; height: 36px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.nav-logo.purple { background: var(--purple); }
.nav-logo svg { width: 20px; height: 20px; fill: white; }
.nav-brand span { font-size: 1rem; font-weight: 700; }
.nav-brand small { font-size: .75rem; color: var(--muted); display: block; }
.nav-right { display: flex; align-items: center; gap: 10px; }

.role-chip {
  background: #fef3c7; color: #92400e; border-radius: 20px;
  padding: .3rem .85rem; font-size: .8rem; font-weight: 700;
}
.role-chip.manager { background: var(--primary-bg); color: var(--primary); }
.role-chip.pembelian { background: var(--purple-bg); color: var(--purple); }
.user-chip {
  background: var(--bg); border-radius: 20px;
  padding: .3rem .85rem; font-size: .82rem; font-weight: 600;
}

.btn-logout {
  background: none; border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: .3rem .75rem; font-size: .82rem; color: var(--muted); cursor: pointer;
  transition: all .2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ============================================================
   LAYOUT
   ============================================================ */
main { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--white); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.card-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem;
  padding-bottom: .75rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.card-title svg { width: 18px; height: 18px; color: var(--primary); }
.card-body { padding: 1.5rem; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab {
  padding: .45rem 1.1rem; border-radius: 20px; font-size: .85rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border); background: var(--white);
  color: var(--muted); transition: all .2s;
}
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.tab.purple.active { background: var(--purple); border-color: var(--purple); }

/* ============================================================
   STATS
   ============================================================ */
.stats-bar { display: flex; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.stat-card {
  background: var(--white); border-radius: 12px; padding: .9rem 1.25rem;
  flex: 1; min-width: 110px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .num { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-card .lbl { font-size: .78rem; color: var(--muted); }
.stat-card.pending  .num { color: #92400e; }
.stat-card.approved .num { color: var(--success); }
.stat-card.rejected .num { color: var(--danger); }
.stat-card.all      .num { color: var(--primary); }
.stat-card.ready    .num { color: var(--primary); }
.stat-card.process  .num { color: var(--purple); }
.stat-card.done     .num { color: var(--success); }
.stat-card.synced   .num { color: #16a34a; }

/* ============================================================
   TOOLBAR & SEARCH
   ============================================================ */
.toolbar { display: flex; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.search-box { flex: 1; min-width: 200px; position: relative; }
.search-box input {
  width: 100%; padding: .6rem .9rem .6rem 2.4rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box svg {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}

.filter-btn {
  padding: .55rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); font-size: .85rem; cursor: pointer; color: var(--muted);
  transition: all .2s; white-space: nowrap;
}
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th {
  background: var(--bg); padding: .65rem .9rem; text-align: left; font-weight: 600;
  color: var(--muted); font-size: .78rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ============================================================
   BADGE
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: .25rem .7rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700; white-space: nowrap;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-approved1 { background: #dbeafe; color: #1e40af; }
.badge-approved2 { background: var(--success-bg); color: var(--success); }
.badge-rejected  { background: var(--danger-bg); color: var(--danger); }
.badge-purchased { background: var(--purple-bg); color: var(--purple); }
.badge-received  { background: #dcfce7; color: #14532d; }
.badge-synced    { background: #dcfce7; color: #14532d; font-size: .7rem; }
.badge-unsynced  { background: #fef3c7; color: #92400e; font-size: .7rem; }

.pr-low    { color: #16a34a; font-weight: 700; font-size: .82rem; }
.pr-medium { color: #2563eb; font-weight: 700; font-size: .82rem; }
.pr-high   { color: #d97706; font-weight: 700; font-size: .82rem; }
.pr-urgent { color: #dc2626; font-weight: 700; font-size: .82rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary, .btn-success, .btn-danger, .btn-purple, .btn-secondary, .btn-approve, .btn-reject, .btn-detail, .btn-proses, .btn-terima, .btn-sheets, .btn-cancel, .btn-loadmore {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius); font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .2s; border: none;
}
.btn-primary:disabled, .btn-success:disabled, .btn-danger:disabled, .btn-purple:disabled {
  opacity: .6; cursor: not-allowed;
}

.btn-primary  { padding: .65rem 1.5rem; background: var(--primary); color: white; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-success  { padding: .65rem 1.5rem; background: var(--success); color: white; }
.btn-success:hover  { background: var(--success-h); }
.btn-danger   { padding: .65rem 1.5rem; background: var(--danger); color: white; }
.btn-danger:hover   { background: var(--danger-h); }
.btn-purple   { padding: .65rem 1.5rem; background: var(--purple); color: white; }
.btn-purple:hover   { background: #5b21b6; }
.btn-secondary{ padding: .65rem 1.25rem; background: var(--white); color: var(--muted); border: 1.5px solid var(--border); }
.btn-secondary:hover{ border-color: #9ca3af; color: var(--text); }

.btn-approve  { padding: .38rem .85rem; background: var(--success); color: white; border: none; border-radius: 6px; font-size: .8rem; }
.btn-approve:hover { background: var(--success-h); }
.btn-reject   { padding: .38rem .85rem; background: var(--white); color: var(--danger); border: 1.5px solid var(--danger); border-radius: 6px; font-size: .8rem; }
.btn-reject:hover  { background: var(--danger); color: white; }
.btn-detail   { padding: .38rem .75rem; background: var(--bg); color: var(--muted); border: 1.5px solid var(--border); border-radius: 6px; font-size: .8rem; }
.btn-detail:hover  { border-color: var(--primary); color: var(--primary); }
.btn-proses   { padding: .38rem .85rem; background: var(--purple); color: white; border: none; border-radius: 6px; font-size: .8rem; }
.btn-proses:hover  { background: #5b21b6; }
.btn-terima   { padding: .38rem .85rem; background: var(--success); color: white; border: none; border-radius: 6px; font-size: .8rem; }
.btn-terima:hover  { background: var(--success-h); }
.btn-sheets   { padding: .55rem 1.1rem; background: #16a34a; color: white; border: none; font-size: .85rem; }
.btn-sheets:hover  { background: #15803d; }
.btn-sheets:disabled { opacity: .6; cursor: not-allowed; }
.btn-loadmore { padding: .65rem 1.5rem; background: var(--white); color: var(--primary); border: 1.5px solid var(--primary); margin: 1.5rem auto 0; display: flex; }
.btn-loadmore:hover { background: var(--primary-bg); }

.btn-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================================
   FORM
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.form-grid .full, .form-grid-2 .full { grid-column: 1 / -1; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }

.field label { display: block; font-size: .825rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field label .hint { font-weight: 400; color: var(--muted); font-size: .78rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .65rem .85rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .9rem; color: var(--text);
  font-family: inherit; outline: none; transition: border-color .2s, box-shadow .2s; background: var(--white);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.field input:disabled, .field select:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.field textarea { resize: vertical; min-height: 80px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 640px; max-height: 92vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-head h3 { font-size: 1.05rem; font-weight: 700; }
.btn-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.btn-close:hover { color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; margin-top: 1.1rem; justify-content: flex-end; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin-bottom: 1.25rem; }
.detail-item { display: flex; flex-direction: column; gap: 3px; }
.detail-item .lbl { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.detail-item .val { font-size: .9rem; color: var(--text); font-weight: 500; }
.detail-item.full { grid-column: 1 / -1; }

.section-box { background: var(--bg); border-radius: 10px; padding: 1.1rem; margin-top: 1rem; }
.section-box h4 { font-size: .9rem; font-weight: 700; margin-bottom: 1rem; }
.penerimaan-form { background: var(--success-bg); border: 1px solid #bbf7d0; border-radius: 10px; padding: 1.1rem; margin-top: 1rem; }
.penerimaan-form h4 { font-size: .9rem; font-weight: 700; color: var(--success); margin-bottom: 1rem; }
.approval-section { background: var(--bg); border-radius: 10px; padding: 1.1rem; margin-top: 1rem; }
.approval-section h4 { font-size: .9rem; font-weight: 700; margin-bottom: .85rem; }
.approval-section textarea {
  width: 100%; padding: .65rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; font-family: inherit; resize: vertical; min-height: 70px; outline: none; transition: border-color .2s;
}
.approval-section textarea:focus { border-color: var(--primary); }

/* ============================================================
   HISTORY LOG
   ============================================================ */
.history-log { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.history-log h4 { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: .75rem; }
.log-item { display: flex; gap: 10px; margin-bottom: .65rem; font-size: .83rem; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 5px; }
.log-dot.green  { background: var(--success); }
.log-dot.red    { background: var(--danger); }
.log-dot.yellow { background: #d97706; }
.log-dot.purple { background: var(--purple); }
.log-content { line-height: 1.5; color: var(--muted); }
.log-content strong { color: var(--text); }

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1f2937; color: white; padding: .85rem 1.5rem;
  border-radius: 10px; font-size: .9rem; font-weight: 500;
  opacity: 0; transition: all .35s; z-index: 999; white-space: nowrap; display: flex; align-items: center; gap: 10px;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: white;
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state svg { width: 52px; height: 52px; margin-bottom: 1rem; opacity: .35; }
.empty-state p { font-size: .9rem; }

/* ============================================================
   INFO ROW
   ============================================================ */
.info-row {
  display: flex; gap: 1rem; flex-wrap: wrap;
  background: var(--primary-bg); border-radius: var(--radius);
  padding: .85rem 1rem; margin-bottom: 1.25rem; font-size: .85rem;
}
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item span:first-child { color: var(--muted); font-size: .78rem; }
.info-item span:last-child { font-weight: 600; color: var(--text); }

/* ============================================================
   PRIORITY PILLS
   ============================================================ */
.priority-group { display: flex; gap: .6rem; flex-wrap: wrap; }
.priority-option { display: none; }
.priority-label {
  padding: .45rem 1.1rem; border-radius: 20px; border: 1.5px solid var(--border);
  font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .18s; user-select: none;
}
.priority-option:checked + .priority-label { color: white; border-color: transparent; }
#p-low:checked + .priority-label { background: #16a34a; }
#p-medium:checked + .priority-label { background: #2563eb; }
#p-high:checked + .priority-label { background: #d97706; }
#p-urgent:checked + .priority-label { background: #dc2626; }
.priority-label[for="p-low"] { color: #16a34a; }
.priority-label[for="p-medium"] { color: #2563eb; }
.priority-label[for="p-high"] { color: #d97706; }
.priority-label[for="p-urgent"] { color: #dc2626; }

/* ============================================================
   FORM ACTIONS
   ============================================================ */
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.btn-submit {
  padding: .7rem 2rem; background: var(--primary); color: white; border: none;
  border-radius: var(--radius); font-size: .9rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: background .2s, transform .1s;
}
.btn-submit:hover { background: var(--primary-h); }
.btn-submit:active { transform: scale(.98); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; }
.btn-reset {
  padding: .7rem 1.5rem; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--white); font-size: .9rem; font-weight: 600; cursor: pointer;
  color: var(--muted); transition: all .2s;
}
.btn-reset:hover { border-color: #9ca3af; color: var(--text); }

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton { background: linear-gradient(90deg, var(--bg) 25%, #e5e7eb 50%, var(--bg) 75%); background-size: 200% 100%; animation: skeleton 1.2s ease-in-out infinite; border-radius: 6px; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }

/* ============================================================
   OFFLINE INDICATOR
   ============================================================ */
#offline-bar {
  position: fixed; top: 0; left: 0; right: 0; background: #b45309; color: white;
  text-align: center; padding: .4rem; font-size: .82rem; font-weight: 600; z-index: 9999;
  display: none; justify-content: center; align-items: center; gap: 8px;
}
#offline-bar.show { display: flex; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding: 0 1rem 1rem; font-size: .85rem; color: var(--muted); }

/* ============================================================
   NOSCRIPT
   ============================================================ */
.noscript-msg {
  position: fixed; inset: 0; background: var(--bg); z-index: 10000;
  display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center;
}
.noscript-msg .card { padding: 2rem; max-width: 400px; }
.noscript-msg h2 { color: var(--danger); margin-bottom: .5rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .stats-bar { gap: .6rem; }
  .stat-card { min-width: 80px; padding: .7rem 1rem; }
  .form-grid, .form-grid-2, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .full, .form-grid-2 .full, .detail-grid .full { grid-column: 1; }
  .modal-actions, .form-actions { flex-direction: column; }
  .btn-submit, .btn-reset, .btn-primary, .btn-success, .btn-secondary { width: 100%; justify-content: center; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; width: 100%; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  background: var(--white); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem; width: 100%; max-width: 420px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.75rem; }
.login-logo-icon { width: 44px; height: 44px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.login-logo-icon svg { width: 24px; height: 24px; fill: white; }
.login-logo h1 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.login-logo p { font-size: .78rem; color: var(--muted); }

.login-card h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); margin-bottom: .35rem; }
.login-subtitle { font-size: .875rem; color: var(--muted); margin-bottom: 1.75rem; }

.login-label { display: block; font-size: .825rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.login-input {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .925rem; color: var(--text); outline: none; transition: border-color .2s; margin-bottom: 1.1rem;
}
.login-input:focus { border-color: var(--primary); }
.password-wrap { position: relative; }
.password-wrap input { margin-bottom: 0; padding-right: 2.8rem; }
.toggle-pw { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--muted); padding: 0; font-size: 1rem; display: flex; align-items: center; }
.field-gap { margin-bottom: 1.1rem; }

.btn-login {
  width: 100%; padding: .75rem; background: var(--primary); color: white; border: none;
  border-radius: var(--radius); font-size: .975rem; font-weight: 600; cursor: pointer;
  transition: background .2s, transform .1s; margin-top: .25rem;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-login:hover { background: var(--primary-h); }
.btn-login:active { transform: scale(.98); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

.login-alert {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: var(--radius); padding: .65rem .9rem; font-size: .85rem; margin-bottom: 1.1rem; display: none;
}
.login-alert.show { display: block; }

.login-divider { text-align: center; color: var(--muted); font-size: .8rem; margin: 1.5rem 0 1.1rem; position: relative; }
.login-divider::before, .login-divider::after { content: ''; position: absolute; top: 50%; width: 38%; height: 1px; background: var(--border); }
.login-divider::before { left: 0; } .login-divider::after { right: 0; }

.btn-google {
  width: 100%; padding: .7rem; background: white; color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .925rem;
  font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: all .2s;
}
.btn-google:hover { background: var(--bg); border-color: #d1d5db; }
.btn-google svg { width: 20px; height: 20px; }

.login-footer { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 1.75rem; }
