/* ================================
   RESET BASE
================================ */
body {
    font-family: Arial, sans-serif;
    background: #f5f1e8;
    margin: 0;
    padding: 0;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

/* ================================
   CONTENITORE FORM
================================ */
#form-container {
    max-width: 1100px; /* Aumentato per ospitare 4 colonne */
    margin: 10px auto;
    padding: 20px 25px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e0d9c8;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

#form-container h2 {
    text-align: center;
    color: #ff7b00;
    margin-bottom: 18px;
}

/* ================================
   LAYOUT A DUE COLONNE
================================ */
.row {
    display: flex;
    flex-wrap: wrap; /* Permette il passaggio a riga successiva */
    gap: 15px;
    margin-bottom: 10px;
}

.col {
    flex: 1 1 calc(25% - 15px); /* Default: 4 colonne */
    min-width: 0; /* Fondamentale: permette alla colonna di restringersi e non farsi forzare dal contenuto lungo */
}

/* Classe per forzare 2 colonne anche su desktop */
.col.two-col {
    flex: 1 1 calc(50% - 15px);
}

/* Media query per .col.two-col: su mobile si comporta come una singola colonna */

/* Tablet: 2 Colonne */
@media (max-width: 900px) {
    .col {
        flex: 1 1 calc(50% - 15px);
    }
}

/* Mobile: 1 Colonna */
@media (max-width: 600px) {
    .row {
        flex-direction: column;
    }
}

/* ================================
   LABEL
================================ */
#form-container label {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

/* ================================
   INPUT, SELECT, FILE
================================ */
#form-container input[type="text"],
#form-container input[type="email"],
#form-container input[type="number"],
#form-container input[type="file"],
#form-container select {
    display: block;
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 15px;
    box-sizing: border-box;
    background: white;
    max-width: 100%; /* Hard limit: l'elemento non può mai essere più largo del suo genitore */
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

/* ================================
   BOTTONE
================================ */
#form-container button {
    width: 100%;
    padding: 12px;
    margin-top: 18px;
    background: #ff7b00;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

#form-container button:hover {
    background: #e56f00;
}

.hidden {
    display: none;
}

.camera-preview {
    margin-top: 10px;
}

.camera-preview video {
    width: 100%;
    max-height: 320px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #000;
}

.camera-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.camera-actions button,
#openCamera {
    display: none; /* Nascosto di default su Desktop */
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    background: #ff7b00;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

/* Garantisce che i pulsanti interni alla preview rimangano visibili quando la fotocamera è attiva */
.camera-actions button {
    display: inline-block;
}

.camera-actions button:hover,
#openCamera:hover {
    background: #e56f00;
}

.photo-preview {
    margin-top: 5px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    color: #999;
    font-size: 13px;
    overflow: hidden;
    text-align: center;
}

.photo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Mostra il pulsante per scattare foto solo su dispositivi Mobile */
@media (max-width: 600px) {
    #openCamera {
        display: inline-block;
    }
}

/* Miglioramento estetico per il filtro ATECO */
#atecoSearch {
    margin-bottom: 5px;
    border-color: #ff7b00;
    font-size: 13px;
}

.form-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    display: none; /* Nascosto finché non c'è un messaggio */
    border: 1px solid transparent;
}
