/**
 * Zones Page Styles
 * Matching alpha/4 visual design
 */

/* CSS Variables (matching alpha/4) */
:root {
  --navy-blue: #1a2b66;
  --papyrus-gold: #f5e6d3;
  --papyrus-light: #faf3e8;
  --papyrus-medium: #f0ddc0;
  --green-grade: #71B956;
  --orange-grade: #E67234;
  --red-grade: #D63B3B;
  --header-height: 60px;
  --bottom-nav-height: 70px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  /* Disable double-tap zoom on iOS */
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: #f5f5f7;
  min-height: 100vh;
  overflow-x: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  /* Disable double-tap zoom */
  touch-action: manipulation;
}

/* Fixed Header (matching alpha/4) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  background: var(--navy-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 15px;
  padding-right: 15px;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.app-logo {
  height: 32px;
  width: auto;
}

.app-badge {
  background: rgba(245, 230, 211, 0.2);
  color: var(--papyrus-gold);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.network-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.network-badge.online {
  background: rgba(113, 185, 86, 0.2);
  color: #71B956;
}

/* =============================================================================
   Main Content Area
   ============================================================================= */

.app-content {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-area-top));
  left: 0;
  right: 0;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: #f5f5f7;
}

.tab-content {
  display: none;
  min-height: 100%;
  padding-bottom: 20px;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* =============================================================================
   Zone Selection Grid (matching alpha/4 area-grid)
   ============================================================================= */

.area-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 15px;
}

.area-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease-out;
  position: relative;
  min-height: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--navy-blue); /* Fix white-on-white text issue */
}

.area-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.area-card:active {
  transform: scale(0.98);
}

.area-card.active {
  background: var(--navy-blue);
  color: white;
}

.area-card.completed {
  background: var(--green-grade);
  color: white;
}

.area-card.needs-more {
  background: #fef3c7;
  color: #92400e;
  border: 2px solid #f59e0b;
}

.area-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
  color: var(--navy-blue); /* Ensure icon is visible */
}

.area-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.area-count {
  font-size: 11px;
  opacity: 0.8;
}

/* =============================================================================
   Camera View (for photo capture)
   ============================================================================= */

.camera-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--navy-blue);
  z-index: 1000;
}

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

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Camera Counter Overlay */
.camera-counter-overlay {
  position: absolute;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 20px);
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  padding: 15px;
  border-radius: 12px;
  text-align: center;
  min-width: 120px;
  z-index: 1001;
}

.counter-area-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.counter-number {
  font-size: 48px;
  font-weight: 700;
  color: white;
  line-height: 1;
  margin-bottom: 4px;
}

.counter-min-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.counter-status-badge {
  background: rgba(113, 185, 86, 0.2);
  color: var(--green-grade);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.counter-status-badge.complete {
  background: rgba(113, 185, 86, 0.3);
}

.counter-status-badge.needs-more {
  background: rgba(230, 114, 52, 0.2);
  color: var(--orange-grade);
}

/* Camera Controls */
.camera-controls {
  position: absolute;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 20px); /* Position above bottom nav */
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 0 20px;
  z-index: 1001;
}

.camera-controls button {
  flex: 1;
  max-width: 200px;
  padding: 16px 24px;
  border: none;
  border-radius: 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.camera-controls button:active {
  transform: scale(0.95);
}

.btn-success {
  background: var(--green-grade);
  color: white;
}

.btn-upload {
  background: var(--papyrus-gold);
  color: var(--navy-blue);
}

.btn-danger {
  background: var(--red-grade);
  color: white;
}

/* =============================================================================
   Bottom Navigation (matching alpha/4)
   ============================================================================= */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  text-decoration: none;
  color: #8e8e93;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-item i {
  font-size: 24px;
  margin-bottom: 4px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 500;
}

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

.nav-item.active i {
  color: var(--navy-blue);
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(20px);
  background: #D63B3B;
  color: white;
  font-size: 10px;
  font-weight: bold;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  z-index: 10;
}

.nav-badge.hidden {
  display: none;
}

/* Reports Badge (red/orange for high visibility) - Worker A1 */
.reports-badge {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  transform: translateX(20px);
}

/* =============================================================================
   Queue Tab
   ============================================================================= */

.queue-list {
  padding: 20px;
}

.queue-item {
  background: white; /* Solid white background for light theme */
  border: 1px solid rgba(26, 43, 102, 0.1); /* Navy border */
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Add subtle shadow */
}

.queue-item-icon {
  font-size: 24px;
  color: var(--navy-blue); /* Dark icon for visibility */
}

.queue-item-info {
  flex: 1;
}

.queue-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-blue); /* Dark text for visibility */
  margin-bottom: 4px;
}

.queue-item-status {
  font-size: 12px;
  color: rgba(26, 43, 102, 0.6); /* Dark text with transparency */
}

.queue-item-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.queue-item-progress-bar {
  height: 100%;
  background: var(--green-grade);
  transition: width 0.3s;
}

.queue-item.uploading .queue-item-progress-bar {
  background: var(--papyrus-gold);
}

.queue-item.failed .queue-item-progress-bar {
  background: var(--red-grade);
}

/* =============================================================================
   Gallery Tab
   ============================================================================= */

.gallery-section {
  padding: 20px;
}

.gallery-zone {
  margin-bottom: 30px;
}

.gallery-zone-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy-blue); /* Dark text for visibility on light background */
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.gallery-photo {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: transform 0.2s;
}

.gallery-photo:active {
  transform: scale(0.95);
}

.gallery-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =============================================================================
   Status Messages (matching alpha/4)
   ============================================================================= */

.status-message {
  margin: 15px;
  padding: 12px 15px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.status-message.info {
  background: rgba(33, 150, 243, 0.1);
  border-left: 4px solid #2196f3;
  color: #1976d2;
}

.status-message.error {
  background: rgba(214, 59, 59, 0.1);
  border-left: 4px solid #D63B3B;
  color: #D63B3B;
}

.status-message i {
  font-size: 16px;
}

/* =============================================================================
   Empty States
   ============================================================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: rgba(26, 43, 102, 0.5); /* Dark text with transparency */
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.4; /* Slightly more transparent for subtlety */
  color: var(--navy-blue); /* Dark icon */
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: rgba(26, 43, 102, 0.8); /* Dark text for visibility */
  margin-bottom: 8px;
}

.empty-message {
  font-size: 14px;
  max-width: 300px;
  color: rgba(26, 43, 102, 0.6); /* Dark text with transparency */
}

/* =============================================================================
   SSE Connection Status Badge (Worker 1A)
   ============================================================================= */

.sse-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  margin: 12px 16px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sse-status-badge i {
  font-size: 14px;
}

.sse-status-badge.connected {
  background-color: #e8f5e9;
  color: var(--green-grade);
  border: 1px solid var(--green-grade);
}

.sse-status-badge.connecting {
  background-color: #fff3e0;
  color: var(--orange-grade);
  border: 1px solid var(--orange-grade);
}

.sse-status-badge.disconnected {
  background-color: #ffebee;
  color: var(--red-grade);
  border: 1px solid var(--red-grade);
}

/* =============================================================================
   Utilities
   ============================================================================= */

.hidden {
  display: none !important;
}

.tab-content {
  display: none;
}

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

/* =============================================================================
   Draft Report Link Styles (UC-504)
   ============================================================================= */

.draft-report-link {
  margin: 20px 16px;
  padding: 20px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #0ea5e9;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.report-ready-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--green-grade);
  color: white;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(113, 185, 86, 0.3);
}

.report-ready-badge i {
  font-size: 16px;
  animation: pulse-check 2s ease-in-out infinite;
}

@keyframes pulse-check {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.btn-report-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-report-view:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.btn-report-view:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-report-view i:first-child {
  font-size: 18px;
}

.btn-report-view i:last-child {
  font-size: 14px;
  margin-left: auto;
}

.draft-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}

.draft-note i {
  font-size: 14px;
  color: #0ea5e9;
  flex-shrink: 0;
}

/* Reports Tab Content Padding */
.report-section {
  padding-bottom: 20px;
}

.report-processing {
  padding: 16px;
}

.report-processing-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  margin-bottom: 16px;
}

.report-processing-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

/* ================================================
   Worker C2: Report Complete Banner & Final State
   ================================================ */

/* Report Complete Container */
.report-complete {
  padding: 20px 16px;
}

/* Report Complete Banner */
.report-complete-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border: 2px solid var(--green-grade);
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(113, 185, 86, 0.2);
}

.report-complete-banner i {
  font-size: 48px;
  color: var(--green-grade);
  animation: bounce-in 0.6s ease-out;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.report-complete-banner h3 {
  font-size: 20px;
  font-weight: 700;
  color: #166534;
  margin: 0 0 4px 0;
}

.completion-time {
  font-size: 13px;
  color: #15803d;
  margin: 0;
}

/* Report Actions */
.report-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-report-final,
.btn-download,
.btn-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-report-final {
  background: linear-gradient(135deg, var(--green-grade) 0%, #5a9a42 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(113, 185, 86, 0.3);
}

.btn-report-final:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(113, 185, 86, 0.4);
}

.btn-download {
  background: white;
  color: var(--navy-blue);
  border: 2px solid #e2e8f0;
}

.btn-download:hover {
  background: #f8fafc;
  border-color: var(--navy-blue);
}

.btn-share {
  background: white;
  color: #0ea5e9;
  border: 2px solid #e0f2fe;
}

.btn-share:hover {
  background: #f0f9ff;
  border-color: #0ea5e9;
}

/* Report Summary */
.report-summary {
  padding: 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-label {
  font-size: 14px;
  color: #64748b;
}

.summary-value {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.summary-value.grade-A,
.summary-value.grade-B {
  color: var(--green-grade);
}

.summary-value.grade-C {
  color: var(--orange-grade);
}

.summary-value.grade-D,
.summary-value.grade-F {
  color: var(--red-grade);
}
