/* ========================================= */
/* 1. SETUP & UTILITIES                      */
/* ========================================= */

/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@600;800&display=swap');

/* CSS Variables for Easy Theming */
:root {
  --primary-color: #ff6b35;
  --primary-color-dark: #f7931e;
  --dark-color: #1a1a1a;
  --dark-color-light: #333333;
  --light-color: #ffffff;
  --text-color: #1a1a1a;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --background-light: #f8f9fa;

  --success-color: #059669;
  --success-color-dark: #10b981;
  --danger-color: #dc2626;
  --warning-color: #f59e0b;
  --info-color: #1d4ed8;

  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Monaco', 'Consolas', monospace;
  
  --border-radius: 12px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background-color: var(--light-color);
  color: var(--text-color);
  line-height: 1.6;
  font-size: 14px;
}

/* ========================================= */
/* 2. LAYOUT & CONTAINER                     */
/* ========================================= */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background-color: var(--light-color);
  min-height: 100vh;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 0;
  background: linear-gradient(135deg, var(--dark-color) 0%, var(--dark-color-light) 100%);
  color: var(--light-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.025em;
}

.header p {
  font-size: 1.2rem;
  font-weight: 500;
  opacity: 0.9;
}

/* ========================================= */
/* 3. TABS & NAVIGATION                      */
/* ========================================= */

.tab-container {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
  background-color: var(--background-light);
  border-radius: var(--border-radius);
  padding: 6px;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  flex: 1;
  max-width: 250px;
  padding: 16px 24px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  background-color: var(--light-color);
  color: var(--text-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
  color: var(--light-color);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
  transform: translateY(-1px);
}

.tab-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease-in-out;
}

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

/* ========================================= */
/* 4. SECTION HEADER & CONTROLS              */
/* ========================================= */

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f1f3f4;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.controls select {
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--light-color);
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 180px;
}

.controls select:hover {
  border-color: var(--primary-color);
}

.controls select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.btn-export {
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
  color: var(--light-color);
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 4px rgba(255, 107, 53, 0.2);
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

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


/* ========================================= */
/* 5. TABLE STYLES                           */
/* ========================================= */

.table-container {
  background: var(--light-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}

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

.table thead {
  background: linear-gradient(135deg, var(--dark-color) 0%, var(--dark-color-light) 100%);
}

.table thead th {
  padding: 18px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--light-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  border: none;
}

.table tbody tr {
  border-bottom: 1px solid #f1f3f4;
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background-color: var(--background-light);
}

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

.table tbody td {
  padding: 16px;
  color: var(--text-color);
  font-weight: 500;
  vertical-align: middle;
}

.table .number {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* -- Financial table specific styles -- */
.keuangan-table .pemasukan { color: var(--success-color); }
.keuangan-table .pengeluaran { color: var(--danger-color); }
.keuangan-table .saldo-positif { color: var(--info-color); font-weight: 700; }
.keuangan-table .saldo-negatif { color: var(--danger-color); font-weight: 700; }

/* -- PDH table specific styles with STAMP EFFECT -- */
.pdh-table .status-lunas,
.pdh-table .status-belum-lunas {
  color: var(--light-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  display: inline-flex;
  align-items: center;
  position: relative; /* Needed for the pseudo-element */
}

/* LUNAS (PAID) STAMP */
.pdh-table .status-lunas {
  background: linear-gradient(135deg, var(--success-color-dark) 0%, var(--success-color) 100%);
}

.pdh-table .status-lunas::after {
  content: '✓';
  font-family: 'Arial', sans-serif;
  font-size: 1rem;
  font-weight: bold;
  color: var(--success-color-dark);
  background: var(--light-color);
  border: 2px solid var(--success-color);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transform: rotate(10deg);
  box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* BELUM LUNAS (UNPAID) STAMP */
.pdh-table .status-belum-lunas {
  background: linear-gradient(135deg, var(--warning-color) 0%, var(--danger-color) 100%);
}

.pdh-table .status-belum-lunas::after {
  content: '✗';
  font-family: 'Arial', sans-serif;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--danger-color);
  background: var(--light-color);
  border: 2px solid var(--danger-color);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transform: rotate(-10deg);
  box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* ========================================= */
/* 6. SUMMARY CARDS                          */
/* ========================================= */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.summary-item {
  background: var(--light-color);
  padding: 24px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.summary-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.summary-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-dark) 100%);
}

.summary-item .label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-item .value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-color);
  font-family: var(--font-mono);
}

.summary-item .value.pemasukan { color: var(--success-color); }
.summary-item .value.pengeluaran { color: var(--danger-color); }
.summary-item .value.saldo { color: var(--info-color); }
.summary-item .value.lunas { color: var(--success-color); }
.summary-item .value.belum-lunas { color: var(--warning-color); }

/* ========================================= */
/* 7. MODAL STYLES                           */
/* ========================================= */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: modalFadeIn 0.3s ease;
}

.modal-content {
  background-color: var(--light-color);
  margin: 10% auto;
  padding: 0;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease;
}

.modal-header {
  background: linear-gradient(135deg, var(--dark-color) 0%, var(--dark-color-light) 100%);
  color: var(--light-color);
  padding: 24px;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.close { font-size: 2rem; font-weight: bold; cursor: pointer; color: var(--light-color); opacity: 0.8; transition: opacity 0.2s ease; line-height: 1; }
.close:hover { opacity: 1; }

.modal-body { padding: 30px; }
.export-options h4 { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }

.export-options label {
  display: block;
  margin-bottom: 15px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.export-options label:hover {
  background-color: var(--background-light);
  border-color: var(--primary-color);
}

.export-options input[type="radio"] {
  margin-right: 12px;
  accent-color: var(--primary-color);
  transform: scale(1.2);
}

.export-options label:has(input[type="radio"]:checked) {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.1) 0%, rgba(247, 147, 30, 0.1) 100%);
  border-color: var(--primary-color);
  color: var(--text-color);
}

.modal-footer {
  padding: 20px 30px 30px;
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

.btn-cancel {
  padding: 12px 24px;
  background-color: #f3f4f6;
  color: #374151;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel:hover { background-color: #e5e7eb; border-color: #9ca3af; }

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }


/* ========================================= */
/* 8. RESPONSIVE & PRINT STYLES              */
/* ========================================= */

/* Tablet */
@media (max-width: 768px) {
  .container { padding: 15px; }
  .header h1 { font-size: 2rem; }
  .header p { font-size: 1rem; }
  .tab-btn { padding: 12px 16px; font-size: 0.9rem; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 15px; }
  .section-header h2 { font-size: 1.5rem; }
  .controls { width: 100%; }
  .controls select, .btn-export { flex: 1; min-width: auto; }
  .table-container { overflow-x: auto; }
  .table { min-width: 700px; }
  .summary { grid-template-columns: 1fr; }
  .modal-content { margin: 5% auto; width: 95%; }
}

/* Mobile */
@media (max-width: 480px) {
  .header { padding: 20px; margin-bottom: 30px; }
  .header h1 { font-size: 1.8rem; }
  .tab-container { flex-direction: column; gap: 8px; }
  .tab-btn { max-width: none; }
  .section-header h2 { font-size: 1.3rem; }
  .modal-footer { flex-direction: column; gap: 10px; }
  .btn-cancel, .btn-export { width: 100%; justify-content: center; }
}

/* Print */
@media print {
  body { font-size: 10pt; color: #000; }
  .controls, .btn-export, .modal, .tab-container, .header p { display: none !important; }
  .container { max-width: none; margin: 0; padding: 0; }
  .header, .table-container, .summary-item { box-shadow: none; border: 1px solid #000; border-radius: 0; }
  .tab-content { display: block !important; }
  .summary-item::before { background: #000; }
  .pdh-table .status-lunas, .pdh-table .status-belum-lunas { background: transparent !important; color: #000; padding: 2px; border: 1px solid #000; }
  .pdh-table .status-lunas::after, .pdh-table .status-belum-lunas::after { display: none; }
}
