/* ============================================
   SIMDES 2026 — Component Styles
   Cards, Tables, Forms, Buttons, Badges
   ============================================ */

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ===== KPI STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  cursor: default;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-color, var(--accent));
}

.stat-card.accent  { --stat-color: var(--accent); }
.stat-card.positive { --stat-color: var(--positive); }
.stat-card.danger  { --stat-color: var(--danger); }
.stat-card.info    { --stat-color: var(--info); }
.stat-card.purple  { --stat-color: var(--purple); }
.stat-card.warning { --stat-color: var(--warning); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  background: var(--stat-icon-bg, var(--accent-dim));
}

.stat-card.accent  .stat-icon { background: var(--accent-dim); }
.stat-card.positive .stat-icon { background: var(--positive-dim); }
.stat-card.danger  .stat-icon { background: var(--danger-dim); }
.stat-card.info    .stat-icon { background: var(--info-dim); }
.stat-card.purple  .stat-icon { background: var(--purple-dim); }
.stat-card.warning .stat-icon { background: var(--warning-dim); }

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card.accent  .stat-icon svg { color: var(--accent); }
.stat-card.positive .stat-icon svg { color: var(--positive); }
.stat-card.danger  .stat-icon svg { color: var(--danger); }
.stat-card.info    .stat-icon svg { color: var(--info); }
.stat-card.purple  .stat-icon svg { color: var(--purple); }
.stat-card.warning .stat-icon svg { color: var(--warning); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-value.compact {
  font-size: 1.3rem;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-sub svg {
  width: 12px;
  height: 12px;
}

.stat-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 14px;
  overflow: hidden;
}

.stat-progress-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--stat-color, var(--accent));
  transition: width 1s ease;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-main-side {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}

@media (max-width: 1200px) {
  .grid-main-side {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.855rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--font);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #E09010;
  border-color: #E09010;
  box-shadow: var(--shadow-accent);
}

.btn-success {
  background: var(--positive);
  color: var(--bg-base);
  border-color: var(--positive);
}
.btn-success:hover {
  opacity: 0.88;
  box-shadow: var(--shadow-positive);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.85; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-card-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead {
  background: var(--bg-surface);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.right, td.right {
  text-align: right;
}

th.center, td.center {
  text-align: center;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

td.td-main {
  color: var(--text-primary);
  font-weight: 500;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

.td-number {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
}

.td-number.positive { color: var(--positive); }
.td-number.danger { color: var(--danger); }
.td-number.accent { color: var(--accent); }

.tfoot-row td {
  background: var(--bg-surface);
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.88rem;
  border-top: 2px solid var(--border-light);
}

/* ===== FORMS ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238B97B5' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-control-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 24px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge svg { width: 11px; height: 11px; }

.badge-accent   { background: var(--accent-dim);   color: var(--accent);   }
.badge-positive { background: var(--positive-dim); color: var(--positive); }
.badge-danger   { background: var(--danger-dim);   color: var(--danger);   }
.badge-info     { background: var(--info-dim);     color: var(--info);     }
.badge-purple   { background: var(--purple-dim);   color: var(--purple);   }
.badge-warning  { background: var(--warning-dim);  color: var(--warning);  }
.badge-muted    { background: var(--bg-muted);     color: var(--text-muted); }

/* ===== ALERTS ===== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 0.84rem;
  margin-bottom: 16px;
}

.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert p { font-weight: 500; color: var(--text-primary); }
.alert span { font-size: 0.78rem; color: var(--text-secondary); display: block; margin-top: 2px; }

.alert-warning { background: var(--warning-dim); border-color: var(--warning); }
.alert-warning svg { color: var(--warning); }
.alert-danger { background: var(--danger-dim); border-color: var(--danger); }
.alert-danger svg { color: var(--danger); }
.alert-positive { background: var(--positive-dim); border-color: var(--positive); }
.alert-positive svg { color: var(--positive); }
.alert-info { background: var(--info-dim); border-color: var(--info); }
.alert-info svg { color: var(--info); }

/* ===== PROGRESS BAR ===== */
.progress-wrapper {
  margin-top: 6px;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-pct {
  font-size: 0.78rem;
  font-weight: 700;
}

.progress-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  border: none;
  font-family: var(--font);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  border: 1px solid var(--border);
}

.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--bg-card-hover);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeInUp 0.25s ease both;
}

/* ===== DIVIDER ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-muted);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-icon svg {
  width: 26px;
  height: 26px;
  color: var(--text-muted);
}

.empty-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 9px;
}

.modal-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  width: 100%;
}

/* ===== SECTION SPACING ===== */
.section-gap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== NUMBER FORMAT ===== */
.num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.rupiah::before {
  content: 'Rp ';
  font-weight: 400;
  font-size: 0.85em;
  color: var(--text-muted);
}

/* ===== TOOLTIP ===== */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-muted);
  color: var(--text-primary);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  border: 1px solid var(--border);
  z-index: 99;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ===== RESPONSIVE HELPERS ===== */
@media (max-width: 768px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
