/**
 * Aplikasi Pembacaan Rontgen Paru (TB) - Puskesmas & Fasilitas Kesehatan
 * CSS Stylesheet Utama - Tema Medical Teal / Green
 */

/* ==========================================================================
   1. CSS Variables & Reset
   ========================================================================== */
:root {
  /* Skema Warna Puskesmas / Medical Teal */
  --primary: #0f766e;        /* Teal 700 */
  --primary-light: #14b8a6;  /* Teal 500 */
  --primary-dark: #134e4a;   /* Teal 900 */
  --primary-subtle: #ccfbf1; /* Teal 100 */
  --primary-hover: #0d9488;  /* Teal 600 */

  /* Latar Belakang & Permukaan */
  --bg: #f0fdfa;             /* Teal 50 */
  --card-bg: #ffffff;
  --card-subtle: #f8fafc;

  /* Tipografi */
  --text: #1e293b;           /* Slate 800 */
  --text-light: #64748b;     /* Slate 500 */
  --text-muted: #94a3b8;     /* Slate 400 */

  /* Status & Kategori Temuan */
  --danger: #ef4444;         /* Merah TB Aktif */
  --danger-light: #fee2e2;
  --danger-dark: #991b1b;

  --warning: #f59e0b;        /* Oranye TB Inaktif */
  --warning-light: #fef3c7;
  --warning-dark: #92400e;

  --yellow: #eab308;         /* Kuning Abnormal Non-TB */
  --yellow-light: #fef9c3;
  --yellow-dark: #854d0e;

  --success: #22c55e;        /* Hijau Normal */
  --success-light: #dcfce7;
  --success-dark: #166534;

  --info: #3b82f6;           /* Biru Informasi */
  --info-light: #dbeafe;
  --info-dark: #1e40af;

  --gray: #64748b;           /* Abu-abu Abnormal Lainnya */
  --gray-light: #f1f5f9;
  --gray-dark: #334155;

  /* Aksen WhatsApp */
  --wa-green: #25D366;
  --wa-green-hover: #1ebd5a;

  /* Garis & Border */
  --border: #e2e8f0;
  --border-focus: #14b8a6;

  /* Radius Sudut */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Bayangan (Shadows) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Transisi */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   2. Layout & Kontainer
   ========================================================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  width: 100%;
}

.main-content {
  flex: 1;
}

/* ==========================================================================
   3. Navbar
   ========================================================================== */
.navbar {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  padding: 14px 0;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  padding-top: 0;
  padding-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #ffffff;
}

.navbar-brand .brand-icon {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.navbar-brand .brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: block;
}

.navbar-brand .brand-subtitle {
  font-size: 0.75rem;
  opacity: 0.85;
  display: block;
  font-weight: 400;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-weight: 600;
}

/* ==========================================================================
   4. Cards & Card Header
   ========================================================================== */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(15, 118, 110, 0.08);
  transition: var(--transition);
}

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

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

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

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ==========================================================================
   5. Form Controls & Layout
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
}

.form-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group .form-hint {
  font-size: 0.775rem;
  color: var(--text-light);
  margin-top: 4px;
}

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

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

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.925rem;
  color: var(--text);
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  font-family: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%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 12px center;
  background-size: 16px;
  padding-right: 36px;
}

/* ==========================================================================
   6. Tombol (Buttons)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius);
  padding: 10px 18px;
  transition: var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.25;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #ffffff;
  box-shadow: 0 4px 8px rgba(15, 118, 110, 0.35);
}

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

.btn-danger:hover {
  background-color: var(--danger-dark);
}

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

.btn-success:hover {
  background-color: var(--success-dark);
}

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

.btn-warning:hover {
  background-color: var(--warning-dark);
}

.btn-wa {
  background-color: var(--wa-green);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 211, 102, 0.25);
}

.btn-wa:hover {
  background-color: var(--wa-green-hover);
  color: #ffffff;
  box-shadow: 0 4px 8px rgba(37, 211, 102, 0.35);
}

.btn-secondary {
  background-color: var(--gray-light);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover {
  background-color: var(--primary-subtle);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   7. Tabel & Table Wrapper
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 12px;
  background-color: #ffffff;
}

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

table thead th {
  background-color: #f8fafc;
  color: var(--text-light);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

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

table tbody tr:nth-child(even) {
  background-color: #fafbfc;
}

table tbody tr:hover {
  background-color: var(--primary-subtle);
}

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

/* ==========================================================================
   8. Badges (Pill Badges)
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
  white-space: nowrap;
}

.badge-success {
  background-color: var(--success-light);
  color: var(--success-dark);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-danger {
  background-color: var(--danger-light);
  color: var(--danger-dark);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
  background-color: var(--warning-light);
  color: var(--warning-dark);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-yellow {
  background-color: var(--yellow-light);
  color: var(--yellow-dark);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-info {
  background-color: var(--info-light);
  color: var(--info-dark);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-gray {
  background-color: var(--gray-light);
  color: var(--gray-dark);
  border: 1px solid var(--border);
}

/* ==========================================================================
   9. Alerts (Notifikasi)
   ========================================================================== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.alert-success {
  background-color: var(--success-light);
  color: var(--success-dark);
  border-color: rgba(34, 197, 94, 0.4);
}

.alert-danger {
  background-color: var(--danger-light);
  color: var(--danger-dark);
  border-color: rgba(239, 68, 68, 0.4);
}

.alert-warning {
  background-color: var(--warning-light);
  color: var(--warning-dark);
  border-color: rgba(245, 158, 11, 0.4);
}

.alert-info {
  background-color: var(--info-light);
  color: var(--info-dark);
  border-color: rgba(59, 130, 246, 0.4);
}

/* ==========================================================================
   10. Statistik Dashboard (Stats Grid)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 118, 110, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}

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

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

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

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

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
}

.stat-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   11. Zona Unggah Foto (Upload Zone) & Pratinjau
   ========================================================================== */
.upload-zone {
  border: 2px dashed var(--primary-light);
  background-color: rgba(240, 253, 250, 0.6);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  background-color: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.15);
}

.upload-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 12px;
}

.upload-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 4px;
}

.upload-subtitle {
  font-size: 0.8125rem;
  color: var(--text-light);
}

.preview-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

/* ==========================================================================
   12. Hasil Analisis AI Rontgen (Hasil Section)
   ========================================================================== */
.hasil-section {
  background-color: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 24px;
  margin-top: 20px;
}

.hasil-kategori {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.hasil-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.hasil-item:last-child {
  border-bottom: none;
}

.hasil-item-icon {
  width: 32px;
  height: 32px;
  background-color: var(--primary-subtle);
  color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.hasil-item-content {
  flex: 1;
}

.hasil-item-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.hasil-item-value {
  font-size: 0.95rem;
  color: var(--text);
}

/* ==========================================================================
   13. Search Bar & Filter
   ========================================================================== */
.search-bar {
  position: relative;
  width: 100%;
  max-width: 340px;
}

.search-bar .input {
  padding-left: 38px;
}

.search-bar-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

/* ==========================================================================
   14. Pagination
   ========================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin-top: 24px;
}

.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: var(--transition);
}

.page-item .page-link:hover {
  background-color: var(--primary-subtle);
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.page-item.active .page-link {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.page-item.disabled .page-link {
  opacity: 0.5;
  pointer-events: none;
  background-color: #f8fafc;
}

/* ==========================================================================
   15. Empty State & Modal
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

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

.empty-state-desc {
  font-size: 0.875rem;
  color: var(--text-light);
  max-width: 400px;
  margin: 0 auto 18px;
}

.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px;
}

.modal-close:hover {
  color: var(--text);
}

/* ==========================================================================
   16. Loading Spinner (CSS Only)
   ========================================================================== */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--primary-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.loading-spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

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

/* ==========================================================================
   17. Media Queries (Responsif)
   ========================================================================== */
@media (max-width: 768px) {
  .container {
    padding: 16px 14px;
  }

  .navbar .container {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

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

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

  .card {
    padding: 18px;
  }

  .search-bar {
    max-width: 100%;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

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

  .stat-number {
    font-size: 1.75rem;
  }

  .btn {
    width: 100%;
  }

  .btn-sm {
    width: auto;
  }
}

/* ==========================================================================
   18. Cetak Laporan (Print Styles untuk PDF / Export)
   ========================================================================== */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .navbar,
  .btn,
  .search-bar,
  .pagination,
  .upload-zone,
  .modal,
  .no-print {
    display: none !important;
  }

  .container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    page-break-inside: avoid;
  }

  .table-wrap {
    border: 1px solid #333 !important;
  }

  table thead th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
  }

  .hasil-section {
    border: 1px solid #999 !important;
    page-break-inside: avoid;
  }

  .preview-img {
    max-height: 380px !important;
    box-shadow: none !important;
  }
}
