/* ==========================================================================
   SIPLah Order Tracking - Modern Design System & Stylesheet
   ========================================================================== */

:root {
  /* Color Palette - Light Mode */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.2);
  
  --secondary: #0ea5e9;
  --accent: #6366f1;
  
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #eab308;
  --warning-bg: #fef08a;
  --warning-border: #ca8a04;
  
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.9);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  
  --border-color: #cbd5e1;
  --border-grid: #94a3b8;
  --border-focus: #3b82f6;
  
  --matrix-yellow: #fde047;
  --matrix-yellow-border: #ca8a04;
  --matrix-green: #15803d;
  --matrix-red: #ef4444;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: rgba(59, 130, 246, 0.15);
  --primary-glow: rgba(59, 130, 246, 0.35);
  
  --bg-main: #0b1120;
  --bg-card: #151e32;
  --bg-card-subtle: #1e293b;
  --bg-glass: rgba(21, 30, 50, 0.92);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --border-color: #334155;
  --border-grid: #475569;
  --border-focus: #60a5fa;
  
  --matrix-yellow: #ca8a04;
  --matrix-green: #16a34a;
  --matrix-red: #dc2626;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 10px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.7);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Background Gradients */
.bg-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob-1 {
  position: absolute;
  top: -80px;
  left: -80px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, rgba(37, 99, 235, 0) 70%);
  border-radius: 50%;
  filter: blur(40px);
}

.blob-2 {
  position: absolute;
  top: 40%;
  right: -100px;
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, rgba(99, 102, 241, 0) 70%);
  border-radius: 50%;
  filter: blur(50px);
}

/* Layout Containers */
.app-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container-fluid {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.25rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-title span {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.btn-nav-action {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-nav-action:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

#btnLoginAdmin {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transition: var(--transition);
}

#btnLoginAdmin:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

.btn-nav-action.admin-active {
  background: #1e40af;
  color: white;
  border-color: #1e3a8a;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
}

/* ==========================================================================
   Kecamatan Navigation Top Bar (Public Menu)
   ========================================================================== */

.kecamatan-menu-wrapper {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border-color);
  padding: 8px 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 68px;
  z-index: 40;
}

.kecamatan-menu-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 4px 0;
  scrollbar-width: thin;
}

.kecamatan-menu-bar::-webkit-scrollbar {
  height: 4px;
}

.kecamatan-menu-bar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.kecamatan-tab-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 8px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: capitalize;
}

.kecamatan-tab-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.kecamatan-tab-btn.active {
  background: #1e3a8a;
  color: white;
  border-color: #1e3a8a;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.35);
}

/* ==========================================================================
   Public Matrix Table Section
   ========================================================================== */

.matrix-main-section {
  padding: 24px 0 40px;
}

.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.matrix-title-group h2 {
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.matrix-title-group p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.last-upload-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.last-upload-badge i {
  color: var(--primary);
}

.last-upload-badge strong {
  color: var(--primary);
  font-weight: 700;
}

.matrix-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-school-input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px 8px 36px;
  font-size: 0.88rem;
  color: var(--text-primary);
  width: 260px;
  outline: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
  background-repeat: no-repeat;
  background-position: 12px center;
}

.search-school-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Legend Indicator */
.matrix-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-box.yellow { background-color: var(--matrix-yellow); border-color: var(--matrix-yellow-border); }
.legend-box.green { background-color: var(--matrix-green); }
.legend-box.red { background-color: var(--matrix-red); }
.legend-box.white { background-color: #ffffff; border-color: #cbd5e1; }

/* Matrix Table Styling (Pixel-perfect to Excel structure) */
.matrix-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.matrix-table-wrapper {
  width: 100%;
  overflow-x: auto;
  max-height: 75vh;
  position: relative;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: center;
  table-layout: fixed;
  min-width: 1100px;
}

.matrix-table th, .matrix-table td {
  border: 1px solid var(--border-grid);
  padding: 7px 8px;
  vertical-align: middle;
}

/* Table Header */
.matrix-table thead th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.82rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .matrix-table thead th {
  background: #1e293b;
  color: #f8fafc;
}

.th-kecamatan-title {
  text-align: left;
  padding-left: 16px !important;
  font-size: 0.95rem;
  text-transform: uppercase;
  background: #e2e8f0 !important;
  width: 250px;
}

[data-theme="dark"] .th-kecamatan-title {
  background: #0f172a !important;
}

.th-status-col {
  width: 85px;
}

.th-separator {
  width: 14px;
  background: #cbd5e1 !important;
  border-top: none !important;
  border-bottom: none !important;
}

[data-theme="dark"] .th-separator {
  background: #334155 !important;
}

/* School Name Column (Fixed / Left Column) */
.td-school-name {
  text-align: left;
  padding-left: 14px !important;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-card);
  position: sticky;
  left: 0;
  z-index: 5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: var(--transition);
}

.matrix-table tbody tr:hover .td-school-name {
  color: var(--primary);
  background: var(--primary-light);
}

/* Matrix Status Cell States */
.cell-status {
  height: 28px;
  cursor: pointer;
  transition: var(--transition);
}

.cell-status.filled-yellow {
  background-color: var(--matrix-yellow) !important;
}

.cell-status.filled-green {
  background-color: var(--matrix-green) !important;
  color: white;
}

.cell-status.filled-red {
  background-color: var(--matrix-red) !important;
  color: white;
}

.cell-status.empty {
  background-color: transparent;
}

.cell-separator {
  background: #e2e8f0;
  border-top: none !important;
  border-bottom: none !important;
}

[data-theme="dark"] .cell-separator {
  background: #1e293b;
}

.matrix-table tbody tr:hover td:not(.cell-separator):not(.filled-yellow):not(.filled-green):not(.filled-red) {
  background-color: rgba(37, 99, 235, 0.05);
}

/* ==========================================================================
   Admin Management Portal
   ========================================================================== */

.admin-portal-wrapper {
  padding: 30px 0 60px;
}

.admin-nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
}

.admin-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -2px;
  transition: var(--transition);
}

.admin-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-tab-pane {
  display: none;
}

.admin-tab-pane.active {
  display: block;
}

/* Excel Importer Box */
.excel-upload-card {
  background: var(--bg-card);
  border: 2px dashed #10b981;
  border-radius: var(--radius-xl);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 28px;
}

.excel-upload-card:hover, .excel-upload-card.dragover {
  background: var(--success-bg);
  transform: translateY(-2px);
}

.excel-upload-icon {
  font-size: 3rem;
  color: #10b981;
  margin-bottom: 12px;
}

.excel-upload-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.excel-upload-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Kecamatan & School Manager Grid */
.manager-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

.manager-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.manager-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 500px;
  overflow-y: auto;
}

.manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  transition: var(--transition);
}

.manager-item:hover, .manager-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.manager-item-actions {
  display: flex;
  gap: 6px;
}

.btn-icon-xs {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-icon-xs:hover {
  color: #ef4444;
  background: #fef2f2;
  border-color: #fca5a5;
  transform: scale(1.08);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

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

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

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

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

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-whatsapp {
  background: #25d366;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Print */
#printArea {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }
  #printArea, #printArea * {
    visibility: visible;
  }
  #printArea {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 20px;
    background: white;
    color: black;
  }
}

/* Responsive Styles */
@media (max-width: 900px) {
  .manager-grid {
    grid-template-columns: 1fr;
  }
}

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

  .site-header {
    height: auto;
  }

  .nav-container {
    height: 58px;
  }

  .brand-logo {
    font-size: 1.05rem;
    gap: 8px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border-radius: 8px;
  }

  .brand-subtitle {
    display: none;
  }

  .btn-nav-action span, #btnLoginAdmin span {
    display: none;
  }

  .btn-nav-action, #btnLoginAdmin {
    padding: 8px 12px;
  }

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

  .matrix-title-group h2 {
    font-size: 1.25rem;
  }

  .matrix-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-school-input {
    width: 100%;
  }

  .kecamatan-tab-btn {
    padding: 6px 14px;
    font-size: 0.82rem;
  }

  .matrix-table-wrapper {
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
  }
}

