/* ==========================================================================
   Sakriya Sath - Rasuwa Relief Dashboard Styles
   ========================================================================== */

/* Dashboard Layout Wrapper */
.dashboard-page {
  padding-bottom: 72px;
}

.dashboard-container {
  width: min(1280px, calc(100% - 48px));
  margin-inline: auto;
}

@media (max-width: 580px) {
  .dashboard-container {
    width: calc(100% - 32px);
  }
}

/* --------------------------------------------------------------------------
   Top Action & Status Toolbar
   -------------------------------------------------------------------------- */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(18, 35, 104, 0.04);
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.toolbar-district-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.toolbar-district-badge strong {
  color: var(--blue-dark);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-public-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Edit Dashboard button (Public View) */
.btn-edit-dashboard {
  background: var(--blue);
  color: var(--white);
  border: 1px solid var(--blue);
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(24, 53, 197, 0.2);
  transition: all var(--trans-fast);
  white-space: nowrap;
}

.btn-edit-dashboard:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
  box-shadow: 0 4px 14px rgba(24, 53, 197, 0.32);
  transform: translateY(-1px);
}

/* Admin status badge */
.admin-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  white-space: nowrap;
}

.admin-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse-orange 2s infinite;
}

@keyframes pulse-orange {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.btn-admin-logout {
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
}

.btn-admin-logout:hover {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

/* Visibility Control for Public vs Admin */
.admin-only-btn,
.admin-only-col {
  display: none !important;
}

body.is-admin-mode .admin-only-btn {
  display: inline-flex !important;
}

body.is-admin-mode .admin-only-col {
  display: table-cell !important;
}

/* Login Modal Alert */
.login-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-dashboard {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--trans-fast);
  white-space: nowrap;
}

.btn-dashboard-primary {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

.btn-dashboard-primary:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
  box-shadow: 0 4px 12px rgba(24, 53, 197, 0.24);
}

.btn-dashboard-secondary {
  background: var(--soft-yellow);
  color: var(--logo-brown);
  border-color: #ebdcb9;
}

.btn-dashboard-secondary:hover {
  background: #fbf2cc;
  border-color: var(--logo-brown);
}

.btn-dashboard-outline {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
}

.btn-dashboard-outline:hover {
  background: #f8fafc;
  border-color: var(--muted);
}

.btn-icon-only {
  padding: 8px 12px;
}

/* --------------------------------------------------------------------------
   KPI Summary Statistics Cards
   -------------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: 0 2px 6px rgba(18, 35, 104, 0.03);
  transition: transform var(--trans-fast), box-shadow var(--trans-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--line);
  transition: background-color var(--trans-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(18, 35, 104, 0.08);
}

.kpi-card-blue::before { background: var(--blue); }
.kpi-card-orange::before { background: #ea580c; }
.kpi-card-green::before { background: #10b981; }
.kpi-card-purple::before { background: #7c3aed; }

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

.kpi-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: #f1f5f9;
  color: var(--blue-dark);
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.kpi-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Dedicated Interactive Map Section (Rasuwa District)
   -------------------------------------------------------------------------- */
.dashboard-map-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(18, 35, 104, 0.04);
  margin-bottom: 32px;
  overflow: hidden;
}

.map-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: #fafafc;
}

.map-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.map-title-text h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--blue-dark);
  margin: 0;
  line-height: 1.2;
}

.map-title-text p {
  font-size: 12.5px;
  color: var(--muted);
  margin: 3px 0 0 0;
}

.map-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.map-chip-select {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.map-chip-select:focus {
  border-color: var(--blue);
}

.map-viewport {
  position: relative;
  min-height: 440px;
  background: #eef2f6;
  background-image: 
    radial-gradient(#d1d5db 1px, transparent 1px),
    linear-gradient(to right, #f8fafc, #edf2f7);
  background-size: 24px 24px, 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.map-overlay-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  font-size: 12px;
}

.map-overlay-badge strong {
  display: block;
  color: var(--blue-dark);
  font-size: 13px;
}

.map-overlay-badge span {
  color: var(--muted);
}

.map-reserved-placeholder {
  max-width: 720px;
  width: 100%;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid #dbeafe;
  border-radius: var(--radius-md);
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(18, 35, 104, 0.08);
  position: relative;
  z-index: 5;
}

.map-municipalities-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 18px 0 16px;
}

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

.municipality-tag {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--blue-dark);
  transition: all var(--trans-fast);
  cursor: pointer;
  text-align: center;
}

.municipality-tag span {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}

.municipality-tag:hover,
.municipality-tag.is-selected {
  background: var(--soft-yellow);
  border-color: var(--logo-brown);
  transform: translateY(-1px);
}

.map-footer-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Dashboard Sections & Data Tables
   -------------------------------------------------------------------------- */
.dashboard-grid-sections {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.dashboard-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 10px rgba(18, 35, 104, 0.03);
  overflow: hidden;
}

.dashboard-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: #fafafc;
}

.card-title-group h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--blue-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title-group p {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0 0;
}

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

.dashboard-search-input {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  outline: none;
  min-width: 200px;
  transition: border-color var(--trans-fast);
}

.dashboard-search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 53, 197, 0.1);
}

.dashboard-filter-select {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.dashboard-filter-select:focus {
  border-color: var(--blue);
}

/* Data Table Component */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.dashboard-table th {
  background: #f8fafc;
  padding: 12px 18px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.dashboard-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

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

.dashboard-table tr:hover td {
  background: #fbfcfe;
}

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-status-planned {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.badge-status-ongoing {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-status-completed {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-severity-critical {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-severity-high {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.badge-severity-moderate {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
}

.badge-severity-monitored {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Actions in Table */
.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-table-action {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  color: var(--ink);
  transition: all var(--trans-fast);
}

.btn-table-action:hover {
  background: #f1f5f9;
  border-color: var(--muted);
}

.btn-table-action-delete:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Professional Empty State Box */
.dashboard-empty-state {
  padding: 56px 24px;
  text-align: center;
  background: var(--white);
}

.empty-state-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--muted);
}

.dashboard-empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--blue-dark);
  margin-bottom: 6px;
}

.dashboard-empty-state p {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto 20px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Interactive Modal Dialogs for Adding/Editing Records
   -------------------------------------------------------------------------- */
.dashboard-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 35, 104, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dashboard-modal-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

.dashboard-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: min(640px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(18, 35, 104, 0.2);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.dashboard-modal-backdrop.is-active .dashboard-modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--blue-dark);
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color var(--trans-fast);
}

.modal-close-btn:hover {
  background: #f1f5f9;
  color: var(--ink);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

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

@media (max-width: 580px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.form-group label .required-mark {
  color: #dc2626;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 53, 197, 0.12);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafc;
}

/* Toast Notification */
.dashboard-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--blue-dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.dashboard-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}
