/* =====================
   THEME VARIABLES
===================== */
:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --surface: #ffffff;
  --bg: #f4f6fb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;

  --pending-bg: #fff3cd;
  --pending-text: #856404;
  --approved-bg: #d4edda;
  --approved-text: #155724;
  --rejected-bg: #f8d7da;
  --rejected-text: #721c24;
}

/* =====================
   BASE
===================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 8px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h2,
h3 {
  margin: 0 0 10px 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* =====================
   BUTTONS
===================== */
button {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Small button for table actions */
td button,
.btn-xs {
  padding: 4px 8px !important;
  font-size: 10px !important;
  border-radius: 4px !important;
  height: auto !important;
  line-height: 1 !important;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-600);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
}

/* =====================
   FORM
===================== */
.form-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  width: 100%;
}

.pr-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}

.pr-form input,
.pr-form textarea,
.pr-form select {
  width: 100%;
  padding: 7px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.pr-form input:focus,
.pr-form textarea:focus,
.pr-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

.form-grid .full {
  grid-column: span 2;
}

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}

/* =====================
   TABLE & PAGINATION
===================== */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  width: 100% !important;
  max-width: 100vw;
  margin: 0 auto;
}

table {
  border-collapse: collapse;
  width: 100% !important;
  /* Fill container width */
  min-width: 100%;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  /* Matched with info text */
  color: #1f2937;
  line-height: 1.5;
}

th,
td {
  padding: 5px 8px;
  /* Slightly more breathable but still compact */
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  /* No wrapping */
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

th {
  background: #f9fafb;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #111827;
  position: sticky;
  top: 0;
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

tbody tr:hover {
  background: #f9fafb;
}

.truncate {
  max-width: 150px;
  /* Limit width for long text columns */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.pagination-btn {
  border: 1px solid var(--border);
  background: #f9fafb;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  margin: 0 1px;
}

.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* =====================
   STATUS BADGE
===================== */
.status {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.status.pending {
  background: var(--pending-bg);
  color: var(--pending-text);
}

.status.approved {
  background: var(--approved-bg);
  color: var(--approved-text);
}

.status.rejected {
  background: var(--rejected-bg);
  color: var(--rejected-text);
}

.status.done {
  background: #e0f2fe;
  color: #0369a1;
}

/* =====================
   TOAST
===================== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #16a34a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(-5px);
  transition: all .25s ease;
  z-index: 9999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =====================
   RESPONSIVE
===================== */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-grid .full {
    grid-column: span 1 !important;
  }

  .head-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .head-actions {
    width: 100%;
    align-items: flex-start;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .table-bottom {
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
  }

  .modal-content {
    margin: 10px;
    padding: 12px;
  }

  /* User Info Box (the one from auth.js) */
  #user-info-box {
    position: static !important;
    margin-top: 20px;
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .stat-card {
    padding: 20px !important;
  }
}

/* =====================
   MODAL
===================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 10px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #fff;
  width: 100%;
  max-width: 900px;
  max-height: 95vh;
  overflow-y: auto;
  border-radius: 10px;
  padding: 16px;
  animation: scaleIn .2s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-close {
  background: transparent;
  font-size: 22px;
  border: none;
  cursor: pointer;
}

@keyframes scaleIn {
  from {
    transform: scale(.95);
    opacity: 0
  }

  to {
    transform: scale(1);
    opacity: 1
  }
}

/* =====================
   DASHBOARD
===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  width: 100%;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, .08);
}

.card-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 13px;
  color: var(--muted);
}

/* =====================
   UTILITAS BARU (dipakai sekarang)
===================== */
.head-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.head-bar h2 {
  margin: 0;
  font-size: 1.5rem;
}

.head-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.head-actions .btn-link,
.head-actions button {
  white-space: nowrap;
  height: 32px;
  line-height: 32px;
  padding: 0 12px;
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  font-size: 13px;
}

.filter-bar select,
.filter-bar input {
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.table-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  /* Dipersempit */
  padding: 5px 0;
  /* Diperkecil */
  width: 100%;
}

#infoText {
  color: var(--muted);
  font-size: 13px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
}

#pagination {
  display: flex;
  gap: 4px;
}

/* ===== ukuran huruf lebih kecil & rapat ===== */
body {
  font-size: 12.5px;
  /* tengah antara 12 & 13 */
  line-height: 1.4;
}

button,
input,
select,
.btn-link {
  font-size: 12px;
}

.table-top,
.table-bottom {
  font-size: 12px;
}

/* =====================
   USER FLOATER
===================== */
.user-floater {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: white;
  padding: 12px 20px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #e5e7eb;
}

.user-avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #a8e6d8, #7ddcd0);
  color: #0d5046;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-meta {
  text-align: left;
}

.user-id {
  font-weight: 700;
  color: #1f2937;
}

.user-tag {
  font-size: 0.75rem;
  color: #065f46;
  font-weight: 700;
}

.nav-logout {
  background: #f5bfbf;
  color: #7f1d1d;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
}

/* =====================
   GLOBAL LOADER
===================== */
#globalLoading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-box {
  background: white;
  padding: 20px 28px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,.15);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
