/* VS Code / Cursor / Apple Premium Palette */
:root {
  --bg-editor: #1e1e1e;
  --bg-sidebar: #252526;
  --bg-activity: #333333;
  --border-color: rgba(255, 255, 255, 0.1);
  --accent-blue: #007aff; /* Apple Blue */
  --accent-hover: #0056b3;
  --text-main: #e0e0e0;
  --text-muted: #8e8e93; /* Apple Gray */
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-dropdown: #2c2c2e;
  --bg-selection: rgba(0, 122, 255, 0.3);
  --tab-active: #1e1e1e;
  --tab-inactive: #252526;
  --color-dirty: #ffd60a; /* Apple Yellow */
  --bg-toast: rgba(30, 30, 30, 0.85);
  --modal-bg: rgba(44, 44, 46, 0.95);
}

/* FLEXBOX BLINDADO PARA EVITAR DESAPARICIÓN DE BOTONES MÓVILES */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-editor);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Scrollbars Globales Premium tipo macOS / VS Code */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none; /* Mantener utilidad para ocultar explícitamente */
}

/* Scrollbar visible para pestañas del editor */
#editor-tabs-container {
  overflow-x: auto !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
#editor-tabs-container::-webkit-scrollbar {
  height: 4px; /* Un poco más fina para no estorbar */
}
#editor-tabs-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}
#editor-tabs-container::-webkit-scrollbar-track {
  background: transparent;
}

.spinner-anim {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.eruda-container {
  width: 33.33vw !important;
  max-width: 33.33vw !important;
  left: auto !important;
  right: 0 !important;
}
/* Custom Dropdowns Premium */
.custom-dropdown {
  position: relative;
  user-select: none;
}
.custom-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}
.custom-dropdown-header:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.custom-dropdown-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: max-content;
  min-width: 100%;
  background-color: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  z-index: 1100;
  display: none;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  backdrop-filter: blur(20px);
  max-width: calc(100vw - 40px);
}
.dropdown-left .custom-dropdown-list {
  left: auto;
  right: 0;
}
.custom-dropdown-list.open {
  display: block;
  animation: fadeIn 0.15s ease-out;
}
.custom-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s;
  white-space: nowrap;
}
.custom-dropdown-item:hover {
  background-color: var(--accent-blue);
  color: #ffffff;
}

/* Dropdown que abre hacia arriba (para dropdowns cerca del fondo de la pantalla) */
.dropdown-up .custom-dropdown-list {
  top: auto;
  bottom: calc(100% + 4px);
}
.dropdown-up .custom-dropdown-item {
  font-size: 12px;
  padding: 6px 10px;
}

/* Toasts Profesionales iOS Style */
#toast-container {
  position: fixed;
  bottom: 80px;
  right: 10px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  width: calc(100% - 20px);
  max-width: 340px;
}
@media (min-width: 768px) {
  #toast-container {
    bottom: 24px;
    right: 24px;
    width: auto;
  }
}
.toast {
  background-color: var(--bg-toast);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  word-break: break-word;
  pointer-events: auto;
  backdrop-filter: blur(15px);
}
@keyframes slideIn {
  from {
    transform: translateX(100%) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

/* Ace Editor Overrides Premium */
#code-editor {
  font-size: 14px;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  line-height: 1.6;
}
.ace-tomorrow-night {
  background-color: var(--bg-editor) !important;
  color: #d4d4d4 !important;
}
.ace_gutter {
  background: var(--bg-editor) !important;
  color: var(--text-muted) !important;
  border-right: 1px solid var(--border-color) !important;
}
.ace_active-line {
  background-color: rgba(255, 255, 255, 0.03) !important;
}
.ace_marker-layer .ace_selection {
  background: rgba(0, 122, 255, 0.4) !important;
}

.dirty-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--color-dirty);
  border-radius: 50%;
  display: none;
}
.is-dirty .dirty-dot {
  display: inline-block;
}

/* Modal y menú contextual (Glassmorphism) */
.modal-overlay {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 99999;
}
.context-menu {
  background: var(--modal-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  z-index: 9999;
  backdrop-filter: blur(25px);
}
.cm-item {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  transition: all 0.2s;
  border-radius: 4px;
  margin: 2px 4px;
}
.cm-item:hover {
  background-color: var(--accent-blue);
  color: white;
}
.cm-item.danger:hover {
  background-color: #ff3b30; /* Apple Red */
}

/* Custom Split Panes Styles */
.resizer {
  background-color: transparent;
  width: 12px; /* Área de agarre más ancha */
  margin-left: -6px; /* Offset para equilibrar el área invisible */
  margin-right: -6px;
  cursor: col-resize;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}
/* La línea visual */
.resizer::after {
  content: '';
  width: 1px;
  height: 100%;
  background-color: var(--border-color);
  transition: all 0.2s ease;
}
.resizer:hover::after, .resizer.is-resizing::after {
  background-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.5);
  width: 3px;
}

/* Prevenir zoom en inputs móviles */
input,
textarea {
  font-size: 16px !important;
  font-family: inherit;
}
@media (min-width: 768px) {
  input,
  textarea {
    font-size: 14px !important;
  }
}

/* Animaciones Globales */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.animate-fadeIn {
  animation: fadeIn 0.3s ease forwards;
}

/* Collapsed Panel Accordion */
.collapsed-mode {
  overflow: hidden !important;
  min-width: 45px !important;
  max-width: 45px !important;
  transition: all 0.25s ease;
  border-right: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}
.collapsed-mode .panel-collapsed-overlay {
  background: var(--bg-sidebar);
}

/* Panel Fit Button */
.panel-fit-btn {
  display: none;
}
@media (min-width: 768px) {
  .panel-fit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .panel-fit-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
  }
}
