/**
 * Debug UI Styles
 * Custom styles for the tilemaker debug page
 */

/* Screen reader only utility class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0ea5e9;
  color: white;
  padding: 8px 16px;
  z-index: 100;
  text-decoration: none;
  font-weight: 500;
}

.skip-link:focus {
  top: 0;
}

/* Editor Container Styles */
#config-editor-container,
#lua-editor-container {
  border-radius: 0.375rem;
  overflow: hidden;
}

#config-editor-container .CodeMirror,
#lua-editor-container .CodeMirror {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* CodeMirror Theme Overrides */
.CodeMirror {
  border-radius: 0.375rem;
}

.CodeMirror-gutters {
  border-radius: 0.375rem 0 0 0.375rem;
}

/* Progress Bar Styles */
#progress-bar {
  transition: width 0.3s ease-in-out;
}

/* Map Container Styles */
#map-container {
  min-height: 400px;
}

#map {
  width: 100%;
  height: 400px;
}

/* Map Loading Overlay */
#map-loading {
  z-index: 10;
}

/* Debug Overlay Styles */
#debug-overlay {
  z-index: 20;
  min-width: 150px;
  backdrop-filter: blur(4px);
}

/* Layer Inspector Styles */
#layer-inspector {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

#layer-inspector::-webkit-scrollbar {
  width: 6px;
}

#layer-inspector::-webkit-scrollbar-track {
  background: #f1f5f9;
}

#layer-inspector::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}

/* Layer Toggle Switch */
#layer-list input[type="checkbox"]:checked + div {
  background-color: #0ea5e9;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
  #config-editor-container .CodeMirror,
  #lua-editor-container .CodeMirror {
    font-size: 12px;
  }
  
  #map-container {
    min-height: 300px;
  }
}

/* Animation for generating state */
@keyframes pulse-border {
  0%, 100% {
    border-color: #0ea5e9;
  }
  50% {
    border-color: #38bdf8;
  }
}

.generating #progress-section {
  animation: pulse-border 2s ease-in-out infinite;
  border: 2px solid #0ea5e9;
  border-radius: 0.5rem;
}

/* Error state styling */
#config-error {
  padding: 0.25rem 0.5rem;
  background-color: #fef2f2;
  border-radius: 0.25rem;
  margin-top: 0.25rem;
}

/* Success animation */
@keyframes success-fade {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

#success-section:not(.hidden) {
  animation: success-fade 0.3s ease-out;
}

/* Error animation */
@keyframes error-shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

#error-section:not(.hidden) {
  animation: error-shake 0.5s ease-in-out;
}

/* Button hover effects */
#generate-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#generate-btn:not(:disabled):active {
  transform: translateY(0);
}

/* Map controls positioning */
.maplibregl-ctrl-top-right {
  top: 10px;
  right: 10px;
}

.maplibregl-ctrl-bottom-right {
  bottom: 10px;
  right: 10px;
}

/* Custom scrollbar for left panel */
.overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.overflow-y-auto::-webkit-scrollbar {
  width: 8px;
}

.overflow-y-auto::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

/* Region selector enhancement */
#region-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Tooltip styles */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.25rem 0.5rem;
  background-color: #1f2937;
  color: white;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  white-space: nowrap;
  z-index: 50;
  margin-bottom: 0.25rem;
}

/* Focus states - improved for accessibility */
#region-select:focus,
#preset-select:focus,
#generate-btn:focus,
#load-preset-btn:focus,
#reset-config-btn:focus,
#reset-lua-btn:focus,
#format-config-btn:focus,
#toggle-debug-overlay:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* Focus visible for keyboard navigation only */
button:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #generate-btn {
    border: 2px solid currentColor;
  }
  
  #progress-bar {
    border: 1px solid #000;
  }
  
  .CodeMirror {
    border: 2px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #progress-bar {
    transition: none;
  }
  
  #success-section:not(.hidden),
  #error-section:not(.hidden) {
    animation: none;
  }
  
  #generate-btn:not(:disabled):hover {
    transform: none;
  }
  
  .animate-spin {
    animation: none;
  }
}

/* Disabled state */
#generate-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Panel divider */
@media (min-width: 1024px) {
  .border-r {
    border-right-width: 1px;
    border-color: #e5e7eb;
  }
}

/* Mobile stacking */
@media (max-width: 1023px) {
  .lg\:flex-row {
    flex-direction: column;
  }
  
  .lg\:w-1\/2 {
    width: 100%;
  }
  
  #map-container {
    height: 50vh;
    min-height: 300px;
  }
  
  /* Make editors more compact on tablet */
  #config-editor-container .CodeMirror,
  #lua-editor-container .CodeMirror {
    font-size: 12px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  #map-container {
    height: 40vh;
    min-height: 250px;
  }
  
  /* Smaller font for editors on mobile */
  #config-editor-container .CodeMirror,
  #lua-editor-container .CodeMirror {
    font-size: 11px;
  }
  
  /* Make buttons full width on mobile */
  #load-preset-btn {
    width: 100%;
    margin-top: 0.5rem;
  }
  
  /* Smaller debug overlay */
  #debug-overlay {
    font-size: 10px;
    padding: 0.5rem;
    min-width: 120px;
  }
  
  /* Compact layer inspector */
  #layer-inspector {
    max-height: 120px;
    padding: 0.5rem;
  }
  
  /* Smaller progress text */
  #progress-stage,
  #progress-percent {
    font-size: 0.75rem;
  }
}

/* Touch-friendly targets for mobile */
@media (pointer: coarse) {
  #layer-list input[type="checkbox"] + div {
    min-width: 44px;
    min-height: 24px;
  }
  
  button,
  select {
    min-height: 44px;
  }
  
  #reset-config-btn,
  #reset-lua-btn,
  #format-config-btn {
    padding: 0.5rem 0.75rem;
  }
}

/* Print styles */
@media print {
  #debug-overlay,
  #layer-inspector,
  #generate-btn,
  #progress-section {
    display: none !important;
  }
}

/* ============================================
   Terminal Styles - Professional CLI Output
   ============================================ */

.terminal-container {
  background: #1e1e1e;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

/* Terminal Header - macOS style */
.terminal-header {
  background: linear-gradient(180deg, #3c3c3c 0%, #2d2d2d 100%);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #1a1a1a;
}

.terminal-buttons {
  display: flex;
  gap: 8px;
  margin-right: 16px;
}

.terminal-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: default;
}

.terminal-btn-close {
  background: #ff5f56;
  border: 1px solid #e0443e;
}

.terminal-btn-minimize {
  background: #ffbd2e;
  border: 1px solid #dea123;
}

.terminal-btn-maximize {
  background: #27c93f;
  border: 1px solid #1aab29;
}

.terminal-title {
  flex: 1;
  color: #9d9d9d;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.terminal-actions {
  display: flex;
  gap: 4px;
}

.terminal-action-btn {
  background: transparent;
  border: none;
  color: #9d9d9d;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.terminal-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.terminal-action-btn:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 1px;
}

/* Terminal Body */
.terminal-body {
  background: #0d0d0d;
  color: #f0f0f0;
  padding: 12px 16px;
  height: 250px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: #3c3c3c #1e1e1e;
}

.terminal-body::-webkit-scrollbar {
  width: 8px;
}

.terminal-body::-webkit-scrollbar-track {
  background: #1e1e1e;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: #3c3c3c;
  border-radius: 4px;
}

.terminal-body::-webkit-scrollbar-thumb:hover {
  background: #4c4c4c;
}

/* Terminal Lines */
.terminal-line {
  display: flex;
  margin-bottom: 2px;
  word-break: break-all;
}

.terminal-timestamp {
  color: #6b7280;
  margin-right: 8px;
  flex-shrink: 0;
  font-size: 10px;
}

.terminal-prompt {
  color: #10b981;
  margin-right: 8px;
  flex-shrink: 0;
  font-weight: bold;
}

.terminal-text {
  color: #e5e7eb;
  flex: 1;
}

.terminal-text-stdout {
  color: #e5e7eb;
}

.terminal-text-stderr {
  color: #ef4444;
}

.terminal-text-muted {
  color: #6b7280;
  font-style: italic;
}

.terminal-text-success {
  color: #10b981;
}

.terminal-text-warning {
  color: #f59e0b;
}

.terminal-text-info {
  color: #3b82f6;
}

/* Terminal Welcome Message */
.terminal-welcome {
  color: #6b7280;
  margin-bottom: 8px;
}

/* Terminal Status Bar */
.terminal-statusbar {
  background: #252526;
  padding: 4px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #1a1a1a;
  font-size: 11px;
}

.terminal-status-text {
  color: #9d9d9d;
}

.terminal-status-text.running {
  color: #10b981;
}

.terminal-status-text.error {
  color: #ef4444;
}

.terminal-status-text.complete {
  color: #3b82f6;
}

.terminal-line-count {
  color: #6b7280;
}

/* Progress indicator in terminal */
.terminal-progress {
  display: inline-block;
  color: #3b82f6;
}

/* Syntax highlighting for common patterns */
.terminal-keyword {
  color: #c586c0;
}

.terminal-number {
  color: #b5cea8;
}

.terminal-string {
  color: #ce9178;
}

.terminal-path {
  color: #4ec9b0;
}

/* Animation for new lines */
@keyframes terminal-line-appear {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.terminal-line-new {
  animation: terminal-line-appear 0.15s ease-out;
}

/* Blinking cursor */
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: #f0f0f0;
  animation: terminal-blink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

@keyframes terminal-blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Responsive terminal */
@media (max-width: 1024px) {
  .terminal-body {
    height: 200px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .terminal-body {
    height: 150px;
    font-size: 10px;
    padding: 8px 12px;
  }
  
  .terminal-header {
    padding: 6px 10px;
  }
  
  .terminal-title {
    font-size: 11px;
  }
  
  .terminal-timestamp {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .terminal-line-new {
    animation: none;
  }
  
  .terminal-cursor {
    animation: none;
    opacity: 1;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .terminal-container {
    border: 2px solid #fff;
  }
  
  .terminal-body {
    background: #000;
  }
  
  .terminal-text {
    color: #fff;
  }
  
  .terminal-text-stderr {
    color: #ff6b6b;
    font-weight: bold;
  }
}
