/* ============================================================
   SI-JEMPOL — Komponen Interaktif (Bottom Sheet, Forms, Stepper)
   ============================================================ */

/* Design Tokens Fallbacks */
:root {
  --border-color: #cbd5e1;
  --border-color-light: #f1f5f9;
  --bg-card-subtle: #f8fafc;
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Bottom Sheet Overlay & Modal */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sheet-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card, #ffffff);
  border-radius: 28px 28px 0 0;
  padding: 20px 22px 30px;
  box-shadow: var(--shadow-sheet);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
  box-sizing: border-box;
}

/* Sleek, Non-Breaking Custom Scrollbar (Never cuts into rounded corners) */
.sheet::-webkit-scrollbar {
  width: 6px;
}

.sheet::-webkit-scrollbar-track {
  background: transparent;
  margin: 18px 0;
}

.sheet::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 9999px;
}

.sheet::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}

@keyframes slideUpSheet {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Centered Modal on Tablet and Desktop */
@media (min-width: 768px) {
  .sheet-overlay {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .sheet {
    max-width: 560px;
    border-radius: 24px;
    padding: 26px 30px 28px;
    max-height: 88vh;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .sheet.sheet-wide {
    max-width: 820px;
  }

  .sheet-handle {
    display: none;
  }

  @keyframes modalPopIn {
    from {
      opacity: 0;
      transform: scale(0.95);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
}

/* Modal Close Button */
.btn-sheet-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-card-subtle, #f8fafc);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 20;
  font-size: 13px;
}

.btn-sheet-close:hover {
  background: #e2e8f0;
  color: var(--text-main);
  transform: scale(1.05);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  background: var(--border-color, #cbd5e1);
  border-radius: var(--radius-full);
  margin: 0 auto 16px;
}

.sheet-icon-top {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.sheet-title {
  font-size: 18.5px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.sheet-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

/* Form Controls - Clear, Visible, & Beautiful */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  text-align: left;
}

.form-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border-radius: 12px;
  border: 1.5px solid var(--border-color, #cbd5e1);
  background: var(--bg-card-subtle, #f8fafc);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-main);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: #94a3b8;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary, #1e3a8a);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(30, 58, 138, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  padding-right: 40px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Category Grid in Emergency Sheet */
.emergency-cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.cat-select-btn {
  background: var(--bg-card-subtle, #f8fafc);
  border: 1.5px solid var(--border-color, #cbd5e1);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.cat-select-btn:hover {
  border-color: var(--accent-red);
  background: #fef2f2;
  transform: translateY(-2px);
}

.cat-select-btn i {
  font-size: 22px;
  color: var(--accent-red);
}

/* Location Preview Box */
.location-detected-box {
  background: var(--bg-card-subtle, #f8fafc);
  border: 1.5px solid var(--border-color, #cbd5e1);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-main);
}

.location-detected-box i {
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

/* Sheet Buttons */
.sheet-btn {
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.sheet-btn:hover {
  transform: translateY(-1px);
}

.sheet-btn:active {
  transform: translateY(0);
}

.sheet-btn.primary {
  background: var(--primary, #1e3a8a);
  color: #fff;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.25);
}

.sheet-btn.primary:hover {
  background: var(--primary-hover, #172554);
}

.sheet-btn.danger {
  background: var(--accent-red, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.sheet-btn.danger:hover {
  background: #b91c1c;
}

.sheet-btn.ghost {
  background: transparent;
  color: var(--text-muted, #64748b);
  border: 1.5px solid var(--border-color, #cbd5e1);
}

.sheet-btn.ghost:hover {
  background: var(--border-color-light, #f1f5f9);
  color: var(--text-main, #0f172a);
}

/* Ticket Confirmation Card */
.ticket-box {
  background: #eff6ff;
  border: 1.5px dashed #93c5fd;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  margin: 16px 0;
}

.ticket-label {
  font-size: 11px;
  font-weight: 700;
  color: #1e3a8a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.ticket-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: 0.03em;
  word-break: break-all;
}

.ticket-hint {
  font-size: 11px;
  color: #4b5563;
  margin-top: 8px;
  line-height: 1.4;
}

/* Status Tracking Stepper */
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
  text-align: left;
}

.status-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin: 20px 10px 14px;
}

.status-track::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.status-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.status-step .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border-color);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 9px;
  transition: background var(--transition-fast);
}

.status-step span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.status-step.done .dot {
  background: #1e3a8a;
}

.status-step.done span {
  color: #1e3a8a;
  font-weight: 700;
}

.status-step.current .dot {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.2);
}

.status-step.current span {
  color: var(--primary);
  font-weight: 800;
}

/* Rating Stars */
.rating-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.rating-stars button {
  background: none;
  border: none;
  font-size: 32px;
  color: #cbd5e1;
  cursor: pointer;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.rating-stars button:hover,
.rating-stars button.on {
  color: #f59e0b;
  transform: scale(1.15);
}

/* Spinner Loader */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Indicators 20 Matrix Table (for Modal) */
.table-iga {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 12px;
}

.table-iga th {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.table-iga td {
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: top;
}

.table-iga tr:hover {
  background: var(--bg-card-subtle);
}

.badge-tag-ok {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  display: inline-block;
}

.badge-tag-wajib {
  background: #fee2e2;
  color: #dc2626;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9.5px;
}

/* ============================================================
   DARK MODE OVERRIDES FOR MODALS & FORMS
   ============================================================ */
body.theme-dark .sheet {
  background: #0f1923;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px #1e3347;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}

body.theme-dark .sheet::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
}

body.theme-dark .sheet::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

body.theme-dark .btn-sheet-close {
  background: #152433;
  border-color: #1e3347;
  color: #94a3b8;
}

body.theme-dark .btn-sheet-close:hover {
  background: #1e3347;
  color: #f8fafc;
}

body.theme-dark .sheet-handle {
  background: #1e3347;
}

body.theme-dark .form-field label {
  color: #f8fafc;
}

body.theme-dark .form-field input,
body.theme-dark .form-field select,
body.theme-dark .form-field textarea {
  background: #152433;
  border-color: #1e3347;
  color: #f8fafc;
}

body.theme-dark .form-field input::placeholder,
body.theme-dark .form-field textarea::placeholder {
  color: #64748b;
}

body.theme-dark .form-field input:focus,
body.theme-dark .form-field select:focus,
body.theme-dark .form-field textarea:focus {
  background: #192b3d;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.25);
}

body.theme-dark .form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

body.theme-dark .cat-select-btn {
  background: #152433;
  border-color: #1e3347;
  color: #f8fafc;
}

body.theme-dark .location-detected-box {
  background: #152433;
  border-color: #1e3347;
  color: #f8fafc;
}

body.theme-dark .status-card {
  background: #152433;
  border-color: #1e3347;
}

body.theme-dark .sheet-btn.ghost {
  border-color: #1e3347;
  color: #94a3b8;
}

body.theme-dark .sheet-btn.ghost:hover {
  background: #1e3347;
  color: #f8fafc;
}

body.theme-dark .table-iga th {
  background: #152433;
  border-color: #1e3347;
  color: #94a3b8;
}

body.theme-dark .table-iga td {
  border-color: #1e3347;
  color: #f8fafc;
}

body.theme-dark .table-iga tr:hover {
  background: #152433;
}
