/* ==========================================================================
   Tracker Distribusi ID Card - Modern Festival Logistics Theme
   ========================================================================== */

:root {
  --primary-dark: #3b1d54;
  --primary-header: #4c226e;
  --primary-accent: #6b21a8;
  --primary-light: #9333ea;
  
  --bg-page: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --color-green-bg: #dcfce7;
  --color-green-text: #15803d;
  --color-green-border: #86efac;

  --color-orange-bg: #ffedd5;
  --color-orange-text: #c2410c;
  --color-orange-border: #fdba74;

  --color-blue-bg: #dbeafe;
  --color-blue-text: #1d4ed8;
  --color-blue-border: #93c5fd;

  --color-purple-bg: #f3e8ff;
  --color-purple-text: #7e22ce;
  --color-purple-border: #d8b4fe;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.08), 0 2px 6px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 24px -4px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 60px;
}

/* Container */
.app-container {
  max-width: 1520px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-dark);
}

.brand-badge .icon-box {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-header), #8b5cf6);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
  color: var(--primary-accent);
  background: var(--color-purple-bg);
}

/* Festival Header Banner (Matching the spreadsheet image) */
.festival-banner {
  background: linear-gradient(135deg, #3d1b54 0%, #4c226e 50%, #2f1542 100%);
  color: #ffffff;
  padding: 22px 28px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.festival-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(216, 180, 254, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.festival-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.festival-subtitle {
  font-size: 13.5px;
  color: #e9d5ff;
  font-weight: 400;
  opacity: 0.95;
}

/* Metrics & Allocation Bar */
.metrics-section {
  display: grid;
  grid-template-columns: 190px 190px 190px 160px 1fr;
  gap: 12px;
  background: #ffffff;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-top: none;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  align-items: stretch;
}

@media (max-width: 1200px) {
  .metrics-section {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  .metrics-section {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid transparent;
  transition: transform 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
}

.metric-card.total {
  background: #faf5ff;
  border-color: #e9d5ff;
}
.metric-card.total .metric-value {
  color: #581c87;
}

.metric-card.terdistribusi {
  background: var(--color-green-bg);
  border-color: var(--color-green-border);
}
.metric-card.terdistribusi .metric-value {
  color: var(--color-green-text);
}

.metric-card.pending {
  background: var(--color-orange-bg);
  border-color: var(--color-orange-border);
}
.metric-card.pending .metric-value {
  color: var(--color-orange-text);
}

.metric-card.progress-card {
  background: #ffffff;
  border-color: var(--border-color);
}

.metric-label {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 2px;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Progress bar inside metric */
.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 10px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* Zone Matrix Table inside Header (Matching screenshot) */
.zone-matrix-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.zone-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: center;
}

.zone-matrix-table th {
  background: #3b1d54;
  color: #ffffff;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  border: 1px solid #4c226e;
}

.zone-matrix-table th:first-child {
  background: #28113b;
  text-align: left;
  border-radius: 4px 0 0 0;
}
.zone-matrix-table th:last-child {
  border-radius: 0 4px 0 0;
}

.zone-matrix-table td {
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  font-weight: 600;
  background: #ffffff;
}

.zone-matrix-table tr:hover td {
  background: #f1f5f9;
}

.zone-matrix-table td:first-child {
  font-weight: 700;
  text-align: left;
  background: #f8fafc;
  color: var(--text-muted);
}

/* Action Toolbar */
.toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.search-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.search-input-wrap {
  position: relative;
  min-width: 260px;
}

.search-input-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 13.5px;
  background: #ffffff;
  outline: none;
  transition: all 0.2s;
}

.search-input-wrap input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 16px;
}

.select-filter {
  padding: 9.5px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 13.5px;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.select-filter:focus {
  border-color: var(--primary-light);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #4c226e;
  color: #ffffff;
}
.btn-primary:hover {
  background: #391854;
  box-shadow: 0 4px 12px rgba(76, 34, 110, 0.3);
}

.btn-accent {
  background: #0ea5e9;
  color: #ffffff;
}
.btn-accent:hover {
  background: #0284c7;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-success {
  background: #10b981;
  color: #ffffff;
}
.btn-success:hover {
  background: #059669;
}

/* Main Table Section */
.table-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.custom-table thead th {
  background: #49225b;
  color: #ffffff;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.custom-table thead th:last-child {
  border-right: none;
}

.custom-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.custom-table tbody td:last-child {
  border-right: none;
}

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

.custom-table tbody tr.row-terdistribusi {
  background-color: #ffffff;
}

/* Badge Categories */
.badge-cat {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Badge Color Cards */
.badge-color {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.status-done {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.status-pending {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}

.status-ready {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* WhatsApp Link */
.wa-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #15803d;
  background: #f0fdf4;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  font-weight: 600;
  font-size: 12.5px;
  text-decoration: none;
  transition: all 0.2s;
}

.wa-link:hover {
  background: #15803d;
  color: #ffffff;
  border-color: #15803d;
}

/* Action Dropdown / Buttons */
.action-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.btn-icon.delete:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content, .modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 92%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalSlide 0.25s ease-out;
  position: relative;
}

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

.modal-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3, .modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.modal-body {
  padding: 20px;
  max-height: calc(90vh - 130px);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* Form Groups */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.15);
}

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

/* Alerts / Flash Messages */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.alert-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

/* Copy Link Pill */
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 12px;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.copy-btn {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--primary-accent);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.copy-btn:hover {
  background: #e2e8f0;
}

/* Table Responsive Container */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Responsive Grid Helpers */
.categories-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 24px;
}

.links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ==========================================================================
   COMPREHENSIVE MOBILE & TABLET RESPONSIVE RULES
   ========================================================================== */

@media (max-width: 1024px) {
  .categories-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .top-nav {
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 16px;
  }
  
  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .zone-matrix-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 12px 10px;
  }

  .festival-banner {
    padding: 16px 18px;
  }

  .festival-title {
    font-size: 18px;
  }

  .festival-subtitle {
    font-size: 12px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  .zone-matrix-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

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

  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .search-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrap {
    width: 100% !important;
    min-width: 0 !important;
  }

  .custom-table th, .custom-table td {
    padding: 10px 10px;
    font-size: 12.5px;
  }

  .btn-action {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .modal-content, .modal-card {
    width: 96%;
    max-height: 95vh;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header, .modal-footer {
    padding: 12px 16px;
  }

  /* Status badge tap friendly */
  .status-badge {
    padding: 4px 10px;
    font-size: 11px;
  }
}

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

  .top-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-badge {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
  }

  .festival-title {
    font-size: 16px;
  }
}

/* Print Styling */
@media print {
  .top-nav, .toolbar-section, .btn-icon, .btn, .modal-overlay {
    display: none !important;
  }
  body {
    background: #fff;
    padding: 0;
  }
  .app-container {
    max-width: 100%;
    padding: 0;
  }
  .festival-banner {
    background: #3b1d54 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
