/* Field Visit Monitoring System - Official MCC Styling */
:root {
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #ccfbf1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bg-slate: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success: #16a34a;
  --warning: #eab308;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  background-color: var(--bg-slate);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #042f2e 0%, #0f766e 100%);
  color: #ffffff;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  width: 100%;
  box-sizing: border-box;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mcc-emblem {
  width: 38px;
  height: 38px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--primary);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.app-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-subtitle {
  font-size: 0.72rem;
  opacity: 0.88;
  font-weight: 400;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-header-link {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-header-link:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Container */
.main-content {
  flex: 1;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  padding: 12px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.desktop-content {
  max-width: 1400px;
}

/* User Banner */
.officer-bar {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  width: 100%;
  box-sizing: border-box;
  gap: 10px;
  overflow: hidden;
}

.officer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.officer-avatar {
  width: 38px;
  height: 38px;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.officer-meta {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.officer-meta h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.officer-meta p {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge-csi {
  background: #fef3c7;
  color: #b45309;
}

.badge-si {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-hs {
  background: #f3e8ff;
  color: #7e22ce;
}

.officer-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon-text {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-icon-text:hover {
  background: #e2e8f0;
}

.btn-logout {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.btn-logout:hover {
  background: #fee2e2;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Card Styles */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Camera Capture Box */
.capture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

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

.camera-card {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
  text-align: center;
  position: relative;
  transition: all 0.2s;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}

.camera-card.captured {
  border-style: solid;
  border-color: var(--primary);
  background: #ffffff;
  padding: 6px;
}

.camera-card input[type="file"] {
  display: none;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

.plain-black-camera-icon {
  width: 44px;
  height: 44px;
  fill: #0f172a;
  display: block;
  margin: 0 auto 10px auto;
  transition: transform 0.2s ease;
}

.camera-card:hover .plain-black-camera-icon {
  transform: scale(1.06);
}

.camera-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 2px;
  text-align: center;
}

.camera-sublabel {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-align: center;
}

.btn-camera {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.2);
  transition: all 0.2s;
}

.btn-camera:hover {
  background: var(--primary-hover);
}

/* Live In-App Camera Viewfinder Modal */
.camera-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000000;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.camera-modal-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  background: #000;
}

.camera-modal-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10;
}

.btn-camera-close {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #ffffff;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-viewport-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-modal-controls {
  padding: 18px 24px;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.btn-camera-snap {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
}

.btn-camera-snap:active {
  transform: scale(0.92);
}

.btn-camera-snap-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffffff;
}

.btn-camera-flip, .btn-camera-fallback {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.preview-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 8px;
}

.preview-overlay {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 4px;
}

.preview-status {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-retake {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

/* GPS Box */
.gps-box {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

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

.gps-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.gps-pill.accurate {
  background: #dcfce7;
  color: #15803d;
}

.gps-pill.locating {
  background: #fef9c3;
  color: #a16207;
}

.gps-pill.error {
  background: #fee2e2;
  color: #b91c1c;
}

.gps-details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
  width: 100%;
  box-sizing: border-box;
}

.gps-item-wide {
  grid-column: span 2;
}

.gps-detail-item {
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.gps-detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.gps-detail-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

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

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

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

/* Submit Button */
.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
  color: #ffffff;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 6px -1px rgba(15, 118, 110, 0.3);
  transition: all 0.2s;
}

.btn-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #115e59 0%, #134e4a 100%);
  transform: translateY(-1px);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* History & Drilldown */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
}

.history-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.history-table tr.clickable {
  cursor: pointer;
  transition: background 0.15s;
}

.history-table tr.clickable:hover {
  background: #f8fafc;
}

.drilldown-panel {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
  border: 1px solid #e2e8f0;
}

.drilldown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}

.point-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

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

.point-photos {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.point-thumb {
  width: 70px;
  height: 70px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  transition: transform 0.15s;
}

.point-thumb:hover {
  transform: scale(1.05);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* Dashboard Specific Styles */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.kpi-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Filter Bar */
.filter-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: flex-end;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.btn-filter {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-excel {
  background: #15803d;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-excel:hover {
  background: #166534;
}

/* Data Table */
.data-table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #ffffff;
}

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

.data-table th {
  background: #f8fafc;
  padding: 12px 14px;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

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

.table-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid #cbd5e1;
  transition: transform 0.15s;
}

.table-thumb:hover {
  transform: scale(1.15);
}

/* Map Container */
#mapContainer {
  height: 600px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 20px;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.lightbox-caption {
  color: #fff;
  margin-top: 12px;
  font-size: 0.9rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  animation: toastIn 0.25s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

