:root {
  --primary: #228B22;
  --primary-dark: #1a6b1a;
  --secondary: #8B7355;
  --background: #FFFEF5;
  --accent: #87CEEB;
  --red: #E74C3C;
  --green: #27AE60;
  --blue: #3498DB;
  --orange: #E67E22;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --shadow: rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background: linear-gradient(180deg, #E8F4FD 0%, var(--background) 30%);
  min-height: 100vh;
  color: var(--text);
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #1a5f1a 100%);
  padding: 1.5rem 2rem;
  color: white;
  box-shadow: 0 4px 20px var(--shadow);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 300;
  margin-top: 0.25rem;
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.tab-switcher {
  display: none;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--primary);
  background: white;
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.panels-container {
  display: grid;
  grid-template-columns: 1fr 1.5fr 280px;
  gap: 1.5rem;
}

.panel {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 24px var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(139, 115, 85, 0.1);
}

.panel-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: linear-gradient(180deg, #FAFAFA 0%, white 100%);
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* Search Bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.search-bar input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid #E0E0E0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-btn {
  padding: 0.6rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.1s, background 0.2s;
}

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

.search-btn:active {
  transform: scale(0.95);
}

/* Map Panel */
.map-container {
  height: 350px;
  background: #f0f0f0;
}

.map-info {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #F8F9FA;
  font-size: 0.8rem;
  color: var(--text-light);
  font-family: 'JetBrains Mono', monospace;
}

.capture-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, #1a6b1a 100%);
  color: white;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.capture-btn:hover {
  box-shadow: 0 4px 12px rgba(34, 139, 34, 0.3);
}

.capture-btn:active {
  transform: scale(0.98);
}

/* Design Panel */
.design-panel {
  display: flex;
  flex-direction: column;
}

.design-workspace {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.image-preview-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f5;
  aspect-ratio: 1;
  max-height: 400px;
}

.annotation-canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.captured-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.text-annotation {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.1s;
}

.text-annotation:hover {
  transform: translate(-50%, -50%) scale(1.05);
}

.text-annotation .remove-hint {
  display: none;
  margin-left: 0.5rem;
  color: var(--red);
}

.text-annotation:hover .remove-hint {
  display: inline;
}

/* Comparison Slider */
.comparison-slider {
  position: relative;
  width: 100%;
  height: 100%;
}

.comparison-before,
.comparison-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.comparison-before {
  z-index: 2;
}

.comparison-before img,
.comparison-after img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comparison-label {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.comparison-label.right {
  left: auto;
  right: 1rem;
}

.comparison-range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 10;
}

.comparison-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: white;
  transform: translateX(-50%);
  z-index: 5;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.comparison-handle::after {
  content: '⟷';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Tools Section */
.tools-section {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tool-buttons {
  display: flex;
  gap: 0.5rem;
}

.tool-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #E0E0E0;
  background: white;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn.active,
.tool-btn:hover {
  border-color: var(--primary);
  background: rgba(34, 139, 34, 0.1);
}

.color-picker {
  display: flex;
  gap: 0.5rem;
}

.color-btn {
  width: 28px;
  height: 28px;
  border: 3px solid white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.color-btn.active,
.color-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Style Section */
.style-section label,
.prompt-section label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.style-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.style-chip {
  padding: 0.5rem 0.875rem;
  border: 2px solid #E0E0E0;
  background: white;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.style-chip:hover {
  border-color: var(--primary);
}

.style-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Prompt Section */
.prompt-section textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #E0E0E0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.2s;
}

.prompt-section textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.prompt-section textarea::placeholder {
  color: #B0B0B0;
  font-style: italic;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.generate-btn {
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, #1a6b1a 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.generate-btn:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(34, 139, 34, 0.35);
  transform: translateY(-1px);
}

.generate-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.generate-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.loading-spinner {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 100px;
  padding: 0.6rem 0.875rem;
  background: white;
  border: 2px solid var(--secondary);
  color: var(--secondary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--secondary);
  color: white;
}

.action-btn.save {
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn.save:hover {
  background: var(--primary);
  color: white;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--text-light);
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.empty-state.small {
  padding: 2rem 1rem;
}

.empty-state.small p {
  font-size: 0.95rem;
}

.capture-btn-secondary {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.capture-btn-secondary:hover {
  background: var(--primary-dark);
}

/* Projects Panel */
.projects-panel {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.projects-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #F8F9FA;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.project-card:hover {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--shadow);
}

.project-thumbnail {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.project-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-info {
  flex: 1;
  min-width: 0;
}

.project-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.delete-btn {
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.delete-btn:hover {
  opacity: 1;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 0.875rem 1.5rem;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Footer */
.footer {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--primary-dark);
}

.footer .divider {
  color: #DDD;
}

/* Mobile Styles */
@media (max-width: 1024px) {
  .panels-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .projects-panel {
    grid-column: span 2;
    max-height: 300px;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }
  
  .logo {
    font-size: 1.5rem;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .tab-switcher {
    display: flex;
  }
  
  .panels-container {
    grid-template-columns: 1fr;
  }
  
  .panel {
    display: none;
  }
  
  .panel.active {
    display: flex;
    flex-direction: column;
  }
  
  .map-panel.active,
  .design-panel.active,
  .projects-panel.active {
    display: flex;
  }
  
  .projects-panel {
    grid-column: 1;
    max-height: none;
  }
  
  .map-container {
    height: 300px;
  }
  
  .style-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }
  
  .style-chip {
    flex-shrink: 0;
  }
  
  .mobile-only {
    display: flex;
  }
}

/* Leaflet Overrides */
.leaflet-container {
  font-family: inherit;
}

.leaflet-control-zoom {
  border-radius: 8px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
}