/* Estilos Generales */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0; /* Cambiado de 20px a 0 para el modo pantalla completa */
    background-color: transparent; /* MODIFICADO: de #f4f7f6 a transparent */
    color: #333;
    line-height: 1.6;
}

/* Estilo para cuando el body está en modo broadcast fullscreen */
body.broadcast-fullscreen-active {
    overflow: hidden; /* Evitar scroll en el body */
}

/* Ocultar el contenedor principal de la app cuando broadcast está en fullscreen */
.broadcast-fullscreen-active #mainAppContainer {
    display: none !important;
}


h1, h2 {
    color: #005f73;
    border-bottom: 2px solid #94d2bd;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.app-container {
    max-width: 800px;
    margin: 20px auto;
    background-color: transparent;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* Considera eliminar o ajustar esto si no quieres sombras */
}

/* Pestañas */
.tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.tab-button {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1rem;
    color: #495057;
    border-bottom: 3px solid transparent;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.tab-button:hover {
    color: #0077b6;
}

.tab-button.active {
    color: #005f73;
    border-bottom-color: #00a896;
    font-weight: 600;
}

/* Vistas */
.view {
    display: none; /* Ocultas por defecto */
    /* padding-top: 10px; quitamos padding para broadcastView fullscreen */
    animation: fadeIn 0.5s ease-in-out;
}

.view.active {
    display: block; /* Visible si está activa */
}


/* --- ESTILOS PARA BROADCAST VIEW (PANTALLA COMPLETA) --- */

#broadcastView {
    /* No se activa display:block aquí, se hace con .active */
    /* Ocupa toda la pantalla cuando está activa y en modo fullscreen */
}

#broadcastView.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: transparent; /* MODIFICADO: de #000 a transparent */
    background-image: none; /* MODIFICADO: eliminado el fondo de imagen */
    /* background-size: cover; Ya no es necesario */
    /* background-position: center; Ya no es necesario */
    /* background-repeat: no-repeat; Ya no es necesario */
    z-index: 10000;
    display: flex; /* Usar flex para centrar el contenedor de subtítulos */
    flex-direction: column; /* Apilar elementos verticalmente */
    justify-content: flex-end; /* Alinea el contenedor de subtítulos abajo */
    align-items: center; /* Centra el contenedor de subtítulos horizontalmente */
    padding: 20px; /* Un poco de padding general si es necesario */
    box-sizing: border-box;
}

#broadcastView.fullscreen #subtitlesContainer {
    width: 85%; /* Por ejemplo, aumentado desde 80% */
    max-width: 1000px; /* Podrías aumentar ligeramente el max-width si es necesario */
    margin-bottom: 5vh; /* Margen desde la parte inferior (5% de la altura de la vista) */
    display: flex;
    flex-direction: column; /* Los subtítulos se apilan verticalmente */
    align-items: center; /* Centra los párrafos de subtítulos */
}

#broadcastView.fullscreen #subtitlesOutput {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: #FFFFFF;
    font-family: 'Arial', sans-serif; /* O la fuente que estés usando */
    /* AJUSTE PRINCIPAL AQUÍ: Prueba con un valor más pequeño */
    font-size: 2.0vw; /* Por ejemplo, reducido desde 2.5vw o 2.2vw */
    line-height: 1.3;
    text-align: center;
    padding: 10px 15px;
    border-radius: 5px;
    min-height: auto;
    /* Asegúrate que max-height sea consistente con MAX_SUBTITLE_LINES (2) y el font-size */
    max-height: calc(2 * 1.3 * 2.0vw + 20px); /* Ajustado para 2 líneas y el nuevo font-size */
    overflow-y: hidden; /* Esto es importante para que el texto extra no se desborde visiblemente */
    border: none;
}

/* Estilo para cada párrafo de subtítulo individual en modo fullscreen */
#broadcastView.fullscreen #subtitlesOutput p {
    margin: 2px 0; /* Pequeño margen entre líneas de subtítulos si se usa más de un <p> por bloque */
    padding: 0;
    /* La norma indica un máximo de 37 caracteres por línea.
       Esto se debe controlar más en JS o en la generación del subtítulo.
       Podríamos añadir un `max-width` al párrafo si la fuente es monoespaciada,
       pero con fuentes proporcionales es más complejo. */

    /* Added properties to better control line behavior */
    white-space: nowrap; /* Prevent text within this p from wrapping */
    overflow: hidden;    /* Hide text that overflows the width of this p */
    text-overflow: ellipsis; /* Show ... if text overflows */
    width: 100%; /* Ensure p takes the full width of its container (subtitlesOutput) */
    box-sizing: border-box; /* Include padding/border in width calculation if any were added */
}


/* Overlay de estado para broadcast view */
#broadcastView.fullscreen #broadcast-status-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    font-size: 0.8rem;
    border-radius: 3px;
    z-index: 10001; /* Por encima del fondo pero debajo del botón de salir */
}


@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Controles en Vista Grabación (sin cambios) */
.controls {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px; /* Espacio entre elementos */
}

.controls label {
    font-weight: 500;
    min-width: 110px; /* Alineación */
    /* margin-right: 10px; */ /* Rely on flex gap for spacing between items */
}

.controls select, .controls button {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95rem;
}

.controls select {
    flex-grow: 1; /* Ocupa espacio disponible */
    max-width: 400px;
}

.controls button {
    cursor: pointer;
    background-color: #0077b6;
    color: white;
    border: none;
    transition: background-color 0.2s ease;
}

.controls button:hover:not(:disabled) {
    background-color: #023e8a;
}

.controls button:disabled {
    background-color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Estado de carga de dispositivos */
#device-loading-status {
    font-style: italic;
    color: #6c757d;
    margin-left: 5px;
}

/* Waveform */
#waveform-container {
    margin-top: 20px;
    padding: 15px;
    background-color: #e9ecef;
    border-radius: 4px;
}
#waveform-container p {
    margin: 0 0 10px 0;
    font-weight: 500;
    color: #495057;
}
#waveform { /* Este ID no está en tu HTML, ¿quizás era para el WaveSurfer container? */
    border: 1px solid #ced4da;
    background-color: #fff;
    height: 100px;
    border-radius: 4px;
}

/* Salida de Subtítulos (original, para la vista no fullscreen) */
#mainAppContainer #subtitlesOutput { /* Asegurar que solo afecte a la versión no fullscreen */
    border: 1px solid #dee2e6;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    margin-top: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #212529;
}
#mainAppContainer #subtitlesOutput p {
    margin: 0 0 8px 0;
    padding: 2px 0;
}


/* Mensajes de Estado (originales) */
.status { /* Estos se aplican a recording-status */
    margin-top: 15px;
    font-style: italic;
    color: #6c757d;
    padding: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    text-align: center;
}

.info { /* Este se aplicaba al texto informativo de la vista broadcast, ya no es tan necesario */
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
    margin-bottom: 10px;
}

/* Ajustes para el botón de fullscreen y salir de fullscreen */
#fullscreenButton, #exitFullscreenButton {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    background-color: #6c757d;
    color: white;
    transition: background-color 0.2s ease;
}
#fullscreenButton:hover, #exitFullscreenButton:hover {
    background-color: #5a6268;
}

/* Toggle Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 50px; /* Reduced from 60px */
    height: 28px; /* Reduced from 34px */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #dde1e3; /* Lighter gray for inactive state */
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px; /* Reduced from 26px */
    width: 24px;  /* Reduced from 26px */
    left: 2px;    /* Reduced from 4px */
    bottom: 2px;  /* Reduced from 4px */
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked + .slider {
    background-color: #005f73; /* Theme color for active state */
}

input:focus + .slider {
    box-shadow: 0 0 0 3px rgba(0, 95, 115, 0.35); /* Softer, larger focus ring using theme color */
}

input:checked + .slider:before {
    -webkit-transform: translateX(22px); /* Adjusted from 26px */
    -ms-transform: translateX(22px);     /* Adjusted from 26px */
    transform: translateX(22px);         /* Adjusted from 26px */
}

/* Rounded sliders */
.slider.round {
    border-radius: 14px; /* Adjusted from 34px (half of new height 28px) */
}

.slider.round:before {
    border-radius: 50%;
}

/* Align toggle nicely with its label */
.controls .switch {
    /* vertical-align: middle; */ /* Handled by flex align-items: center on parent */
    /* margin-left: 10px; */   /* Rely on flex gap for spacing between items */
}