/* --- RESETEO Y BASE --- */
html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 700px;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}

header {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

header h1 {
    margin: 0;
    font-size: 1.5em;
    color: #222;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-actions a, .header-actions button {
    text-decoration: none;
    color: #007bff;
    font-size: 0.9em;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
}

.header-actions a:hover, .header-actions button:hover {
    background-color: #e9ecef;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* --- ESTILOS DE LA SECCIÓN DE EXPLICACIÓN --- */
.explanation-section {
    background-color: #eef7ff;
    border-left: 4px solid #007bff;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 4px;
}

.explanation-section h2 {
    margin-top: 0;
    color: #0056b3;
}

.explanation-section p {
    text-align: justify; /* Alineación justificada añadida */
}

.converter-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* --- ESTILOS CORREGIDOS PARA EL TEXTAREA --- */
#textInput {
    width: 100%;
    flex-grow: 1;
    padding: 15px;
    font-size: 1em;
    line-height: 1.5;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    min-height: 200px;
    font-family: 'Courier New', Courier, monospace;
    
    text-align: left !important;
    box-sizing: border-box;
}

#textInput::placeholder {
    color: #6c757d;
    text-align: left !important;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.char-count {
    font-size: 0.9em;
    color: #666;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

#convertButton, .clear-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s, transform 0.1s;
    box-sizing: border-box;
}

#convertButton {
    background-color: #007bff;
    color: white;
}

#convertButton:hover {
    background-color: #0056b3;
}

.clear-btn {
    background-color: #6c757d;
    color: white;
    padding: 10px 15px;
    font-size: 1.2em;
}

.clear-btn:hover {
    background-color: #5a6268;
    transform: scale(1.05);
}

footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.8em;
    color: #777;
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        min-height: 95vh;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    header h1 {
        font-size: 1.3em;
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .char-count {
        align-self: flex-start;
        margin-bottom: 10px;
    }
    
    .button-group {
        width: 100%;
        justify-content: space-between;
    }

    #convertButton, .clear-btn {
        flex-grow: 1;
        text-align: center;
    }
}