/* Reset i variables */
:root {
    --primary: #4a90e2;
    --primary-dark: #357abd;
    --secondary: #2ecc71;
    --text: #333333;
    --background: #ffffff;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Contenidor Principal */
.math-generator {
    max-width: 1000px;
    margin: 40px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15),
                0 -4px 6px rgba(0, 0, 0, 0.08);
}

.generator-header h1 {
    font-size: 2.5em;
    color: var(--text);
    margin: 0 0 30px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

/* Formulari */
.input-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

/* Inputs i Select */
input[type="number"],
select {
    width: 100px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
}

select {
    width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;
    padding-right: 35px;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* File Input */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="file"] {
    max-width: 300px;
}

.file-status {
    color: #666;
    font-size: 0.9em;
    margin-left: 10px;
}

/* Botons */
.button-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-generate {
    background-color: var(--primary);
    color: white;
}

.btn-download {
    background-color: var(--secondary);
    color: white;
}

#toggle-solutions {
    background-color: #f8f9fa;
    border: 2px solid #e0e0e0;
    color: #333;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px var(--shadow);
}

#toggle-solutions:hover {
    background-color: #e9ecef;
}

#toggle-solutions.showing {
    background-color: #e0e0e0;
}

/* Previsualització */
.preview-section {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.preview-header {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.preview-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.preview-fields .field {
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* Operacions */
#operations-container {
    width: 100%;
    padding: 20px 0;
    font-family: monospace;
}

.operation-row {
    display: grid;
    grid-template-columns: 40px repeat(5, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 10px;
    align-items: start;
}



.operation {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    width: fit-content;
}

.operation:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.operation .number {
    font-family: monospace;
    font-size: 1.2em;
    line-height: 1.6;
    letter-spacing: normal;
    white-space: pre;
}

.operation .number-container {
    display: inline-block;
    text-align: right;
}

.operation .operation-line {
    height: 2px;
    background-color: #333;
    margin: 5px 0;
    min-width: 100%;
}

/* Divisions */
.operations-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 20px 0;
}

.operations-table td {
    width: 33.33%;
    padding: 0;
    vertical-align: top;
}

.operation.divisio {
    width: 100%;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.operation.divisio .division-top {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    width: 100%;
    font-size: 1.4em;  /* Augmentem la mida del text */
}

.operation.divisio .division-bottom {
    margin-top: 10px;
    text-align: center;
    width: 100%;
}

.operation-row.division-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 20px;
}

.operation-letter {
    font-weight: bold;
    font-size: 1.2em;
}

.operation-row.division-row .operations-container {
    display: flex;
    flex-direction: column;  /* Forcem disposició vertical */
    gap: 20px;
    width: 100%;
}



.operation.divisio .division-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}



.operation.divisio .operation-number {
    display: inline-block;
}

.operation.divisio .operation-symbol {
    padding-right: 4px;
}

/* Solucions */
.operation-result {
    font-family: monospace;
    font-size: 1.2em;
    color: #2ecc71;
    font-weight: bold;
    margin-top: 5px;
    text-align: right;
}

.operation.divisio .operation-result {
    padding-left: 8px;
}

.operation.divisio .operation-result[style*="display: block"] {
    margin-top: 8px;
    text-align: left;
}

.operation.divisio .operation-result[style*="display: inline"] {
    margin-left: 8px;
}

.operation.divisio .operation-result,
.operation.divisio .remainder-result {
    display: inline;
    font-size: 1.2em;
    color: #2ecc71;
}


/* Responsive */
@media (max-width: 600px) {
    .math-generator {
        margin: 20px;
        padding: 20px;
    }

    .button-container {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}