/* Reseteo global: previene que paddings/bordes rompan el 100% de alto/ancho */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 1. BODY: Contenedor principal a pantalla completa estricta */
body {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh !important;
  margin: 0;
  overflow: hidden !important; /* Bloquea scroll global */
  font-size: inherit;
  text-align: left;
}

/* Reduce el logo solo en pantallas de 490px o menos (Móviles) */
@media screen and (max-width: 490px) {
  .logo {
    width: 20vw !important;
  }
}

/* 2. WRAPPER GLOBAL (Clase): Absorbe el espacio entre header y footer */
.wrapper {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto !important;
  width: 100%;
  min-height: 0; /* Vital para que no colapse la cadena Flex */
}

/* 3. HEADER/FOOTER fijos: evitamos que se aplasten */
#main-header,
footer {
  flex-shrink: 0;
}

/* --- LETRILLA: MÓVIL (Cálculos basados en diseño de 375px) --- */
.carga {
  min-height: 36.33vw;
  display: block;
  padding-top: 4vw;
  padding-bottom: 4vw;
  padding-left: 2.93vw;
  text-align: center;
  width: 100%;
  overflow: hidden;
  flex-shrink: 0; /* El bloque verde superior no debe encogerse */
}

.carga p,
.carga h1 {
  width: 100%;
  text-align: left;
  font-size: 5.33vw !important;
}

/* --- LETRILLA: TABLET --- */
@media (min-width: 768px) {
  .carga p,
  .carga h1 {
    font-size: 2.6vw !important;
  }
}

/* --- LETRILLA: DESKTOP --- */
@media (min-width: 1024px) {
  .carga {
    min-height: 10.41vw;
    padding-top: 0.78vw;
    padding-bottom: 0.78vw;
    padding-left: 0.57vw;
  }

  .carga p,
  .carga h1 {
    margin-left: 0.62vw;
    font-size: 1.3vw !important;
    overflow: hidden;
  }

  .carga h1,
  .carga p:not(:nth-child(3)) {
    white-space: nowrap;
  }
}

/* --- NÚCLEO RETRO-TECH REAR MACHINE --- */
:root {
  --cmd-green: #2ecc71;
  --cmd-bg: #050505;
  --rm-red: #ff4757;
  --glow: 0 0 10px rgba(46, 204, 113, 0.7);
}

/* 4. SECCIÓN PRINCIPAL: Hereda el espacio restante del .wrapper global */
#ira-page {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

/* 5. CONTENEDOR INTERNO: Continúa la cadena Flex */
#ira-page .content {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column;
  min-height: 0;
}

/* 6. WRAPPER NEGRO (ID): Absorbe el final de la cadena tras el bloque .carga */
#wrapper {
  background-color: var(--cmd-bg);
  color: var(--cmd-green);
  text-transform: uppercase;
  margin: 0;
  display: flex !important;
  flex: 1 1 auto !important;
  min-height: 0;
  position: relative;
}

/* Filtro CRT */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size:
    100% 4px,
    3px 100%;
  pointer-events: none;
}

/* Menú lateral */
#sidebar {
  width: 280px;
  border-right: 2px solid var(--cmd-green);
  background: #000;
  padding: 20px;
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.dir-link {
  display: block;
  color: var(--cmd-green);
  text-decoration: none;
  margin-bottom: 12px;
  padding: 4px;
}

.dir-link:before {
  content: "[DIR] ";
  opacity: 0.6;
}
.dir-link:hover {
  background: var(--cmd-green);
  color: #000;
}

/* 7. ÁREA DE TERMINAL: Respeta el ID #wrapper sin desbordar */
#terminal-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 40px;
  min-height: 0;
}

/* 8. OUTPUT: Destino final, asume el scroll interno (overflow-y: auto) */
#output {
  flex: 1 1 auto;
  overflow-y: auto;
  margin-bottom: 20px;
  min-height: 0;
  text-shadow: var(--glow);
}

.cmd-block {
  border: 1px solid var(--cmd-green);
  padding: 15px;
  margin: 15px 0;
  background: rgba(46, 204, 113, 0.05);
  word-wrap: break-word;

  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user-prompt {
  color: var(--rm-red);
  font-weight: bold;
}

/* Contenedor de entrada: flex-shrink: 0 evita que desaparezca si el output crece */
.input-line {
  display: flex;
  position: relative;
  width: 100%;
  text-shadow: var(--glow);
  align-items: center;
  flex-shrink: 0;
}

.input-wrapper {
  position: relative;
  flex-grow: 1;
  display: flex;
  align-items: center;
}

#cmd-input {
  background: transparent;
  border: none !important;
  box-shadow: none !important;
  color: var(--cmd-green);
  outline: none;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  margin: 0;
  z-index: 2;
  caret-color: transparent;
}

.cursor {
  position: absolute;
  width: 12px;
  height: 1.2em;
  background: var(--cmd-green);
  animation: blink 0.8s infinite;
  z-index: 1;
  box-shadow: var(--glow);
  pointer-events: none;
  left: 0;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--cmd-green);
}

/* --- CLASES UTILITARIAS REEMPLAZO DE BOOTSTRAP --- */
.mb-3 {
  margin-bottom: 1rem !important;
}
.mt-3 {
  margin-top: 1rem !important;
}
.mt-auto {
  margin-top: auto;
}
.pt-3 {
  padding-top: 1rem !important;
}
.me-1 {
  margin-right: 0.25rem !important;
}
.small {
  font-size: 0.875em !important;
}
.border-top {
  border-top: 1px solid var(--cmd-green);
}
.border-success {
  border-color: var(--cmd-green) !important;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
  .carga {
    max-height: 36.33vw;
    overflow-y: auto;
    display: none !important; /*quitar si queremos la carga*/
  }

  #wrapper {
    flex-direction: column !important;
  }
  #sidebar {
    border-right: none;
    border-bottom: 2px solid var(--cmd-green);
    width: 100%;
    height: auto;
    padding: 15px;
  }
  #terminal-area {
    padding: 15px;
    flex: 1 1 0% !important;
    min-height: 0 !important;
  }
}

/* BOTON GRABAR VOZ */
.rm-voice-btn {
  width: 42px;
  height: 42px;
  background: #020202;
  border: 1px solid #00ff66;
  color: #00ff66;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: monospace;
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.35);
}

.rm-voice-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.rm-voice-btn:hover {
  background: #00ff66;
  color: #020202;
}

.rm-voice-btn.is-recording {
  border-color: #ff3b5c;
  color: #ff3b5c;
  box-shadow: 0 0 12px rgba(255, 59, 92, 0.65);
}
