:root {
  /* Color Palette - Wedgewood, Timberwolf & Gulf Blue */
  --primary: #577EA8;
  --primary-hover: #4a6b8f;
  --primary-foreground: #ffffff;
  --secondary: #DED7D2;
  --secondary-foreground: #2a3f5f;
  --muted: #f5f3f1;
  --accent: #0C194B;
  --accent-foreground: #ffffff;
  --foreground: #2a3f5f;
  --success: #22c55e;
  --warning: #f59e0b;
  --destructive: #ef4444;
  --background: #ffffff;
  --card: #fafafa;
  --popover: #ffffff;
  --border: #e5e7eb;
  --input: #f9fafb;
  --focus-ring: #577EA8;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
}

header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  padding: 2rem 0;
  color: var(--primary-foreground);
  text-align: center;
  box-shadow: 0 4px 20px rgba(12, 25, 75, 0.15);
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.3;
}

.header-content {
  position: relative;
  z-index: 1;
}

h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.header-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 400;
  margin: 0;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-foreground);
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-link:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

main {
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

.ide-container {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 1.5rem;
  margin-bottom: 2rem;
  min-height: 600px;
  max-width: 100%;
}

.library-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  height: fit-content;
  max-height: 70vh;
  align-self: start;
  min-width: 280px;
}

.samples-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  height: fit-content;
  max-height: 70vh;
  align-self: start;
  min-width: 300px;
}

.samples-header {
  background: var(--muted);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.samples-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.samples-search {
  width: calc(100% - 3rem);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--background);
  color: var(--foreground);
  margin: 1rem 1.5rem 0;
  box-sizing: border-box;
}

.samples-search:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 2px rgba(87, 126, 168, 0.1);
}

.samples-list {
  max-height: calc(70vh - 120px);
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sample-category {
  margin-bottom: 1rem;
}

.sample-category-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.85rem;
  padding: 0.5rem 1.5rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sample-item {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.sample-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sample-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--foreground);
}

.sample-desc {
  font-size: 0.75rem;
  color: #6b7280;
}

.load-button {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.load-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(87, 126, 168, 0.3);
}

.library-header {
  background: var(--muted);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.library-search {
  width: calc(100% - 3rem);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--background);
  color: var(--foreground);
  margin: 1rem 1.5rem 0;
  box-sizing: border-box;
}

.library-search:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 2px rgba(87, 126, 168, 0.1);
}

.library-list {
  max-height: calc(70vh - 120px);
  overflow-y: auto;
  padding: 0.5rem 0;
}

.library-category {
  margin-bottom: 1rem;
}

.category-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.85rem;
  padding: 0.5rem 1.5rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.library-item {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-item:hover {
  background: var(--muted);
}

.library-item.selected {
  background: var(--primary);
  color: var(--primary-foreground);
}

.library-name {
  font-size: 0.9rem;
  font-weight: 500;
}

.library-version {
  font-size: 0.75rem;
  opacity: 0.7;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.library-item.selected .library-version {
  background: rgba(255, 255, 255, 0.2);
}

.include-button {
  background: var(--success);
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
  transform: translateX(-10px);
}

.library-item:hover .include-button {
  opacity: 1;
  transform: translateX(0);
}

.library-item.selected .include-button {
  opacity: 1;
  transform: translateX(0);
  background: rgba(255, 255, 255, 0.2);
}

.include-button:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.code-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  height: 70vh;
  min-height: 600px;
}

.code-header {
  background: var(--muted);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.btn {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Poppins', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(87, 126, 168, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-secondary:hover {
  background: #d1c9c4;
}

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

.btn-success:hover {
  background: #16a34a;
}

#monaco-editor-container {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  min-height: 400px;
  flex: 1;
  border-radius: 0 0 12px 12px;
}

.monaco-editor {
  border-radius: 0 0 12px 12px;
}

#output {
  margin-top: 2rem;
}

.output-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.output-header {
  background: var(--muted);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.output-content {
  padding: 1.5rem;
}

.success-message {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 1.5rem;
  color: #166534;
}

.compilation-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

.memory-usage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.memory-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
}

.memory-title {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.memory-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.memory-percentage {
  font-size: 0.8rem;
  color: #6b7280;
}

.memory-remaining {
  font-size: 0.8rem;
  color: var(--success);
  margin-top: 0.25rem;
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1.5rem;
  color: #dc2626;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--foreground);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

esp-web-install-button::part(button) {
  background: var(--success);
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'Poppins', sans-serif;
  transition: all 0.2s ease;
}

esp-web-install-button::part(button):hover {
  background: #16a34a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.note {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--muted);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}

footer {
  background: var(--muted);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-text {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.social-link {
  color: #6b7280;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.social-link:hover {
  color: var(--primary);
  transform: translateY(-2px);
}

.github:hover { color: #333; }
.linkedin:hover { color: #0077b5; }
.website:hover { color: var(--accent); }

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: var(--background);
  margin: 5% auto;
  padding: 0;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: var(--primary-foreground);
  padding: 1.5rem;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.close {
  color: var(--primary-foreground);
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.close:hover {
  opacity: 1;
}

.modal-body {
  padding: 2rem;
}

.steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.step-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--muted);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}

.step-number {
  background: var(--primary);
  color: var(--primary-foreground);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  margin-right: 1rem;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-title {
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}

.step-description {
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1.5;
}

.help-icon {
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 1.1rem;
}

.help-icon:hover {
  background: var(--muted);
  transform: scale(1.1);
}

@media (max-width: 768px) {
  main {
    padding: 1rem;
  }
  
  .ide-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .library-panel {
    order: 2;
    max-height: 300px;
    min-width: auto;
  }
  
  .code-section {
    order: 1;
    height: 50vh;
    min-height: 400px;
  }

  .samples-panel {
    order: 3;
    max-height: 300px;
    min-width: auto;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .header-subtitle {
    font-size: 1rem;
  }

  /* Search inputs for mobile */
  .library-search,
  .samples-search {
    width: calc(100% - 2rem) !important;
    margin: 1rem 1rem 0 !important;
  }

  /* Modal adjustments for mobile */
  #codeModal .modal-content {
    width: 98% !important;
    height: 95vh !important;
    max-height: none !important;
  }

  #codeModal .modal-body {
    height: calc(95vh - 80px) !important;
    max-height: none !important;
  }
}

@media (max-width: 480px) {
  #codeModal .modal-content {
    width: 100% !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  #codeModal .modal-body {
    height: calc(100vh - 80px) !important;
  }

  #modalCodeInput {
    font-size: 13px !important;
    padding: 1rem !important;
  }
}
