body {
    font-family: sans-serif;
    background-color: #333333;
    color: #eee;
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Apply box-sizing to the body */
}

#logo {
    display: block;
    margin: 20px auto;
    max-width: 200px; /* Adjust as needed */
}

.language-selector {
    display: flex;
    justify-content: space-between; /* Changed from space-around to space-between */
    margin: 20px auto; /* Added auto margins */
    align-items: center;
    position: relative;
    width: 80%; /* Match translator width */
    max-width: 960px; /* Match translator max-width */
    padding: 0 20px; /* Match translator padding */
}

.language-selector > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.source-language-container, 
.target-language-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.source-language-container {
    justify-content: flex-start;
    margin-right: 30px; /* Match input-area margin-right */
}

.target-language-container {
    justify-content: flex-start;
}

.language-selector label[for="source-language"],
.language-selector select#source-language,
.language-selector label[for="target-language"],
.language-selector select#target-language {
    position: static; /* Remove positioning */
    left: auto;
}

.language-selector label {
    font-weight: bold;
    color: #bbb; /* Lighter gray for labels */
}

.language-selector select {
    padding: 5px;
    border: 1px solid #666; /* Slightly lighter border */
    border-radius: 4px;
    background-color: #444; /* Slightly lighter select background */
    color: #eee;
}

.translator {
    display: flex;
    flex-direction: row; /* Default to row layout */
    justify-content: space-between;
    align-items: flex-start;
    margin: 20px auto; /* Center the translator */
    width: 80%;
    max-width: 960px; /* Maximum width for larger screens */
    padding: 0 20px; /* Add some padding on the sides */
}

.input-area {
    display: flex;
    flex-direction: column;
    width: 100%; /* Full width for input area */
    flex: 1;
    margin-right: 20px;
}

.output-area {
  width: 100%; /* Full width for output area */
  flex: 1;
}

#input-box {
    width: 100%;
    min-height: 350px; /* Increased height */
    border: 1px solid #666;
    border-radius: 4px;
    position: relative;
    background: none;
    box-shadow: none;
    overflow: hidden; /* Prevent content from breaking border */
    margin-bottom: 10px;
}

#input-text {
    width: 100%;
    height: 100%;
    padding: 10px;
    border: none; /* Remove border from input-text */
    border-radius: 4px;
    resize: vertical;
    background-color: #444;
    color: #eee;
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    min-height: 350px; /* Match input-box height */
    font-size: 16px; /* Increased font size */
    line-height: 1.5; /* Better line spacing */
}

#drop-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #ccc;
    pointer-events: none;
    z-index: 1;
    box-sizing: border-box;
    background: none;
}

#drop-area.highlight {
    background: none;
    opacity: 0;
    display: none; /* Hide highlight completely */
}

#file-info {
    display: none;
    align-items: center;
    background-color: #444;
    padding: 15px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #666;
}

#file-icon {
    margin-right: 10px;
    font-size: 24px;
}

#file-name {
    color: #eee;
    word-break: break-all;
}

.button-container {
    position: relative;
    display: flex;
    justify-content: center; /* center both on desktop */
    align-items: center;
    margin-top: 20px;
    flex-direction: row; /* For desktop */
    width: 80%;
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 15px; /* Aumentar padding inferior */
    min-height: 60px; /* Altura mínima para asegurar espacio para todos los elementos */
}

.toggle-container {
    position: absolute; /* Remove absolute positioning */
    left: calc(50% + 80px); /* Adjust this value as needed to get proper spacing */
    display: none; /* Hide by default */
    align-items: center;
    gap: 8px;
    order: 2; /* toggle after button in desktop row */
    margin-top: 10px; /* Mismo margen que el botón de traducir */
    margin-left: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #999;
    transition: 0.4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #D56809;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

#translate-button {
    display: inline-flex;
    align-items: center;
    padding: 10px 30px;
    background-color: #D56809;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    position: absolute;
    left: 50%;
    margin-top: 10px;
    transform: translateX(-50%);
}

/* Ensure the icon is larger but remains aligned with the text */
#translate-button i {
    font-size: 200%; /* Set icon size for PC */
    margin-right: 8px; /* Adjust spacing as needed */
}

#output-text {
    width: 100%;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 10px;
    height: 330px; /* Altura fija en lugar de min-height */
    background-color: #444;
    color: #eee;
    font-size: 16px;
    line-height: 1.5;
    overflow-y: auto; /* Agregar barra de desplazamiento vertical */
}

.loading {
    position: relative;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #D56809;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

#progress-text {
    text-align: center;
    color: #D56809;
    margin: 10px 0;
    font-weight: bold;
}

#copy-button {
  background-color: #444444;
  border: none;              
  color: #fff;
  padding: 5px 10px;        
  border-radius: 4px;       
  cursor: pointer;         
  height: 28px;              
}

#clear-button {
  background-color: #444444;
  border: none;              
  color: #fff;
  padding: 5px 10px;        
  border-radius: 4px;       
  cursor: pointer;         
  height: 28px;              
}


.download-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #D56809;
    text-decoration: none;
    padding: 8px;
    margin: 5px 0;
    cursor: pointer;
    transition: color 0.3s ease;
}

.download-link:hover {
    color: #ff8010;
}

.download-link i {
    font-size: 1.2em;
}

.files-container {
    margin-top: 15px;
    padding: 10px;
    border-top: 1px solid #666;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .translator {
        flex-direction: column; /* Stack input and output vertically */
        align-items: stretch;
        width: 100%; /* Full width for mobile translator container */
        padding: 0 20px; /* Add padding to the sides */
        box-sizing: border-box; /* Include padding in width calculation */
        gap: 20px;
    }

    .language-selector {
        flex-direction: column;
        align-items: stretch; /* Stretch labels and selects */
        gap: 15px;
        width: 100%;
        padding: 0 10px; /* Reducir el padding en móvil */
        width: calc(100% - 20px); /* Ajustar el ancho considerando el padding */
    }

    .language-selector select {
        width: 100%; /* Asegurar que el select use todo el ancho disponible */
        max-width: 100%; /* Quitar el max-width para evitar que se corte */
        /*min-width: 200px; /* Asegurar un ancho mínimo */
        margin: 0; /* Quitar márgenes que puedan causar desbordamiento */
    }

    .source-language-container, 
    .target-language-container {
        justify-content: center;
        margin-right: 0;
        width: 100%; /* Usar todo el ancho disponible */
        padding: 0 5px; /* Pequeño padding para evitar que toque los bordes */
        box-sizing: border-box;
    }

    .language-selector label,
    .language-selector select {
        position: static;
        width: 100%;
        max-width: 300px;
        margin: 0 auto; /* Center the elements */
    }

    .input-area, 
    .output-area {
        width: 100%; /* Full width on small screens */
        margin-right: 0; /* Remove margin */
        margin-bottom: 20px; /* Ensure vertical space */
        margin: 0;
    }

    .language-selector label[for="target-language"],
    .language-selector select#target-language {
        left: 0; /* Align with output box */
    }

    #input-box {
        height: auto; /* Adjust height as needed */
        min-height: 150px;
        position: relative;
        margin-bottom: 10px;
        box-sizing: border-box; /* Include padding and border in element's total width and height */
        border: 1px solid #666; /* Ensure border is visible on mobile */
    }
    #input-text, #drop-area, #output-text {
        min-height: 150px;
        height: 150px; /* Set explicit height for input and output boxes */
        box-sizing: border-box;
        border: 1px solid #666; /* Add border for consistency */
        border-radius: 4px;
    }
    #input-box {
        box-sizing: border-box;
        border: none; /* Remove border from input-box */
    }
    #mobile-upload-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 16px; /* Ensure text size is consistent */
        margin: 10px auto;
        background-color: #444;
        color: #eee;
        width: 90%;
        max-width: 300px;
        padding: 10px;
        background-color: #D56809;
        color: white;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        margin: 10px auto 20px auto; /* Center and add more bottom margin */
        cursor: pointer;
        z-index: 2; /* Ensure button is above other elements */
        display: block; /* Ensure block display for centering with auto margins */
    }
    #mobile-upload-button i {
        font-size: 130%; /* Set upload icon size */
    }

    #input-text,
    #output-text {
        position: static;
        width: 100%;
        height: 150px; /* Ensure consistent height */
        min-height: 150px; /* Keep min-height for content overflow */
        margin-bottom: 10px;
        box-sizing: border-box; /* Ensure padding is included in height */
        border: 1px solid #666; /* Add border for consistency */
        border-radius: 4px;
        margin-bottom: 20px; /* Add margin below output text */
    }

    .button-container {
        margin: 20px 0;
        flex-direction: column; /* Stacks toggle above button */
        align-items: center;
        width: 100%;
        gap: 8px; /* Add space between stacked elements */
        padding-bottom: 10px; /* Padding inferior reducido */
    }

    .toggle-container {
        margin-bottom: 10px; /* Space below toggle */
        margin-left: 0;
        order: 3; /* place toggle above translate button */
        position: static;
        transform: none;
        margin: 10px auto;
    }

    #translate-button {
        width: 90%; /* Slightly reduced width for translate button */
        max-width: 300px;
        order: 2; /* button below toggle */
        justify-content: center; /* Center the translate button content */
        font-size: 16px; /* Set font size for Translate text on mobile */
        position: static;
        transform: none;
        margin: 10px auto;
        margin-top: -5px;
    }

    #translate-button i {
        font-size: 130%; /* Set icon size for mobile */
    }

    #input-text,
    #drop-area {
        height: 200px;  /* Reduced height for input area */
        min-height: 200px;
        margin-bottom: 0px;  /* Reduced gap below input */
    }
    #output-text {
        height: 200px;  /* Reduced height to match input area */
        min-height: 200px;
        margin-top: -15px;
    }
    .tone-selector {
        order: 1; /* First element in mobile layout */
        position: static; /* Remove absolute positioning */
        right: auto; /* Remove desktop positioning */
        transform: none;
        margin: 0 auto 5px; /* Add margin at the bottom only */
        width: 90%; /* Match width with translate button */
        max-width: 300px;
        justify-content: center;
        z-index: 1; /* Ensure it's above other elements */
    }
    
    /* Make sure tone selector takes full width on mobile */
    .tone-selector label,
    .tone-selector select {
        width: auto; /* Auto width instead of 100% to prevent overflow */
    }
    
    .tone-selector select {
        flex: 1; /* Allow select to grow */
    }

    /* Sobrescribir completamente la posición del tono selector en móvil */
    .tone-selector {
        position: static !important; /* Forzar override de la posición absoluta */
        right: auto !important; /* Remover el posicionamiento horizontal */
        left: auto !important;
        transform: none !important;
        margin: 0 auto 15px !important; /* Margen superior e inferior, centrado horizontal */
        width: 90% !important; /* Ancho consistente con otros elementos */
        max-width: 300px !important;
        display: flex !important;
        justify-content: center !important;
        order: 1 !important; /* Asegurar que aparezca primero */
    }
    
    /* Asegurar que el label y select estén correctamente alineados */
    .tone-selector label {
        width: auto !important;
        white-space: nowrap;
        margin-top: -20px;
    }
    
    .tone-selector select {
        flex: 1 !important;
        min-width: 0 !important; /* Permitir que se reduzca si es necesario */
        max-width: none !important; /* Permitir que ocupe el espacio disponible */
        margin-top: -20px;
    }
}

/* Hide mobile upload button on larger screens */
@media (min-width: 769px) {
    #mobile-upload-button {
        display: none;
    }
}

.toggle-container.show {
    display: flex;
}

/* Styles for the tone selector dropdown */
.tone-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
    position: absolute;
    right: calc(50% + 80px); /* Adjust this value as needed to get proper spacing */
    margin-top: 10px; /* Mismo margen que el botón de traducir */
}

.tone-selector label {
    font-weight: bold;
    color: #bbb;
}

.tone-selector select {
    padding: 5px;
    border: 1px solid #666;
    border-radius: 4px;
    background-color: #444;
    color: #eee;
    font-size: 14px;
    cursor: pointer;
}

.tone-selector select:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 3px rgba(74, 144, 226, 0.5);
}

/* Make button container display items in a row */
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

/* Mobile responsiveness for tone selector */
@media (max-width: 600px) {
    .button-container {
        flex-wrap: wrap;
    }
    
    .tone-selector {
        margin-bottom: 10px;
        margin-right: 0;
        width: 100%;
        justify-content: center;
    }
}