/* Updated styles for GLANCE Developer with 3-column layout */
:root {
  --primary: #10B981;
  --primary-light: #34D399;
  --primary-dark: #059669;
  --bg-dark: #111827;
  --bg-medium: #1F2937;
  --bg-light: #374151;
  --text-light: #F9FAFB;
  --text-muted: #9CA3AF;
  --border-color: #4B5563;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.5;
  color: var(--text-light);
  background: var(--bg-dark);
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  background: linear-gradient(to right, var(--bg-medium), var(--bg-dark));
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.logo svg {
  margin-right: 0.5rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-light);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.btn-group-vertical {
  flex-direction: column;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 0.875rem;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

.btn-primary {
  background: linear-gradient(to right, var(--primary), var(--primary-light));
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(to right, var(--primary-dark), var(--primary));
  box-shadow: var(--shadow-md);
}

.btn-full {
  width: 100%;
  margin-top: 0.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info span {
  color: var(--text-muted);
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-light);
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.help-icon:hover {
  background: var(--primary);
}

main {
  padding: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Three column layout */
.app-container {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 1.5rem;
  height: calc(100vh - 130px);
  max-height: calc(100vh - 130px);
}

.left-panel, .right-panel {
  background: var(--bg-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.main-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.editor-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 300px;
  height: 60%; /* Default 60% height */
  resize: vertical; /* Allow vertical resizing */
  position: relative;
}

/* Add resize handle between editor and preview */
.editor-container::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background-color: var(--bg-light);
  cursor: ns-resize;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-light);
  border-bottom: 1px solid var(--border-color);
}

.editor-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-editor-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 100px; /* Allow for smaller editor */
}

/* CodeMirror styling */
.CodeMirror {
  height: 100% !important;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  background-color: var(--bg-dark) !important;
  display: block !important;
  visibility: visible !important;
}

.CodeMirror-gutters {
  background-color: var(--bg-medium) !important;
  border-right: 1px solid var(--border-color) !important;
}

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

/* Form styles */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Help section */
.help-section {
  border-bottom: 1px solid var(--border-color);
}

.help-header {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.help-header:hover {
  background: var(--bg-light);
}

.help-content {
  padding: 1rem;
  display: none;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.help-content p {
  margin-bottom: 0.5rem;
}

.help-content code {
  display: block;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', monospace;
  overflow-x: auto;
}

/* Preview Section */
.preview-section {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-medium);
  height: 40%; /* Default 40% height */
  min-height: 150px; /* Minimum 10% of typical container */
  max-height: 60%; /* Maximum 60% of container */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent scrolling */
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}


.preview-title {
  font-size: 1rem;
  font-weight: 600;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.preview-dimensions {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
}

.canvas-wrapper {
  position: relative;
  background-color: var(--bg-dark);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--border-color);
  flex: 1;
  height: calc(100% - 40px); /* Account for header */
  min-height: 100px; /* Ensure minimum height */
}


/* Canvas and Grid styling */
#preview-canvas {
  position: absolute;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  z-index: 3;
}

/* Ensure pixel-perfect canvas rendering */
canvas#preview-canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Canvas controls styling */
.canvas-zoom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
  z-index: 10;
  background: rgba(31, 41, 55, 0.8);
  padding: 5px;
  border-radius: var(--radius-sm);
}

.canvas-zoom-controls button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.canvas-zoom-controls button:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}


/* Grid overlay */
.grid-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
}

/* Error display */
.code-errors {
  background: rgba(220, 38, 38, 0.1);
  border-left: 3px solid #DC2626;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #F87171;
  border-radius: var(--radius-sm);
  max-height: 120px;
  overflow-y: auto;
}

.code-errors ul {
  margin: 0;
  padding-left: 1.5rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-light) var(--bg-dark);
}
/* Styling for code blocks with copy buttons */
.code-with-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.code-block {
  flex: 1;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: 'Fira Code', monospace;
  overflow-x: auto;
}

.copy-btn {
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  height: fit-content;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: var(--transition);
}

.copy-btn:hover {
  background: var(--primary-dark);
  color: var(--text-light);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}

.copy-btn.copied {
  background: var(--primary);
  color: white;
}

.syntax-error {
  background-color: rgba(239, 68, 68, 0.2);
  border-bottom: 2px wavy #EF4444;
  cursor: help;
}

textarea#php-code {
  display: none !important;
  opacity: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  height: 0 !important;
  width: 0 !important;
  visibility: hidden !important;
  overflow: hidden !important;
}

/* Resize handle between editor and preview */
.resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5px;
  background-color: var(--bg-light);
  cursor: ns-resize;
  z-index: 10;
  transition: background-color 0.2s ease;
}

.resize-handle:hover, .resize-handle:active {
  background-color: var(--primary);
}

/* Grid control */
.grid-control {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
}

.grid-control input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.grid-control label {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* Responsive adjustments */
@media (max-height: 768px) {
  .editor-container {
    min-height: 200px;
  }
  
  .preview-section {
    min-height: 120px;
  }
}

@media (max-width: 1280px) {
  .app-container {
    grid-template-columns: 180px 1fr 260px;
  }
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 160px 1fr 240px;
  }
  .preview-controls {
    flex-wrap: wrap;
  }
}