:root {
    --primary-color: #2563eb;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --bg-color: #f3f4f6;
    --panel-bg: #ffffff;
    --text-color: #1f2937;
    --secondary-color: #6b7280;
    --border-color: #d1d5db;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* PWA Offline Indicator */
body.offline::before {
    content: '⚠️ Modalità Offline';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    text-align: center;
    padding: 8px;
    font-weight: 600;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.offline .container {
    margin-top: 40px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

.step {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, #92ade7 0%, #91a5e7 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
}

.header .logo {
    height: 40px;
    max-width: 40%;
    width: auto;
    filter: brightness(0) invert(1); /* Rende il logo bianco */
}

.btn-debug {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-debug:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.ordine-info {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 6px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.ordine-info .label {
    font-size: 14px;
    opacity: 0.9;
}

.ordine-info .value {
    font-size: 20px;
    font-weight: 700;
}

.btn-back {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: rgba(255,255,255,0.3);
}

/* ===== SELEZIONE ORDINI ===== */
.ordine-section {
    margin-bottom: 20px;
}

.ordine-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--text-color);
}

.ordini-attivi {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.ordine-card {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.ordine-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.ordine-card .num-packing {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.ordine-card .info {
    font-size: 14px;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

/* ===== SCANNER SECTION ===== */
.scanner-section {
    background: var(--panel-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.scanner-input-container {
    margin-bottom: 12px;
}

.scanner-input-container label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.barcode-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.barcode-input {
    flex: 1;
    min-width: 0;
    padding: 12px 10px;
    font-size: 18px;
    font-weight: 700;
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    background: #f9fafb;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.barcode-input:focus {
    outline: none;
    border-color: var(--success-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.barcode-action-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.barcode-action-btn:hover {
    background: #1e40af;
    transform: scale(1.05);
}

.barcode-action-btn:active {
    transform: scale(0.95);
}

.scan-feedback {
    margin-top: 8px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
    min-height: 18px;
    transition: all 0.2s;
    font-size: 14px;
}

.scan-feedback.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.scan-feedback.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

.scan-feedback.info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info-color);
}

/* ===== BARCODE TOOLBAR ===== */
.barcode-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 2px dashed var(--border-color);
}

.toolbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-color);
    white-space: nowrap;
}

.barcode-btn {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.barcode-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.barcode-btn:active {
    transform: translateY(0);
}

.barcode-btn.barcode-small {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.barcode-btn.barcode-medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.barcode-btn.barcode-large {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

/* ===== COLLI SECTION ===== */
.colli-section {
    background: var(--panel-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.colli-section h2 {
    font-size: 17px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.collo-attivo-info {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.collo-attivo-info .label {
    font-weight: 600;
    color: var(--secondary-color);
}

.collo-attivo-info .value {
    font-weight: 700;
    color: var(--text-color);
}

.colli-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.collo-item {
    background: #f9fafb;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.collo-item:hover {
    border-color: var(--primary-color);
    background: white;
}

.collo-header {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.collo-numero {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
}

.collo-dimensione {
    font-size: 14px;
    color: var(--secondary-color);
    font-family: 'Courier New', monospace;
}

.collo-prodotti {
    font-size: 14px;
    color: var(--success-color);
    font-weight: 600;
}

.btn-spacchetta {
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-spacchetta:hover {
    background: #b45309;
    transform: translateY(-1px);
}

/* ===== PRODOTTI SECTION ===== */
.prodotti-section {
    background: var(--panel-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.prodotti-section h2 {
    font-size: 17px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.prodotti-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.stat {
    flex: 1;
    background: #f9fafb;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid transparent;
}

.stat.stat-warning {
    border-color: var(--warning-color);
}

.stat.stat-success {
    border-color: var(--success-color);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--secondary-color);
    margin-bottom: 4px;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
}

.prodotti-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

.prodotto-item {
    background: #fef3c7;
    border-left: 4px solid var(--warning-color);
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.prodotto-item.impacchettato {
    background: #d1fae5;
    border-left-color: var(--success-color);
    opacity: 0.7;
}

.prodotto-item:hover {
    transform: translateX(3px);
}

.prodotto-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.prodotto-cod {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-color);
}

.prodotto-desc {
    font-size: 13px;
    color: var(--secondary-color);
}

.prodotto-barcode {
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #9ca3af;
}

.prodotto-status {
    display: flex;
    align-items: center;
}

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

/* ===== ACTIONS ===== */
.actions-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 12px 0;
}

.btn {
    padding: 14px 35px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-primary:hover:not(:disabled) {
    background: #047857;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== MOBILE RESPONSIVE (Zebra TC22 optimized) ===== */
@media (max-width: 768px) {
    body {
        line-height: 1.4;
    }

    .container {
        padding: 8px;
    }

    .header {
        flex-direction: row;
        gap: 8px;
        text-align: left;
        padding: 10px 12px;
        margin-bottom: 8px;
    }

    .header h1 {
        font-size: 18px;
    }

    .ordine-info {
        padding: 6px 12px;
        font-size: 13px;
    }

    .ordine-info .label {
        font-size: 12px;
    }

    .ordine-info .value {
        font-size: 16px;
    }

    .btn-back {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Selezione ordini */
    .ordine-section h2 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .ordini-attivi {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .ordine-card {
        padding: 12px;
    }

    .ordine-card .num-packing {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .ordine-card .info {
        font-size: 13px;
        margin-bottom: 3px;
    }

    /* Scanner section */
    .scanner-section {
        padding: 10px;
        margin-bottom: 8px;
    }

    .scanner-input-container {
        margin-bottom: 8px;
    }

    .scanner-input-container label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .barcode-input {
        padding: 12px 14px;
        font-size: 18px;
    }

    .scan-feedback {
        margin-top: 6px;
        padding: 8px;
        font-size: 13px;
        min-height: 16px;
    }

    /* Barcode toolbar */
    .barcode-toolbar {
        padding: 8px;
        gap: 6px;
    }

    .toolbar-label {
        font-size: 12px;
    }

    .barcode-quick-buttons {
        gap: 6px;
    }

    .barcode-btn {
        padding: 8px;
        gap: 2px;
    }

    .barcode-btn .barcode-label {
        font-size: 11px;
    }

    .barcode-btn .barcode-code {
        font-size: 12px;
    }

    /* Colli section */
    .colli-section {
        padding: 10px;
        margin-bottom: 8px;
    }

    .colli-section h2 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .collo-attivo-info {
        padding: 8px 10px;
        margin-bottom: 8px;
        font-size: 13px;
    }

    .colli-list {
        gap: 6px;
    }

    .collo-item {
        padding: 8px 10px;
    }

    .collo-header {
        gap: 8px;
        flex-wrap: nowrap;
    }

    .collo-numero {
        font-size: 14px;
    }

    .collo-dimensione {
        font-size: 12px;
    }

    .collo-prodotti {
        font-size: 12px;
    }

    .btn-spacchetta {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Prodotti section */
    .prodotti-section {
        padding: 10px;
        margin-bottom: 8px;
    }

    .prodotti-section h2 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .prodotti-stats {
        gap: 6px;
        margin-bottom: 8px;
    }

    .stat {
        padding: 8px 10px;
    }

    .stat-label {
        font-size: 10px;
        margin-bottom: 3px;
    }

    .stat-value {
        font-size: 20px;
    }

    .prodotti-list {
        gap: 6px;
        max-height: 300px;
    }

    .prodotto-item {
        padding: 8px 10px;
        gap: 8px;
    }

    .prodotto-info {
        gap: 2px;
    }

    .prodotto-cod {
        font-size: 14px;
    }

    .prodotto-desc {
        font-size: 12px;
    }

    .prodotto-barcode {
        font-size: 10px;
    }

    .badge {
        padding: 4px 10px;
        font-size: 11px;
    }

    /* Actions */
    .actions-section {
        padding: 8px 0;
        gap: 8px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 14px;
        width: 100%;
    }
}
