/* ========================================================
   SIPM - UI COMPONENTS (CARDS, TABLES, MODALS, BUTTONS)
   ======================================================== */

/* ================= CARDS ================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--slate-900);
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--slate-500);
}

.card-body {
  padding: 1.5rem;
}

/* ================= STATS CARDS ================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-icon.emerald {
  background: var(--emerald-50);
  color: var(--emerald-700);
}

.stat-icon.amber {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-icon.rose {
  background: var(--arrear-bg);
  color: var(--arrear-color);
}

.stat-icon.sky {
  background: var(--info-bg);
  color: var(--info);
}

.stat-value {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
}

.stat-footer {
  font-size: 0.75rem;
  color: var(--slate-500);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

/* Kartu Penanda Khusus Tunggakan Tahun Lalu */
.stat-card.card-arrears {
  border-left: 4px solid var(--arrear-color);
  background: linear-gradient(180deg, #ffffff 0%, #fffbfc 100%);
}

.stat-card.card-arrears .stat-value {
  color: var(--arrear-color);
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-700) 0%, var(--emerald-800) 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--emerald-800) 0%, var(--emerald-900) 100%);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.35);
  color: #ffffff;
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border-color);
  color: var(--slate-700);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--slate-50);
  border-color: var(--slate-300);
  color: var(--slate-900);
}

.btn-success {
  background-color: var(--emerald-600);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  background-color: var(--emerald-700);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #be123c;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ================= BADGES ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-paid {
  background-color: var(--emerald-100);
  color: var(--emerald-800);
}

.badge-unpaid {
  background-color: var(--warning-bg);
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-partial {
  background-color: var(--info-bg);
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Penanda Tunggakan Tahun Lalu */
.badge-arrear {
  background-color: var(--arrear-bg);
  color: var(--arrear-color);
  border: 1px solid var(--arrear-border);
  font-weight: 800;
}

.badge-active {
  background-color: var(--emerald-100);
  color: var(--emerald-800);
}

/* ================= TABLES ================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.table th {
  background-color: #f8fafc;
  color: var(--slate-600);
  font-weight: 700;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--slate-700);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background-color: #f8fcf9;
}

/* Zebra row untuk tabel laporan */
.table-striped tbody tr:nth-of-type(odd) {
  background-color: #fafbfc;
}

/* ================= FORMS & CONTROLS ================= */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.375rem;
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--slate-800);
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.search-input-box {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-input-box input {
  padding-left: 2.25rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
}

/* ================= TAB NAVIGATION ================= */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.625rem 1.25rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--slate-500);
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

.tab-btn:hover {
  color: var(--emerald-700);
}

.tab-btn.active {
  color: var(--emerald-700);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--emerald-700);
}

/* ================= MODAL DIALOG ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.show {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.25s ease-out;
  overflow: hidden;
}

.modal-dialog.modal-lg {
  max-width: 840px;
}

.modal-dialog.modal-xl {
  max-width: 1050px;
}

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--slate-900);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--slate-400);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--slate-700);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ================= TOAST NOTIFICATIONS ================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  background-color: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 4px solid var(--emerald-600);
  animation: slideInRight 0.3s ease-out;
}

.toast.toast-error {
  border-left-color: var(--danger);
}

.toast.toast-warning {
  border-left-color: var(--warning);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
