/* ======================================================
   ⚙️ SCRIPT RUNNER PRO 🧪
   style.css — Mascoalba, editor coloreado, sin saltos
   ====================================================== */

/* RESET BÁSICO */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #e6e6e6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* SCROLLBARS NEGROS */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #000;
}
::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #333;
}

/* ===============================
   BODY LAYOUT (SIDE / TOP)
   =============================== */

body.layout-side .tool-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

body.layout-top .tool-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

body.layout-side .editor-output-wrapper {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  grid-template-rows: auto;
  gap: 12px;
}

body.layout-top .editor-output-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 12px;
}

/* ===============================
   TÍTULO SUPERIOR
   =============================== */

.tool-title {
  padding: 18px 16px 10px;
  background: #0b0b0b;
  border-bottom: 1px solid #111;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.tool-title h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.tool-title .subtitle {
  display: block;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 4px;
}

/* ===============================
   MENÚ SUPERIOR
   =============================== */

#menu {
  padding: 8px 16px;
  background: #050505;
  border-bottom: 1px solid #111;
}

.tool-menu {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.tool-menu .menu-item {
  padding: 4px 10px;
  border-radius: 999px;
  background: #111;
  color: #aaa;
}

.tool-menu .menu-item.active {
  background: linear-gradient(180deg, #0b57a4, #083b73);
  color: #fff;
}

.tool-menu .menu-item.disabled {
  opacity: 0.5;
}

/* ===============================
   OVERLAY MODO PROFESIONAL
   =============================== */

.pro-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(11, 87, 164, 0.35), rgba(0, 0, 0, 0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.pro-box {
  background: #050505;
  border-radius: 16px;
  padding: 24px 26px;
  border: 1px solid #222;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9);
  text-align: center;
  max-width: 360px;
}

.pro-box h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.pro-box p {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 18px;
}

.pro-btn {
  background: linear-gradient(180deg, #0b57a4, #083b73);
  border: none;
  border-radius: 999px;
  padding: 8px 22px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7);
  transition: 0.2s;
}

.pro-btn:hover {
  opacity: 0.9;
}

.pro-btn:active {
  transform: scale(0.96);
}

/* ===============================
   CONTENEDOR PRINCIPAL
   =============================== */

.tool-container {
  padding: 12px 16px 16px;
}

.editor-output-wrapper {
  width: 100%;
  min-height: 420px;
}

/* ===============================
   EDITOR
   =============================== */

.editor-section {
  display: flex;
  flex-direction: column;
  background: #050505;
  border-radius: 12px;
  border: 1px solid #111;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  padding: 10px 10px 12px;
  gap: 8px;
}

/* PILA EDITOR + PRISM */
.editor-stack {
  position: relative;
  width: 100%;
  height: 420px; /* altura fija Mascoalba */
  border-radius: 10px;
  border: 1px solid #222;
  background: #050505;
  box-shadow: 0 8px 24px rgba(0,0,0,0.65);
  overflow: hidden;
}

/* CAPA INFERIOR: PRISM */
#highlightedCode {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: Consolas, "Fira Code", monospace;
  font-size: 15px;
  line-height: 1.45;
}

/* CAPA SUPERIOR: EDITOR REAL */
.code-editor-layer {
  position: absolute;
  inset: 0;
  padding: 12px;
  font-family: Consolas, "Fira Code", monospace;
  font-size: 15px;
  line-height: 1.45;
  color: transparent;          /* texto invisible */
  caret-color: #ffffff;        /* cursor visible */
  background: transparent;
  border: none;
  outline: none;
  white-space: pre-wrap;
  overflow: auto;
}

/* Placeholder */
.code-editor-layer:empty::before {
  content: attr(data-placeholder);
  color: #555;
  font-style: italic;
}

/* LED */
.led-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3a0b0b;
  box-shadow: 0 0 8px #ff4d4f;
  border: 1px solid #111;
  margin-top: 4px;
}

.led-ok {
  background: #0b3f1f;
  box-shadow: 0 0 8px #2ecc71;
}

.led-error {
  background: #3a0b0b;
  box-shadow: 0 0 8px #ff4d4f;
}

/* ===============================
   BOTONES
   =============================== */

.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.btn-blue {
  background: linear-gradient(180deg, #0b57a4, #083b73);
  color: #fff;
}

.btn-green {
  background: linear-gradient(180deg, #1f8a4d, #166636);
  color: #fff;
}

.btn-orange {
  background: linear-gradient(180deg, #d9822b, #a85f1a);
  color: #fff;
}

.btn-grey {
  background: #151515;
  color: #ddd;
  border: 1px solid #222;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.96);
}

.btn-preview {
  font-size: 13px;
  padding-inline: 10px;
}

#snippetButtons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ======================================================
   BOTONES FLOTANTES
   ====================================================== */

.floating-btn {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    border: 1px solid #222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    z-index: 9999;
    transition: 0.2s ease;
}

.floating-btn:hover {
    background: #1a1a1a;
    transform: scale(1.05);
}

.floating-btn:active {
    transform: scale(0.92);
}

/* Botón fullscreen ⛶ encima del ↔ */
.fullscreen-btn {
    bottom: 70px;
}

/* ======================================================
   INDICADOR DE GUARDADO (Guardado ✓)
   ====================================================== */

#saveIndicator {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: #0b3f1f;
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 9999;
    border: 1px solid #1f6f3a;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}


/* ===============================
   OUTPUT (IFRAME) + VISTAS 📱📟🖥️
   =============================== */

.output-section {
  background: #050505;
  border-radius: 12px;
  border: 1px solid #111;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  padding: 10px;
  height: 420px;
  overflow: hidden;
}

.device-frame {
  width: 100%;
  height: 100%;
  transform-origin: top center;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#outputFrame {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid #222;
  background: #000;
}

/* ===============================
   PRISM AJUSTE
   =============================== */

pre[class*="language-"] {
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ===============================
   RESPONSIVE
   =============================== */

@media (max-width: 1024px) {
  body.layout-side .editor-output-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
}

@media (max-width: 768px) {
  .tool-title h1 {
    font-size: 18px;
  }

  .tool-title .subtitle {
    font-size: 12px;
  }

  .tool-container {
    padding-inline: 10px;
  }

  .buttons {
    justify-content: flex-start;
  }

  .editor-stack,
  .output-section {
    height: 360px;
  }
}
