/* ==========================================================================
   PestGuard Pro - Modern Mobile-First CSS with Dark & Light Mode Support
   ========================================================================== */

:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-elevated: #1e293b;
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);

  --secondary: #0ea5e9;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-purple: #8b5cf6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-color: #334155;
  --border-light: rgba(255, 255, 255, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.25);

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --nav-height: 64px;
  --header-height: 60px;
}

/* Light Mode Overrides */
body.light-mode {
  --bg-dark: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #e2e8f0;
  --bg-elevated: #ffffff;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --border-color: #cbd5e1;
  --border-light: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

body.light-mode .app-header {
  background-color: rgba(241, 245, 249, 0.95);
}

body.light-mode .bottom-nav {
  background-color: rgba(255, 255, 255, 0.98);
}

body.light-mode .status-chip {
  background-color: #ffffff;
}

body.light-mode .day-btn {
  background-color: #ffffff;
}

body.light-mode .question-item {
  background-color: #f8fafc;
}

body.light-mode .pest-option {
  background-color: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  user-select: none;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Container Structure */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 16px);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  transition: background-color 0.25s ease;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-pro {
  font-size: 10px;
  font-weight: 700;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-maps-icon {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #38bdf8;
  font-size: 18px;
  width: 36px;
  height: 36px;
}

.btn-maps-icon:hover {
  background: var(--secondary);
  color: #000;
}

.btn-install {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #000;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-glow);
}

/* Install Banner */
.install-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(14, 165, 233, 0.15));
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

/* Quick Status Bar */
.quick-status-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background-color: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-chip.highlight {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--primary);
  background-color: var(--primary-light);
}

/* App Main Content */
.app-content {
  flex: 1;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  padding: 16px;
}

/* Tab Management */
.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

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

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

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header h2 i {
  color: var(--primary);
}

/* Days Selector Scroll (Monday to Saturday) */
.days-selector-scroll {
  overflow-x: auto;
  margin: 0 -16px 16px -16px;
  padding: 0 16px 4px 16px;
  scrollbar-width: none;
}
.days-selector-scroll::-webkit-scrollbar { display: none; }

.days-selector {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 68px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.day-btn .day-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.day-btn .day-count {
  font-size: 10px;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-dark);
  color: var(--text-dim);
}

.day-btn.active {
  background: linear-gradient(135deg, var(--primary), #059669);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.day-btn.active .day-count {
  background: rgba(0,0,0,0.3);
  color: #ffffff;
}

.day-btn.sunday {
  opacity: 0.5;
  border-dash: 1px dashed var(--border-color);
}

/* Filter Pills */
.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pill.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Visit Cards List */
.visit-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.visit-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.visit-card:active {
  transform: scale(0.99);
}

.visit-card.completed {
  border-left: 4px solid var(--primary);
  opacity: 0.85;
}

.visit-card.in_progress {
  border-left: 4px solid var(--accent-warning);
}

.visit-card.pending {
  border-left: 4px solid var(--secondary);
}

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

.visit-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.type-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-dark);
  color: var(--text-muted);
}

.visit-card-body {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.visit-card-body i {
  width: 16px;
  color: var(--primary);
}

.visit-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Traps & Devices */
.traps-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.summary-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}

.summary-card i {
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--primary);
}

.summary-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.summary-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.devices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--primary);
  margin-right: 12px;
}

.device-details {
  flex: 1;
}

.device-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.device-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.device-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.status-ok { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-refilled { background: rgba(14, 165, 233, 0.2); color: #38bdf8; }
.status-pest { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-damaged { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Inspection Form Wizard */
.inspection-wizard-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.tab-subnav {
  display: flex;
  background-color: var(--bg-dark);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
}

.subtab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.subtab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
}

.inspection-form-area {
  display: none;
}
.inspection-form-area.active {
  display: block;
}

.question-item {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.question-text {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-main);
}

.options-group {
  display: flex;
  gap: 6px;
}

.opt-btn {
  flex: 1;
  padding: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.opt-btn.active-yes { background: rgba(239, 68, 68, 0.25); border-color: var(--accent-danger); color: #f87171; }
.opt-btn.active-no { background: rgba(16, 185, 129, 0.25); border-color: var(--primary); color: #34d399; }
.opt-btn.active-na { background: var(--bg-card-hover); color: var(--text-dim); }

.anomaly-badge-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 3px 8px;
  border-radius: 4px;
}

/* Report Type Selector Buttons */
.report-type-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.btn-report-type {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-report-type.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Pest Grid Selector in Modal */
.pest-grid-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.pest-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pest-option input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* Color Toolbar for Workplan Notes */
.workplan-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.btn-color-tag {
  border: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.tag-red { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #ef4444; }
.tag-yellow { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid #f59e0b; }
.tag-green { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }

.highlight-red { color: #f87171; font-weight: 800; background: rgba(239, 68, 68, 0.15); padding: 1px 4px; border-radius: 3px; }
.highlight-yellow { color: #fbbf24; font-weight: 800; background: rgba(245, 158, 11, 0.15); padding: 1px 4px; border-radius: 3px; }
.highlight-green { color: #34d399; font-weight: 800; background: rgba(16, 185, 129, 0.15); padding: 1px 4px; border-radius: 3px; }

.alert-info-box {
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.3);
  color: #38bdf8;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  margin-bottom: 16px;
}

/* Timer Section */
.timer-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px 16px;
  text-align: center;
}

.timer-battery-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.timer-presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
  flex-wrap: wrap;
}

.preset-btn {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.preset-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.timer-display-container {
  margin: 24px 0;
}

.timer-digits {
  font-size: 48px;
  font-weight: 800;
  font-family: monospace;
  color: var(--primary);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.timer-status {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.timer-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
}

.timer-info-footer {
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-control {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.flex-1 { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background-color: var(--primary); color: #000; }
.btn-success { background-color: var(--primary); color: #000; }
.btn-warning { background-color: var(--accent-warning); color: #000; }
.btn-danger { background-color: var(--accent-danger); color: #fff; }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-main); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background-color: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 999;
  max-width: 768px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  gap: 4px;
  cursor: pointer;
  padding: 6px 0;
}

.nav-item i { font-size: 18px; }

.nav-item.active {
  color: var(--primary);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 768px;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--text-main); }

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

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.hidden { display: none !important; }

/* PDF Paper Styling for Generation & Preview */
.pdf-report-paper {
  background-color: #ffffff;
  color: #1e293b;
  padding: 32px;
  font-family: Arial, sans-serif;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pdf-brand h2 { font-size: 22px; font-weight: 800; color: #0f172a; margin: 0; }
.pdf-brand p { font-size: 12px; color: #64748b; margin: 0; }

.pdf-date-box { font-size: 12px; text-align: right; color: #334155; }
.pdf-divider { border: 0; height: 2px; background: #e2e8f0; margin: 16px 0; }

.pdf-section { margin-bottom: 20px; }
.pdf-section h3 { font-size: 14px; font-weight: 700; color: #0f172a; border-bottom: 1px solid #cbd5e1; padding-bottom: 4px; margin-bottom: 8px; }

.pdf-table-info { width: 100%; border-collapse: collapse; font-size: 12px; }
.pdf-table-info td { padding: 4px 0; }

.pdf-data-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 8px; }
.pdf-data-table th, .pdf-data-table td { border: 1px solid #cbd5e1; padding: 6px; text-align: left; }
.pdf-data-table th { background-color: #f1f5f9; font-weight: 700; }

.pdf-notes-box { background-color: #f8fafc; border: 1px solid #e2e8f0; padding: 8px; font-size: 11px; border-radius: 4px; }
.pdf-footer-note { margin-top: 30px; font-size: 10px; color: #94a3b8; text-align: center; }
