/* --- VARIABILI & RESET --- */
:root {
    --primary: #243668; /* Blu */
    --secondary: #f0ea6e; /* Giallo */
    --bg-color: #f4f6f9;
    --text-color: #333;
    --card-bg: #ffffff;
    --border-radius: 12px;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Source Sans Pro', sans-serif; background-color: var(--bg-color); color: var(--text-color); margin: 0; padding-bottom: 80px; }

/* --- UTILS --- */
.hidden { display: none !important; }
.bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-lg { font-size: 18px; }
.mb-15 { margin-bottom: 15px; }
.mt-10 { margin-top: 10px; }
.input-readonly { background-color: #eee; cursor: not-allowed; }
.loading { text-align: center; color: #999; margin-top: 20px; }
.alert-success { text-align: center; margin-bottom: 15px; color: green; }

/* --- HEADER --- */
.app-header { background: var(--primary); padding: 15px 20px; color: white; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1000; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.logo-container { display: flex; align-items: center; font-weight: 900; font-size: 24px; letter-spacing: -0.5px; }
.logo-text { color: white; }
.logo-circle { background: var(--primary); width: 32px; height: 32px; border-radius: 50%; display: flex; justify-content: center; align-items: center; margin: 0 4px; border: 2px solid white; }
.logo-p { color: var(--secondary); font-size: 20px; font-weight: 900; }
.header-btn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; }

/* --- NAVIGATION --- */
.bottom-nav { position: fixed; bottom: 0; width: 100%; background: white; border-top: 1px solid #eee; display: flex; justify-content: space-around; padding: 12px 0; z-index: 1000; }
.nav-item { text-align: center; color: #aaa; font-size: 10px; cursor: pointer; transition: 0.3s; }
.nav-item i { font-size: 20px; display: block; margin-bottom: 4px; }
.nav-item.active { color: var(--primary); transform: translateY(-2px); }

/* --- VISTE --- */
.view { display: none; padding: 20px; max-width: 800px; margin: 0 auto; animation: fadeIn 0.3s; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- CARDS & GRID --- */
.card { background: var(--card-bg); border-radius: var(--border-radius); padding: 20px; margin-bottom: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.menu-btn { background: white; padding: 25px 15px; border-radius: 15px; text-align: center; box-shadow: 0 4px 10px rgba(0,0,0,0.05); cursor: pointer; border: 1px solid transparent; transition: 0.2s; }
.menu-btn:active { transform: scale(0.96); background-color: #f0f0f0; }
.menu-btn i { font-size: 32px; color: var(--primary); margin-bottom: 10px; }
.menu-btn span { display: block; font-weight: 600; color: var(--primary); font-size: 14px; }

/* --- FORMS --- */
.form-group { margin-bottom: 15px; }
label { display: block; font-size: 12px; font-weight: 600; color: #666; margin-bottom: 5px; text-transform: uppercase; }
input, select { width: 100%; padding: 12px; border: 2px solid #eee; border-radius: 8px; font-size: 16px; background: #fff; }
input:focus, select:focus { border-color: var(--primary); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.box-check { padding: 10px; border: 1px solid #ddd; border-radius: 8px; background: white; }

/* --- BUTTONS --- */
.btn { border: none; padding: 14px; border-radius: 8px; width: 100%; font-weight: 700; font-size: 16px; cursor: pointer; margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #eee; color: #333; }
.btn-danger { background: #e74c3c; color: white; }
.btn-success { background: #27ae60; color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-row { display: flex; gap: 10px; margin-top: 20px; }
.btn-small { padding: 6px 12px; font-size: 12px; width: auto; margin-top: 0; }
.btn-text { background: none; border: none; font-size: 12px; color: #666; text-decoration: underline; cursor: pointer; margin-top: 5px; }

/* --- LIST ITEMS --- */
.list-item { padding: 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: white; }
.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: white; }
.status-lavorazione { background: #95a5a6; }
.status-transito { background: #3498db; }
.status-consegnato { background: #27ae60; }
.status-giacenza { background: #f39c12; }
.status-reso { background: #e74c3c; }

/* --- FILTERS --- */
.filter-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 10px; }
.filter-btn { white-space: nowrap; padding: 8px 15px; border-radius: 20px; border: 1px solid #ddd; background: white; font-size: 12px; cursor: pointer; }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* --- WIZARD --- */
.wizard-step { display: none; }
.wizard-step.active { display: block; }
.wizard-progress { display: flex; justify-content: space-between; margin-bottom: 20px; padding: 0 10px; }
.step-dot { width: 30px; height: 30px; background: #ddd; border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; font-weight: bold; }
.step-dot.active { background: var(--primary); box-shadow: 0 0 0 4px rgba(36, 54, 104, 0.2); }

/* --- MODALS & FAB --- */
.fab { position: fixed; bottom: 80px; right: 20px; background: var(--secondary); color: var(--primary); width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); cursor: pointer; z-index: 900; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; display: none; align-items: center; justify-content: center; }
.modal-content { background: white; width: 90%; max-width: 400px; padding: 20px; border-radius: 12px; max-height: 90vh; overflow-y: auto; }

/* --- SIGNATURE --- */
canvas { border: 2px dashed #ccc; width: 100%; height: 200px; border-radius: 8px; background: #fafafa; }

/* --- FIRMA TUTTO SCHERMO (CORRETTO) --- */
.modal-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Occupa tutto lo schermo */
    background: white;
    z-index: 3000;
    display: none; /* Gestito dal JS */
    flex-direction: column; /* Impila gli elementi verticalmente */
    padding: 0; /* Rimuovi padding generale */
}

.sig-header {
    flex: 0 0 auto; /* Non si ridimensiona */
    padding: 20px 20px 10px 20px;
    background: white;
    border-bottom: 1px solid #eee;
}

.sig-body {
    flex: 1 1 auto; /* Si espande per occupare tutto lo spazio vuoto */
    position: relative;
    background: #f9f9f9;
    width: 100%;
    overflow: hidden;
    touch-action: none; /* Blocca lo scroll del dito */
}

#sig-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.sig-footer {
    flex: 0 0 auto; /* Non si ridimensiona */
    padding: 10px 20px 20px 20px;
    background: white;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05); /* Ombra per staccarlo */
}
/* --- AUTOCOMPLETE --- */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    border: 1px solid #d4d4d4;
    border-bottom: none;
    border-top: none;
    z-index: 9999;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #d4d4d4;
    font-size: 14px;
}

.autocomplete-item:hover {
    background-color: #e9e9e9;
}

.autocomplete-item strong {
    color: var(--primary);
    display: block;
}
.autocomplete-item small {
    color: #666;
    font-size: 11px;
}