/**
 * LandmanAssistant Theme - Land Management Tech Refined
 *
 * "AI That Understands the Land"
 *
 * Color Philosophy:
 * - Deep charcoal base (surveyor's precision)
 * - Warm copper/amber accents (minerals, oil, deeds)
 * - Sophisticated and authoritative
 */

:root {
  /* ============================================
     PRIMARY BRAND COLORS
     ============================================ */
  /* Emerald/Teal - Nature/Land/Growth */
  --primary: #14b8a6;
  --primary-hover: #0d9488;
  --primary-light: #ccfbf1;
  --primary-dark: #0f766e;

  /* Warm Copper - Minerals/Oil/Legal Documents */
  --secondary: #d97706;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-light: #fef3c7;

  /* ============================================
     NEUTRALS - WARM SOPHISTICATED PALETTE
     ============================================ */
  --background: #fdfcfa;
  --surface: #ffffff;
  --text-primary: #1f242e;
  --text-secondary: #5d6575;
  --text-muted: #8790a2;
  --border: #e0e4e8;
  --border-light: #f0f2f5;

  /* ============================================
     STATUS COLORS
     ============================================ */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #4a90d9;
  --info-light: #dbeafe;

  /* ============================================
     SHADOWS - REFINED & LAYERED
     ============================================ */
  --shadow-sm: 0 1px 2px rgba(10, 13, 18, 0.06), 0 1px 3px rgba(10, 13, 18, 0.1);
  --shadow: 0 4px 6px rgba(10, 13, 18, 0.07), 0 2px 4px rgba(10, 13, 18, 0.06);
  --shadow-md: 0 6px 8px rgba(10, 13, 18, 0.08), 0 3px 5px rgba(10, 13, 18, 0.05);
  --shadow-lg: 0 10px 15px rgba(10, 13, 18, 0.1), 0 4px 6px rgba(10, 13, 18, 0.05);
  --shadow-xl: 0 20px 25px rgba(10, 13, 18, 0.15), 0 10px 10px rgba(10, 13, 18, 0.04);
  --shadow-2xl: 0 25px 50px rgba(10, 13, 18, 0.25);
  --shadow-hover: 0 12px 20px rgba(10, 13, 18, 0.15), 0 6px 8px rgba(10, 13, 18, 0.08);

  /* ============================================
     BORDER RADIUS
     ============================================ */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* ============================================
     SPACING SCALE
     ============================================ */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* ============================================
     TYPOGRAPHY
     ============================================ */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

  /* Font sizes - refined scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  /* ============================================
     TRANSITIONS
     ============================================ */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ============================================
     LEGACY COMPATIBILITY MAPPINGS
     (For backward compatibility with old code)
     ============================================ */
  --primary-blue: #4a90d9;
  --secondary-blue: #0d9488;
  --accent-red: #d97706;
  --white: #ffffff;
  --gray: #f9f7f4;
  --light-gray: #f0f2f5;
  --dark-gray: #1f242e;
  --text-gray: #5d6575;
}

/* ============================================
   BASE ELEMENT STYLING
   ============================================ */
body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-primary { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary) !important; }
.bg-accent { background-color: var(--accent) !important; }
.bg-surface { background-color: var(--surface) !important; }
.bg-background { background-color: var(--background) !important; }

.border-primary { border-color: var(--primary) !important; }
.border-accent { border-color: var(--accent) !important; }

.hover\:bg-primary-hover:hover { background-color: var(--primary-hover) !important; }
.hover\:bg-accent-hover:hover { background-color: var(--accent-hover) !important; }

/* ============================================
   THEMED COMPONENTS
   ============================================ */

/* Card styling */
.card-themed {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-lg);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.card-themed:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

/* Input styling */
.input-themed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

.input-themed:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   AERIAL HERO SECTION - IMPROVED
   ============================================ */

.hero-aerial {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--color-slate-900);
  display: flex;
  align-items: center;
}

/* Aerial imagery layer */
.aerial-background {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.aerial-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.65) contrast(1.15) saturate(0.9);
}

/* Sophisticated dark overlay with gradient */
.aerial-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.88) 0%,
    rgba(31, 36, 46, 0.82) 40%,
    rgba(21, 24, 33, 0.92) 100%
  );
  z-index: 2;
}

/* Survey grid pattern overlay */
.grid-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='surveygrid' width='100' height='100' patternUnits='userSpaceOnUse'%3E%3Cpath d='M 100 0 L 0 0 0 100' fill='none' stroke='rgba(217,119,6,0.12)' stroke-width='0.5'/%3E%3C/pattern%3E%3C/defs%3E%3Crect fill='url(%23surveygrid)' width='100' height='100'/%3E%3C/svg%3E");
  opacity: 0.5;
  animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.7; }
}

/* Deed plot tract overlay - right side */
.tract-overlay {
  position: absolute;
  top: 50%;
  right: 8%;
  width: 360px;
  height: 360px;
  transform: translateY(-50%);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  animation: tractFadeIn 1.2s ease-out 0.8s forwards;
}

@keyframes tractFadeIn {
  from {
    opacity: 0;
    transform: translateY(-50%) scale(0.85) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) scale(1) rotate(0deg);
  }
}

/* SVG deed plot animation */
.tract-boundary {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: drawTract 2.5s ease-out 1.5s forwards;
}

@keyframes drawTract {
  to { stroke-dashoffset: 0; }
}

.corner-marker {
  opacity: 0;
  transform-origin: center;
  animation: markerPop 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}

.corner-marker:nth-child(3) { animation-delay: 3.8s; }
.corner-marker:nth-child(4) { animation-delay: 4s; }
.corner-marker:nth-child(5) { animation-delay: 4.2s; }
.corner-marker:nth-child(6) { animation-delay: 4.4s; }

@keyframes markerPop {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  60% {
    transform: scale(1.3);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.measurement-line {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: drawLine 1s ease-out 4.6s forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* Hero content - text on left */
.hero-content-aerial {
  position: relative;
  z-index: 10;
  max-width: 700px;
  padding: 2.5rem 0;
  animation: heroContentFadeIn 0.9s ease-out;
}

@keyframes heroContentFadeIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.hero-title-aerial {
  font-family: var(--font-display);
  font-size: 4.25rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 1.5rem;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.hero-title-aerial span {
  background: linear-gradient(135deg, var(--color-copper-300), var(--color-copper-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle-aerial {
  font-size: 1.375rem;
  color: rgba(203, 213, 225, 0.95);
  margin-bottom: 2.5rem;
  line-height: 1.6;
  max-width: 600px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  font-weight: 400;
}

.hero-buttons-aerial {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.hero-cta {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  padding: 1.125rem 2.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: white;
  box-shadow: 0 12px 32px rgba(20, 184, 166, 0.35);
  transition: all var(--transition);
  border-radius: 8px;
}

.hero-cta:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(20, 184, 166, 0.5);
  color: white;
}

.btn-outline-light {
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  padding: 1rem 2rem;
  font-weight: 600;
  border-radius: 8px;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.6);
  color: #ffffff;
}

/* Feature pills - modern tags */
.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin-bottom: 2rem;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1.25rem;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2rem;
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
}

.feature-pill:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.feature-pill i {
  color: var(--color-copper-300);
}

/* AI agent callout */
.ai-agent-callout {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1.75rem 2rem;
  display: flex;
  gap: 1.25rem;
  max-width: 600px;
  box-shadow: var(--shadow-xl);
}

.callout-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.4);
}

.callout-content h4 {
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.625rem;
  font-weight: 600;
}

.callout-content p {
  color: rgba(203, 213, 225, 0.9);
  font-size: 0.9375rem;
  margin: 0;
  line-height: 1.6;
}

/* ============================================
   DEED PLOT CARD - TRANSPARENT ON AERIAL
   ============================================ */
.deed-plot-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  box-shadow: var(--shadow-2xl);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
  max-width: 420px;
}

.card-header-animated {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  padding: 1.125rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-weight: 600;
  font-size: 1.0625rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.status-badge {
  margin-left: auto;
  background: rgba(16, 185, 129, 0.25);
  color: #10b981;
  padding: 0.375rem 0.875rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(16, 185, 129, 0.4);
  text-transform: uppercase;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.02);
  }
}

.card-body-animated {
  padding: 2rem 1.75rem;
  background: rgba(255, 255, 255, 0.6);
}

/* Workflow steps - elegant checklist */
.workflow-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-slate-800);
  border: 1px solid rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateX(20px);
  animation: slideInCheck 0.5s ease-out forwards;
}

.workflow-step.complete i {
  color: var(--primary);
  font-size: 1.25rem;
}

.workflow-step:nth-child(1) { animation-delay: 1.2s; }
.workflow-step:nth-child(2) { animation-delay: 1.4s; }
.workflow-step:nth-child(3) { animation-delay: 1.6s; }
.workflow-step:nth-child(4) { animation-delay: 1.8s; }

@keyframes slideInCheck {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Export section */
.export-section {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.export-button {
  width: 100%;
  padding: 1.125rem 1.75rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.0625rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  transition: all var(--transition);
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.35);
}

.export-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(20, 184, 166, 0.5);
}

.export-button i {
  font-size: 1.375rem;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 991px) {
  .hero-title-aerial {
    font-size: 3.25rem;
  }

  .hero-subtitle-aerial {
    font-size: 1.1875rem;
  }

  .tract-overlay {
    width: 280px;
    height: 280px;
    right: 5%;
  }
}

@media (max-width: 768px) {
  .hero-title-aerial {
    font-size: 2.5rem;
  }

  .hero-subtitle-aerial {
    font-size: 1.0625rem;
  }

  .hero-buttons-aerial {
    flex-direction: column;
  }

  .tract-overlay {
    width: 200px;
    height: 200px;
    right: 50%;
    top: auto;
    bottom: 15%;
    transform: translateX(50%);
    opacity: 0.6;
  }

  .deed-plot-card {
    margin-top: 3rem;
  }
}

@media (max-width: 576px) {
  .hero-title-aerial {
    font-size: 2rem;
  }

  .tract-overlay {
    display: none;
  }

  .ai-agent-callout {
    padding: 1.25rem 1.5rem;
  }
}

/* ============================================
   INDEX PAGE OVERRIDES - READABILITY FIXES
   ============================================ */

/* Services Overview Section - Fix title and card readability */
.services-overview {
  background: var(--background) !important;
}

.services-overview .section-title {
  color: var(--text-primary) !important;
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
}

.services-overview .service-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

.services-overview .service-card h3 {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.services-overview .service-card p {
  color: var(--text-secondary) !important;
}

.services-overview .service-icon {
  color: var(--primary) !important;
}

.services-overview .service-link {
  color: var(--primary) !important;
  font-weight: 600 !important;
}

.services-overview .service-link:hover {
  color: var(--primary-hover) !important;
}

/* Technology Section - Fix AI demo card readability */
.technology-section {
  background: var(--surface) !important;
}

.technology-section h2 {
  color: var(--text-primary) !important;
  font-family: var(--font-display) !important;
}

.technology-section p,
.technology-section li {
  color: var(--text-secondary) !important;
}

.ai-demo-card {
  background: var(--background) !important;
  border: 1px solid var(--border) !important;
}

.ai-demo-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  color: #ffffff !important;
}

.ai-demo-chat .demo-message.user {
  background: var(--primary-light) !important;
  color: var(--text-primary) !important;
}

.ai-demo-chat .demo-message.ai {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
}

/* ============================================
   EDIT TOOL PANEL - OVERRIDE DARK THEME FOR READABILITY
   ============================================ */

/* Override CAD dark theme with landmanassistant light theme */
.edit-panel-draggable,
.floating-panel {
  /* Override dark backgrounds with light ones */
  --cad-bg-dark: #f8f9fa !important;
  --cad-bg-panel: #ffffff !important;
  --cad-bg-surface: #f8f9fa !important;
  --cad-bg-input: #ffffff !important;
  --cad-bg-hover: #e9ecef !important;
  --cad-bg-active: var(--primary) !important;

  /* Override borders */
  --cad-border: var(--border) !important;
  --cad-border-light: var(--border) !important;
  --cad-border-active: var(--primary) !important;

  /* Override text colors with dark readable text */
  --cad-text-primary: var(--text-primary) !important;
  --cad-text-secondary: var(--text-secondary) !important;
  --cad-text-muted: var(--text-muted) !important;
  --cad-text-accent: var(--primary) !important;

  /* Override accent colors */
  --cad-accent-blue: var(--primary) !important;
  --cad-accent-orange: var(--accent) !important;
  --cad-accent-green: var(--success) !important;
  --cad-accent-red: var(--error) !important;
  --cad-accent-teal: var(--primary) !important;
}

/* Panel backgrounds */
.edit-panel-draggable,
.floating-panel.edit-panel-draggable {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

/* Panel header */
.edit-panel-draggable .panel-header,
.floating-panel .panel-header {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

.edit-panel-draggable .panel-title,
.floating-panel .panel-title {
  color: var(--text-primary) !important;
}

/* Panel content area */
.edit-panel-draggable .panel-content,
.floating-panel .panel-content {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

/* Form labels and text */
.edit-panel-draggable .form-label,
.floating-panel .form-label {
  color: var(--text-secondary) !important;
}

/* Form inputs - CRITICAL FIX */
.edit-panel-draggable .form-select,
.edit-panel-draggable .form-input,
.floating-panel .form-select,
.floating-panel .form-input {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important; /* Fix white text to dark */
}

.edit-panel-draggable .form-select:focus,
.edit-panel-draggable .form-input:focus,
.floating-panel .form-select:focus,
.floating-panel .form-input:focus {
  background: var(--surface) !important;
  border-color: var(--primary) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 0 2px var(--primary-light) !important;
}

.edit-panel-draggable .form-select option,
.floating-panel .form-select option {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

/* Edit mode toolbar */
.edit-panel-draggable .edit-mode-toolbar,
.floating-panel .edit-mode-toolbar {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .edit-mode-button,
.floating-panel .edit-mode-button {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .edit-mode-button:hover:not(:disabled),
.floating-panel .edit-mode-button:hover:not(:disabled) {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

.edit-panel-draggable .edit-mode-button.active,
.floating-panel .edit-mode-button.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

/* Tool grids and buttons */
.edit-panel-draggable .cad-tool-grid,
.floating-panel .cad-tool-grid {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .cad-tool-btn,
.floating-panel .cad-tool-btn {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .cad-tool-btn:hover:not(:disabled),
.floating-panel .cad-tool-btn:hover:not(:disabled) {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

.edit-panel-draggable .cad-tool-btn.active,
.floating-panel .cad-tool-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

/* Tool group titles */
.edit-panel-draggable .tool-group-title,
.floating-panel .tool-group-title {
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}

/* Geometry tools panel */
.edit-panel-draggable .geometry-tools-panel,
.floating-panel .geometry-tools-panel {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .geometry-tools-title,
.floating-panel .geometry-tools-title {
  color: var(--text-primary) !important;
}

.edit-panel-draggable .geo-tool-btn,
.floating-panel .geo-tool-btn {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .geo-tool-btn:hover:not(:disabled),
.floating-panel .geo-tool-btn:hover:not(:disabled) {
  background: var(--background) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent) !important;
}

.edit-panel-draggable .geo-tool-btn.active,
.floating-panel .geo-tool-btn.active {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: white !important;
}

/* Vertex tools */
.edit-panel-draggable .vertex-tools-panel,
.floating-panel .vertex-tools-panel {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .vertex-tools-title,
.floating-panel .vertex-tools-title {
  color: var(--text-primary) !important;
}

.edit-panel-draggable .vertex-tool-btn,
.floating-panel .vertex-tool-btn {
  background: var(--surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .vertex-tool-btn:hover:not(:disabled),
.floating-panel .vertex-tool-btn:hover:not(:disabled) {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

/* Precision panel */
.edit-panel-draggable .precision-panel,
.floating-panel .precision-panel {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .precision-title,
.floating-panel .precision-title {
  color: var(--text-secondary) !important;
}

.edit-panel-draggable .precision-input-label,
.floating-panel .precision-input-label {
  color: var(--text-muted) !important;
}

.edit-panel-draggable .precision-input,
.floating-panel .precision-input {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--success) !important;
}

/* Snapping options */
.edit-panel-draggable .snap-options-panel,
.floating-panel .snap-options-panel {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .snap-title,
.floating-panel .snap-title {
  color: var(--text-primary) !important;
}

.edit-panel-draggable .snap-layer-item,
.floating-panel .snap-layer-item {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .snap-layer-item:hover,
.floating-panel .snap-layer-item:hover {
  background: var(--background) !important;
}

.edit-panel-draggable .snap-layer-name,
.floating-panel .snap-layer-name {
  color: var(--text-primary) !important;
}

/* Form sections */
.edit-panel-draggable .form-section,
.floating-panel .form-section {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .section-title,
.floating-panel .section-title {
  color: var(--text-primary) !important;
}

/* Details/collapsible sections */
.edit-panel-draggable details,
.floating-panel details {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable details summary,
.floating-panel details summary {
  color: var(--text-secondary) !important;
}

.edit-panel-draggable details summary:hover,
.floating-panel details summary:hover {
  color: var(--text-primary) !important;
}

.edit-panel-draggable details[open] summary,
.floating-panel details[open] summary {
  color: var(--text-primary) !important;
}

/* Instructions box */
.edit-panel-draggable .instructions-box,
.floating-panel .instructions-box {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}

.edit-panel-draggable .instructions-box p,
.floating-panel .instructions-box p {
  color: var(--text-primary) !important;
}

.edit-panel-draggable .shortcut-item,
.floating-panel .shortcut-item {
  color: var(--text-secondary) !important;
}

.edit-panel-draggable .shortcut-key,
.floating-panel .shortcut-key {
  background: var(--background) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Message boxes */
.edit-panel-draggable .message-success,
.floating-panel .message-success {
  background: var(--success-light) !important;
  border-color: var(--success) !important;
  color: #155724 !important;
}

.edit-panel-draggable .message-error,
.floating-panel .message-error {
  background: var(--error-light) !important;
  border-color: var(--error) !important;
  color: #721c24 !important;
}

.edit-panel-draggable .message-warning,
.floating-panel .message-warning {
  background: var(--warning-light) !important;
  border-color: var(--warning) !important;
  color: #856404 !important;
}

.edit-panel-draggable .message-info,
.floating-panel .message-info {
  background: var(--info-light) !important;
  border-color: var(--info) !important;
  color: #0c5460 !important;
}

/* Action buttons */
.edit-panel-draggable .btn-success,
.floating-panel .btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: white !important;
}

.edit-panel-draggable .btn-primary,
.floating-panel .btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

.edit-panel-draggable .btn-secondary,
.floating-panel .btn-secondary {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

.edit-panel-draggable .btn-danger,
.floating-panel .btn-danger {
  background: var(--error) !important;
  border-color: var(--error) !important;
  color: white !important;
}

/* Status indicator */
.edit-panel-draggable .status-indicator,
.floating-panel .status-indicator {
  background: var(--background) !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}

/* Selected feature info */
.edit-panel-draggable .selected-feature-info,
.floating-panel .selected-feature-info {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
}

/* Symbology picker */
.edit-panel-draggable .symbology-presets-label,
.edit-panel-draggable .symbology-custom-label,
.floating-panel .symbology-presets-label,
.floating-panel .symbology-custom-label {
  color: var(--text-muted) !important;
}

.edit-panel-draggable .symbology-preset-btn,
.floating-panel .symbology-preset-btn {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .symbology-preset-btn:hover,
.floating-panel .symbology-preset-btn:hover {
  background: var(--background) !important;
}

.edit-panel-draggable .preset-name,
.floating-panel .preset-name {
  color: var(--text-primary) !important;
}

.edit-panel-draggable .symbology-control-label,
.floating-panel .symbology-control-label {
  color: var(--text-secondary) !important;
}

.edit-panel-draggable .color-picker-wrapper,
.floating-panel .color-picker-wrapper {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

.edit-panel-draggable .color-picker-value,
.floating-panel .color-picker-value {
  color: var(--text-secondary) !important;
}

/* Coordinates bar */
.edit-panel-draggable .coordinates-bar,
.floating-panel .coordinates-bar {
  background: var(--background) !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}

.edit-panel-draggable .coord-label,
.floating-panel .coord-label {
  color: var(--text-muted) !important;
}

.edit-panel-draggable .coord-value,
.floating-panel .coord-value {
  color: var(--success) !important;
}

/* Scrollbar customization */
.edit-panel-draggable .panel-content::-webkit-scrollbar-track,
.floating-panel .panel-content::-webkit-scrollbar-track {
  background: var(--background) !important;
}

.edit-panel-draggable .panel-content::-webkit-scrollbar-thumb,
.floating-panel .panel-content::-webkit-scrollbar-thumb {
  background: var(--border) !important;
}

.edit-panel-draggable .panel-content::-webkit-scrollbar-thumb:hover,
.floating-panel .panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted) !important;
}

/* ============================================
   COMPREHENSIVE APP-WIDE READABILITY FIXES
   ============================================ */

/* Unified Edit Widget */
.unified-edit-panel {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.unified-panel-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  color: white !important;
}

.unified-panel-body {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.unified-panel-body .layer-selector label,
.unified-panel-body .tool-group h6 {
  color: var(--text-secondary) !important;
}

.unified-panel-body .layer-selector select,
.unified-panel-body input,
.unified-panel-body textarea {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Map Layers Panel */
.layers-panel,
.map-layers-panel {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.layers-panel .panel-header,
.map-layers-panel .panel-header {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

.layers-panel label,
.map-layers-panel label {
  color: var(--text-primary) !important;
}

.layers-panel input,
.layers-panel select,
.map-layers-panel input,
.map-layers-panel select {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* COGO Panel */
.cogo-panel-right,
#cogo-panel {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.cogo-panel-right .cogo-header,
#cogo-panel .cogo-header {
  background: linear-gradient(135deg, var(--success), var(--primary)) !important;
  color: white !important;
}

.cogo-panel-right .cogo-instructions,
#cogo-panel .cogo-instructions {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

.cogo-panel-right #cogoTextarea,
#cogo-panel #cogo-calls {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

.cogo-panel-right .cogo-info,
#cogo-panel .cogo-info {
  background: var(--background) !important;
  color: var(--text-secondary) !important;
}

/* Map Toolbar */
.map-toolbar {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.map-toolbar button {
  color: var(--text-primary) !important;
}

.map-toolbar button:hover {
  background: var(--background) !important;
}

.map-toolbar button.active {
  background: var(--primary) !important;
  color: white !important;
}

/* Map Menu */
.map-menu {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.map-menu-item {
  color: var(--text-primary) !important;
}

.map-menu-item:hover {
  background: var(--background) !important;
}

/* Feature Info Popup */
.feature-popup,
.feature-info-popup {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.feature-popup .popup-header,
.feature-info-popup .popup-header {
  background: var(--primary) !important;
  color: white !important;
}

.feature-popup .popup-content,
.feature-info-popup .popup-content {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.feature-popup .property-key,
.feature-info-popup .property-key {
  color: var(--text-secondary) !important;
}

.feature-popup .property-value,
.feature-info-popup .property-value {
  color: var(--text-primary) !important;
}

/* Map AI Assistant */
.map-ai-assistant {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.map-ai-assistant .ai-header {
  background: var(--primary) !important;
  color: white !important;
}

.map-ai-assistant input,
.map-ai-assistant textarea {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Table Drawer */
.table-drawer {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.table-drawer th {
  background: var(--background) !important;
  color: var(--text-primary) !important;
}

.table-drawer td {
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

/* Basemap Selector */
.basemap-selector,
.basemap-panel {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.basemap-option {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.basemap-option:hover {
  background: var(--background) !important;
}

.basemap-name {
  color: var(--text-primary) !important;
}

/* Search Tool */
.search-panel,
.map-search {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.search-panel input,
.map-search input {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

.search-panel .search-result,
.map-search .search-result {
  color: var(--text-primary) !important;
}

.search-panel .search-result:hover,
.map-search .search-result:hover {
  background: var(--background) !important;
}

/* Measurement Tool */
.measurement-panel,
.map-measure {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.measurement-panel label,
.map-measure label {
  color: var(--text-secondary) !important;
}

.measurement-panel input,
.measurement-panel select,
.map-measure input,
.map-measure select {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

/* Drawing Tool */
.drawing-panel,
.map-draw {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.drawing-panel button,
.map-draw button {
  color: var(--text-primary) !important;
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.drawing-panel button:hover,
.map-draw button:hover {
  background: var(--background) !important;
}

.drawing-panel button.active,
.map-draw button.active {
  background: var(--primary) !important;
  color: white !important;
}

/* Modals */
.modal,
.map-modal {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.modal-header {
  background: var(--background) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.modal-body {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.modal-footer {
  background: var(--background) !important;
  border-color: var(--border) !important;
}

/* General panel overrides */
.panel,
.widget-panel,
.tool-panel {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

.panel-header,
.widget-header,
.tool-header {
  background: var(--background) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

/* General button overrides */
button,
.btn {
  color: var(--text-primary) !important;
}

button.btn-primary,
.btn-primary {
  background: var(--primary) !important;
  color: white !important;
}

button.btn-secondary,
.btn-secondary {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

button.btn-success,
.btn-success {
  background: var(--success) !important;
  color: white !important;
}

button.btn-danger,
.btn-danger {
  background: var(--error) !important;
  color: white !important;
}

/* General input/select overrides */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}

input:focus:not([type="checkbox"]):not([type="radio"]),
select:focus,
textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-light) !important;
}

/* Select dropdowns */
select option {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}

/* Labels */
label {
  color: var(--text-primary) !important;
}

/* General text classes */
.text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}
