/* Comandos Page Styles */

body {
  font-family: 'Inter', sans-serif;
  background-color: #1a1a2e;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  color: #e2e8f0;
  min-height: 100vh;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.content {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* --- Sidebar --- */

.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#sidebar-card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 6rem);
  position: sticky;
  top: 1.5rem;
}

.card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}

.card-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-card-header {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle-chevron {
  margin-left: auto;
  font-size: 0.75rem;
  color: #64748b;
  transition: transform 0.2s;
}

/* Hide toggle chevron on desktop (sidebar always expanded) */
@media (min-width: 769px) {
  .sidebar-toggle-chevron {
    display: none;
  }
}

.card-body {
  padding: 1.5rem;
}

#commands-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

#commands-list::-webkit-scrollbar {
  width: 4px;
}

#commands-list::-webkit-scrollbar-track {
  background: transparent;
}

#commands-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

/* Command groups (collapsible) */

.cmd-group {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.cmd-group:last-child {
  border-bottom: none;
}

.cmd-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  color: #cbd5e1;
  user-select: none;
  transition: background 0.15s;
  border-radius: 6px;
}

.cmd-group-header:hover {
  background: rgba(255,255,255,0.05);
}

.cmd-group-chevron {
  font-size: 0.7rem;
  transition: transform 0.2s;
  color: #64748b;
  width: 12px;
  text-align: center;
}

.cmd-group.collapsed .cmd-group-chevron {
  transform: rotate(-90deg);
}

.cmd-group-count {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  color: #94a3b8;
  padding: 1px 6px;
  border-radius: 9999px;
}

.cmd-group-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease;
}

.cmd-group.collapsed .cmd-group-items {
  max-height: 0;
}

.cmd-item {
  padding: 0.4rem 0.75rem 0.4rem 1.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.cmd-item:hover {
  background: rgba(255,255,255,0.05);
}

.cmd-item.active {
  background: rgba(59,130,246,0.1);
  color: #60a5fa;
}

.cmd-name {
  font-weight: 500;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  color: #7dd3fc;
}

.cmd-desc {
  font-size: 0.7rem;
  color: #94a3b8;
  line-height: 1.3;
  margin-top: 1px;
}

/* --- Main Panel --- */

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* --- Editor --- */

#editor-wrapper {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
}

#editor-container {
  min-height: 350px;
  overflow: visible;
  border: none;
}

#vim-status-bar {
  height: 24px;
  background: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #64748b;
  padding: 2px 12px;
  line-height: 20px;
  border-top: 1px solid #1e293b;
}

#editor-buttons {
  display: flex;
  gap: 0.5rem;
}

#execute-btn {
  flex: 1;
  padding: 0.6rem 1.25rem;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.15s;
}

#execute-btn:hover {
  background: #059669;
}

#execute-btn:active {
  transform: scale(0.98);
}

#clear-btn {
  padding: 0.6rem 1.25rem;
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.15s;
}

#clear-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #e2e8f0;
}

/* --- REPL Output --- */

.repl-container {
  background: #1e293b;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  height: 400px;
  max-height: 500px;
}

.repl-header {
  padding: 0.5rem 1rem;
  background: #0f172a;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
}

.repl-output {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  min-height: 0;
}

.log-entry {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.log-expr {
  color: #facc15;
}

.log-result {
  color: #e2e8f0;
  background: rgba(255,255,255,0.05);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border-left: 2px solid #3b82f6;
  margin-left: 0.75rem;
  margin-top: 0.25rem;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.4;
  overflow-x: auto;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.log-error {
  color: #f87171;
  padding-left: 0.75rem;
  word-break: break-all;
}

.log-info {
  color: #94a3b8;
  font-style: italic;
}

/* --- Utilities --- */

.loading {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  border-top-color: #3b82f6;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-blue {
  background: #dce7ff;
  color: #2563eb;
}

.badge-orange {
  background: #ffedd5;
  color: #ea580c;
}

/* --- Mobile responsive --- */

@media (max-width: 768px) {
  .content {
    flex-direction: column;
    padding: 0.75rem 1rem;
    gap: 1rem;
    overflow-x: hidden;
  }

  .sidebar {
    width: 100%;
    order: 1;
  }

  #sidebar-card {
    max-height: 35vh;
    position: relative;
    top: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .sidebar-card-header:hover {
    background: rgba(255,255,255,0.05);
  }

  .sidebar-card-header:active {
    background: rgba(255,255,255,0.08);
  }

  #sidebar-card.collapsed .sidebar-toggle-chevron {
    transform: rotate(-90deg);
  }

  #sidebar-card.collapsed #commands-list {
    max-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  #commands-list {
    max-height: 28vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cmd-group-items {
    max-height: 200px;
  }

  .cmd-name {
    font-size: 0.72rem;
    word-break: break-all;
  }

  .cmd-desc {
    font-size: 0.65rem;
  }

  .main-panel {
    order: 2;
    flex: 1;
    min-height: 0;
  }

  #editor-wrapper {
    border-radius: 8px;
  }

  #editor-container {
    min-height: 200px;
  }

  #editor-buttons {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #execute-btn,
  #clear-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }

  .repl-container {
    height: 280px;
    max-height: 50vh;
    border-radius: 8px;
  }

  .repl-header {
    padding: 0.6rem 1rem;
    min-height: 44px;
  }

  .repl-header button {
    min-height: 36px;
    min-width: 44px;
    padding: 0.5rem 0.75rem;
  }

  .log-result {
    margin-left: 0.5rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }

  .content {
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
  }

  .card-header {
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
  }

  #commands-list {
    padding: 0.4rem;
    max-height: 30vh;
  }

  .cmd-group-header {
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
  }

  .cmd-item {
    padding: 0.5rem 0.6rem 0.5rem 1.25rem;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #editor-container {
    min-height: 180px;
  }

  .repl-container {
    height: 220px;
    max-height: 45vh;
  }
}
