/* ===============================================
   === THEME: MOBILE CLEAN ========================
   ===============================================

   Tema ottimizzato per dispositivi mobile e touch
   - Layout a scroll orizzontale per workcenters
   - Spaziature generose per touch
   - Font Inter per leggibilità
   - Design pulito stile Apple
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

[data-style="mobile-clean"] {
    /* Colori base */
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F5F5F7;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-muted: #AEAEB2;
    --border-color: #E5E5E7;

    /* Colori accento */
    --color-primary: #34C759;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-danger: #FF3B30;
    --color-info: #007AFF;

    /* Colori operazioni */
    --color-estrusione: #34C759;
    --color-estrusione-bg: #E8F9ED;
    --color-saldatura: #FF9500;
    --color-saldatura-bg: #FFF4E5;
    --color-stampa: #007AFF;
    --color-stampa-bg: #E5F2FF;

    /* Ombre */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.1);

    /* Bordi - senza arrotondamenti */
    --border-radius: 0;
    --border-radius-lg: 0;
    --border-radius-xl: 0;
}

/* Font base */
[data-style="mobile-clean"] body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    -webkit-tap-highlight-color: transparent;
}

/* Header */
[data-style="mobile-clean"] .header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    box-shadow: none;
}

[data-style="mobile-clean"] .header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

[data-style="mobile-clean"] .header-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
}

[data-style="mobile-clean"] .header-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

[data-style="mobile-clean"] .connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-primary);
    background: var(--color-estrusione-bg);
    padding: 6px 12px;
}

/* Toolbar e Search */
[data-style="mobile-clean"] .toolbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

[data-style="mobile-clean"] .search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    padding: 12px 16px;
    gap: 12px;
    border: none;
}

[data-style="mobile-clean"] .search-bar:focus-within {
    background: var(--bg-secondary);
    box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.2);
}

[data-style="mobile-clean"] .search-bar input {
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

/* Sezione titoli */
[data-style="mobile-clean"] .section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-left: 4px;
}

/* Workcenters - Scroll orizzontale */
[data-style="mobile-clean"] .workcenters-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: none;
}

[data-style="mobile-clean"] .workcenters-grid::-webkit-scrollbar {
    display: none;
}

[data-style="mobile-clean"] .workcenter-card {
    flex-shrink: 0;
    width: 160px;
    min-width: 160px;
    background: var(--bg-secondary);
    padding: 20px 16px;
    box-shadow: var(--shadow-md);
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--color-primary);
    border-radius: 0;
}

[data-style="mobile-clean"] .workcenter-card:active {
    transform: scale(0.98);
}

[data-style="mobile-clean"] .workcenter-card.op-estrusione {
    border-left-color: var(--color-estrusione);
    background: var(--bg-secondary);
}

[data-style="mobile-clean"] .workcenter-card.op-saldatura {
    border-left-color: var(--color-saldatura);
    background: var(--bg-secondary);
}

[data-style="mobile-clean"] .workcenter-card.op-stampa {
    border-left-color: var(--color-stampa);
    background: var(--bg-secondary);
}

[data-style="mobile-clean"] .workcenter-card .card-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}

[data-style="mobile-clean"] .workcenter-card .workcenter-type-badge {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    background: transparent;
    padding: 0;
}

[data-style="mobile-clean"] .workcenter-card .count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 10px;
    background: var(--bg-primary);
}

[data-style="mobile-clean"] .workcenter-card .count-badge.active {
    background: var(--color-saldatura-bg);
    color: var(--color-saldatura);
}

[data-style="mobile-clean"] .workcenter-card .count-badge.ready {
    background: var(--color-estrusione-bg);
    color: var(--color-estrusione);
}

/* Tabs */
[data-style="mobile-clean"] .tabs {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    border-radius: 0;
}

[data-style="mobile-clean"] .tab {
    flex: 1;
    padding: 14px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
}

[data-style="mobile-clean"] .tab.active {
    background: var(--text-primary);
    color: white;
    box-shadow: none;
}

[data-style="mobile-clean"] .tab-count {
    font-weight: 400;
    opacity: 0.7;
    margin-left: 4px;
    background: transparent;
    padding: 0;
}

/* Work order cards */
[data-style="mobile-clean"] .workorder-card {
    background: var(--bg-secondary);
    padding: 16px;
    padding-top: 40px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    border-left: 4px solid var(--color-primary);
    margin-bottom: 12px;
}

[data-style="mobile-clean"] .workorder-card:active {
    transform: scale(0.99);
}

[data-style="mobile-clean"] .workorder-card.active {
    border-left: 4px solid var(--color-saldatura);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--color-saldatura-bg) 100%);
}

[data-style="mobile-clean"] .workorder-card .card-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
}

[data-style="mobile-clean"] .workorder-card .card-timer {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-saldatura);
    line-height: 1;
    background: var(--color-saldatura-bg);
    padding: 4px 8px;
    position: absolute;
    bottom: 10px;
    right: 10px;
}

/* Badge operazione in alto a sinistra */
[data-style="mobile-clean"] .workorder-card .operation-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 0.6rem;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-style="mobile-clean"] .workorder-card .card-state {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 10px;
    background: var(--color-saldatura);
    color: white;
}

/* Operation badges */
[data-style="mobile-clean"] .operation-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 10px;
    margin-top: 12px;
}

[data-style="mobile-clean"] .operation-badge.estrusione {
    background: var(--color-estrusione-bg);
    color: var(--color-estrusione);
}

[data-style="mobile-clean"] .operation-badge.saldatura {
    background: var(--color-saldatura-bg);
    color: var(--color-saldatura);
}

[data-style="mobile-clean"] .operation-badge.stampa {
    background: var(--color-stampa-bg);
    color: var(--color-stampa);
}

/* Bottoni */
[data-style="mobile-clean"] .btn {
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
}

[data-style="mobile-clean"] .btn:active {
    transform: scale(0.98);
}

[data-style="mobile-clean"] .btn-primary,
[data-style="mobile-clean"] .btn-success {
    background: var(--color-primary);
    color: white;
}

[data-style="mobile-clean"] .btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-style="mobile-clean"] .toolbar-btn {
    background: var(--color-primary);
    color: white;
    border-radius: 0;
}

/* Modal */
[data-style="mobile-clean"] .modal-overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

[data-style="mobile-clean"] .modal {
    border-radius: 0;
}

[data-style="mobile-clean"] .modal-header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
}

[data-style="mobile-clean"] .modal-close {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 0;
}

[data-style="mobile-clean"] .modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Theme selector */
[data-style="mobile-clean"] .theme-selector-btn {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 0;
}

[data-style="mobile-clean"] .theme-selector-btn:hover {
    background: rgba(52, 199, 89, 0.1);
    color: var(--color-primary);
}

[data-style="mobile-clean"] .theme-dropdown {
    border-radius: 0;
}

[data-style="mobile-clean"] .theme-option:first-child,
[data-style="mobile-clean"] .theme-option:last-child {
    border-radius: 0;
}

/* Toast */
[data-style="mobile-clean"] .toast {
    border-radius: 0;
    font-family: 'Inter', sans-serif;
}

/* Empty state */
[data-style="mobile-clean"] .empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

/* Dark mode */
[data-style="mobile-clean"][data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-muted: #636366;
    --border-color: #38383A;

    --color-estrusione-bg: rgba(52, 199, 89, 0.15);
    --color-saldatura-bg: rgba(255, 149, 0, 0.15);
    --color-stampa-bg: rgba(0, 122, 255, 0.15);
}

[data-style="mobile-clean"][data-theme="dark"] .header {
    background: rgba(28, 28, 30, 0.95);
}

[data-style="mobile-clean"][data-theme="dark"] .toolbar {
    background: rgba(28, 28, 30, 0.95);
}

/* =============================================
   GRIGLIA CARD - UNA COLONNA SU MOBILE
   ============================================= */
@media screen and (max-width: 768px) {
    [data-style="mobile-clean"] .kanban-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        grid-template-columns: none !important;
    }

    [data-style="mobile-clean"] .kanban-grid .workorder-card,
    [data-style="mobile-clean"] .workorder-card {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        padding: 12px !important;
        padding-top: 36px !important;
        box-sizing: border-box !important;
    }

    /* Badge operazione più compatto */
    [data-style="mobile-clean"] .workorder-card .operation-badge {
        font-size: 0.55rem !important;
        padding: 2px 5px !important;
        top: 8px !important;
        left: 8px !important;
        max-width: 50% !important;
    }

    /* Badge stato più compatto */
    [data-style="mobile-clean"] .workorder-card .card-state {
        font-size: 0.55rem !important;
        padding: 2px 5px !important;
        top: 8px !important;
        right: 8px !important;
    }

    /* Nome più compatto */
    [data-style="mobile-clean"] .workorder-card .card-name {
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        margin-bottom: 4px !important;
    }

    /* Prodotto */
    [data-style="mobile-clean"] .workorder-card .card-product {
        font-size: 0.7rem !important;
        margin-bottom: 3px !important;
    }

    /* Workcenter */
    [data-style="mobile-clean"] .workorder-card .card-workcenter {
        font-size: 0.6rem !important;
        padding: 2px 5px !important;
        margin-top: 3px !important;
    }

    /* Dettagli */
    [data-style="mobile-clean"] .workorder-card .card-details {
        font-size: 0.7rem !important;
        margin-top: 5px !important;
    }

    /* Timer in basso */
    [data-style="mobile-clean"] .workorder-card .card-timer {
        font-size: 0.7rem !important;
        padding: 2px 6px !important;
        bottom: 6px !important;
        right: 6px !important;
    }
}

/* =============================================
   MODAL SPECIFICHE TECNICHE - Layout mobile
   ============================================= */

[data-style="mobile-clean"] .modal-specs {
    margin: 0;
    max-height: 100vh;
    height: 100%;
    max-width: 100%;
    border-radius: 0;
}

[data-style="mobile-clean"] .modal-body-scroll {
    padding: 16px;
}

[data-style="mobile-clean"] .specs-section h4,
[data-style="mobile-clean"] .bom-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Tabella specifiche - responsive a card su mobile */
@media (max-width: 600px) {
    [data-style="mobile-clean"] .specs-table,
    [data-style="mobile-clean"] .bom-table {
        display: block;
    }

    [data-style="mobile-clean"] .specs-table thead,
    [data-style="mobile-clean"] .bom-table thead {
        display: none; /* Nascondi header su mobile */
    }

    [data-style="mobile-clean"] .specs-table tbody,
    [data-style="mobile-clean"] .bom-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    [data-style="mobile-clean"] .specs-table tr,
    [data-style="mobile-clean"] .bom-table tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-primary);
        padding: 16px;
        border: 1px solid var(--border-color);
        position: relative;
    }

    [data-style="mobile-clean"] .specs-table td,
    [data-style="mobile-clean"] .bom-table td {
        display: flex;
        flex-direction: column;
        padding: 8px 0;
        border: none;
        width: 100% !important;
    }

    /* Label sopra ogni campo */
    [data-style="mobile-clean"] .specs-table td::before,
    [data-style="mobile-clean"] .bom-table td::before {
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-secondary);
        margin-bottom: 4px;
    }

    /* Labels per specifiche tecniche */
    [data-style="mobile-clean"] .specs-table td:nth-child(1)::before {
        content: "Tipo Macchina";
    }
    [data-style="mobile-clean"] .specs-table td:nth-child(2)::before {
        content: "Chiave";
    }
    [data-style="mobile-clean"] .specs-table td:nth-child(3)::before {
        content: "Valore";
    }

    /* Labels per BOM */
    [data-style="mobile-clean"] .bom-table td:nth-child(1)::before {
        content: "Prodotto";
    }
    [data-style="mobile-clean"] .bom-table td:nth-child(2)::before {
        content: "Quantità %";
    }

    /* Colonna azioni - posiziona in alto a destra */
    [data-style="mobile-clean"] .specs-table td.col-actions,
    [data-style="mobile-clean"] .bom-table td.col-actions,
    [data-style="mobile-clean"] .specs-table td:last-child,
    [data-style="mobile-clean"] .bom-table td:last-child {
        position: absolute;
        top: 8px;
        right: 8px;
        width: auto !important;
        padding: 0;
    }

    [data-style="mobile-clean"] .specs-table td:last-child::before,
    [data-style="mobile-clean"] .bom-table td:last-child::before {
        content: none;
    }

    /* Input più grandi per touch */
    [data-style="mobile-clean"] .specs-table input,
    [data-style="mobile-clean"] .specs-table select,
    [data-style="mobile-clean"] .bom-table input {
        padding: 12px;
        font-size: 1rem;
        border-radius: 0;
    }

    /* Campo valore - textarea multilinea */
    [data-style="mobile-clean"] .specs-table td:nth-child(3) textarea {
        width: 100%;
        min-height: 60px;
        padding: 10px;
        font-size: 1rem;
        font-family: 'Inter', sans-serif;
        border: 1px solid var(--border-color);
        border-radius: 0;
        resize: vertical;
        line-height: 1.4;
    }

    /* Se il valore è in uno span/div invece che input */
    [data-style="mobile-clean"] .specs-table td:nth-child(3) {
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }

    /* Campo CHIAVE - permetti multi-linea se necessario */
    [data-style="mobile-clean"] .specs-table td:nth-child(2) {
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        line-height: 1.4;
    }

    [data-style="mobile-clean"] .specs-table td:nth-child(2) select,
    [data-style="mobile-clean"] .specs-table td:nth-child(2) span,
    [data-style="mobile-clean"] .specs-table td:nth-child(2) div {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Info section */
    [data-style="mobile-clean"] .specs-info-section {
        padding: 16px;
        background: var(--bg-primary);
        margin-bottom: 16px;
    }

    [data-style="mobile-clean"] .specs-info-row {
        flex-direction: column;
        gap: 12px;
    }

    [data-style="mobile-clean"] .info-cell {
        min-width: 100%;
    }
}

/* Responsive - assicura layout mobile */
@media (max-width: 768px) {
    [data-style="mobile-clean"] .workcenters-grid {
        display: flex !important;
        flex-wrap: nowrap;
    }

    [data-style="mobile-clean"] .workcenter-card {
        width: 160px !important;
        min-width: 160px !important;
    }
}
