/* VERSION 7.0 - RESTORED LAYOUT + PERFORMANCE MODAL */
:root {
    --primary: #ffd700;
    --bg-dark: #000;
    --card-bg: #15151a;
    --text-main: #fff;
    --text-dim: #888;
    --green-glow: 0 0 15px rgba(0, 255, 0, 0.4);
    --blue-glow: 0 0 15px rgba(0, 150, 255, 0.4);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: #000; color: #fff; overflow: hidden; }

.split-layout {
    display: flex;
    height: calc(100vh - 70px);
    width: 100%;
    background: #000;
    overflow: hidden;
}

.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.layout-sidebar {
    width: 400px;
    flex-shrink: 0;
    background: #080808;
    border-left: 2px solid #222;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.machine-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
}

/* Header Produzione Compatto */
.header-operative {
    background: #000;
    padding: 5px 15px;
    border-bottom: 2px solid #222;
}

.header-top-row {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 60px;
}

.date-navigator-massive {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-arrow-huge {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 2.2rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s;
}
.nav-arrow-huge:hover { transform: scale(1.2); }

.date-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
    min-width: 180px;
}

.day-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: #888;
    letter-spacing: 2px;
}

.date-label {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
}

.dept-filters-bar {
    display: flex;
    flex-wrap: wrap; /* Wrap invece di scroll */
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid #111;
}

.dept-btn {
    padding: 8px 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.dept-btn.active { background: var(--primary); color: #000; border-color: var(--primary); }

.compact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 6px;
}

.phase-descr-row {
    font-size: 0.75rem;
    color: #888;
    background: rgba(255,255,255,0.03);
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 5px;
    font-style: italic;
}

/* CARD MACCHINA 3D */
.machine-card {
    background: var(--card-bg);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 10px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    height: auto; /* Permettiamo alla card di crescere per le info articolo */
    min-height: 180px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.machine-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.6); }

.machine-card.active { border-color: #00ff00; box-shadow: var(--green-glow); }
.machine-card.setup { border-color: #0096ff; box-shadow: var(--blue-glow); }

.card-status-dot {
    position: absolute;
    top: 12px; right: 12px;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.3);
    z-index: 2;
}
.card-status-dot.green { background: #00ff00; box-shadow: 0 0 10px #00ff00; }
.card-status-dot.blue { background: #0096ff; box-shadow: 0 0 10px #0096ff; }
.card-status-dot.off { background: #444; }

.machine-card.inactive { 
    opacity: 0.4; 
    filter: grayscale(1) brightness(0.6); 
    border: 1px dashed #444; 
    background: #0a0a0c;
}
.machine-card.inactive h3 { color: #555; }
.machine-card.inactive .cdc-label { color: #444; }
.machine-card.inactive:hover { opacity: 0.8; filter: none; }

.machine-total-day {
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--primary);
    margin-top: 5px;
    background: rgba(0,0,0,0.6);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,215,0,0.2);
    text-align: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.status-icon-box {
    position: absolute;
    top: 8px; right: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}
.status-icon-box svg { width: 22px; height: 22px; filter: drop-shadow(0 0 8px currentColor); }

.card-header h3 { margin: 0; font-size: 1rem; color: var(--primary); text-transform: uppercase; max-width: 80%; }
.cdc-label { font-size: 0.7rem; color: #666; font-weight: 800; display: block; margin-top: 4px; }

.card-body { margin-top: 12px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.data-row { 
    display: flex; 
    align-items: center; 
    font-size: 0.85rem; 
    color: #ccc; 
    gap: 8px;
}
.data-row .label { color: #666; font-weight: 800; font-size: 0.75rem; width: 45px; }
.data-row .val { color: #fff; font-weight: 800; min-width: 70px; }
.data-row .highlight { color: var(--primary); font-size: 1rem; }

.qty-box, .fase-box {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    justify-content: center;
}
.label-qty, .label-fase { font-size: 0.65rem; color: #555; font-weight: 800; }
.val-qty { font-size: 0.85rem; color: #fff; }

.time-val {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.3);
}
.time-val.setup { color: #0096ff; }
.time-val.work { color: #00ff00; }

.phase-badge { background: #222; color: var(--primary); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; border: 1px solid rgba(255,215,0,0.2); }

.art-info-row {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.art-code {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
}
.art-descr {
    font-size: 0.7rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer { 
    margin-top: auto; 
    border-top: 1px solid #333; 
    padding-top: 8px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.operator-info { display: flex; align-items: center; gap: 6px; color: #fff; font-weight: 600; font-size: 0.85rem; }
.operator-info i { color: var(--primary); }
.start-time { font-size: 0.7rem; color: #666; font-weight: 700; }

/* OVERLAY DETTAGLI MACCHINA */
.details-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px);
}
.details-content {
    background: #111; width: 900px; max-width: 95%; max-height: 85vh;
    border-radius: 12px; border: 1px solid #333;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.details-header {
    padding: 20px; background: #1a1a1a; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #333;
}
.details-header h2 { margin: 0; font-size: 1.2rem; color: var(--primary); }
.close-btn { background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; opacity: 0.5; }
.close-btn:hover { opacity: 1; }

.details-body { flex: 1; overflow-y: auto; padding: 20px; }
.details-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.details-table th { text-align: left; padding: 12px; color: #666; border-bottom: 2px solid #222; text-transform: uppercase; font-size: 0.75rem; }
.details-table td { padding: 12px; border-bottom: 1px solid #111; color: #ccc; }
.details-table tr:hover { background: rgba(255,215,0,0.05); }
.details-table tr.row-active { background: rgba(0,255,0,0.05); }
.details-table tr.row-active td { color: #00ff00; font-weight: 700; }


.history-peek {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #222;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hist-item {
    font-size: 0.72rem;
    color: #888;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hist-item strong { color: #ccc; }
.hist-item .h-time { color: #555; font-family: monospace; }

/* SIDEBAR OMARINI */
.sidebar-cat { margin-bottom: 15px; }
.sidebar-cat h4 { color: var(--primary); font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid #333; padding-bottom: 3px; margin-bottom: 10px; }

.omarini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.omarino-card { 
    display: flex; flex-direction: column; align-items: center; 
    cursor: pointer; transition: transform 0.2s; 
}
.omarino-card:hover { transform: scale(1.1); }

.avatar-circle {
    width: 64px; height: 64px; border-radius: 50%;
    background: #111; display: flex; align-items: center; justify-content: center;
    position: relative; font-size: 1.2rem; color: #888; border: 4px solid #222;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.omarino-card.working .avatar-circle { background: #005500; color: #fff; border-color: #00ff00; }
.omarino-card.present .avatar-circle { background: #444; color: #fff; border-color: #ffff00; }
.omarino-card.away .avatar-circle { opacity: 0.4; }

.status-indicator {
    position: absolute; bottom: -1px; right: -1px;
    width: 10px; height: 10px; border-radius: 50%; border: 1px solid #111;
}
.omarino-card.working .status-indicator { background: #00ff00; }
.omarino-card.present .status-indicator { background: #ffff00; }
.omarino-card.away .status-indicator { background: #ff0000; }

.eff-pct { font-size: 1rem; font-weight: 900; color: #fff; text-shadow: 0 0 4px rgba(0,0,0,0.8); }

.omarino-name { font-size: 0.75rem; color: #eee; margin-top: 6px; line-height: 1.2; font-weight: 800; text-align: center; text-transform: uppercase; }

/* REPARTI BUTTONS */
.dept-filters-bar { display: flex; gap: 10px; padding: 10px 20px; overflow-x: auto; background: rgba(255,255,255,0.02); border-bottom: 1px solid #222; }
.dept-btn {
    background: #222; border: 1px solid #444; color: #888; padding: 8px 20px;
    border-radius: 6px; cursor: pointer; font-weight: 700; white-space: nowrap; transition: all 0.2s;
}
.dept-btn:hover { background: #333; color: #fff; }
.dept-btn.active { background: var(--primary); color: #000; border-color: var(--primary); }
.operator-signature {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #eee;
    font-weight: 700;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.05);
    padding: 3px 8px;
    border-radius: 20px;
}
.avatar-mini {
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}
.start-time { font-size: 0.7rem; color: #555; font-weight: 800; font-family: monospace; }

/* OPERATOR SIGNATURE ON CARD */
.machine-card .operator-signature {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 10;
}

.machine-card .op-badge-mini {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #111;
    border: 2px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: transform 0.2s;
}

.machine-card .op-badge-mini:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.machine-card .op-eff-mini {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #00ff00;
    color: #000;
    font-size: 9px;
    font-weight: 900;
    padding: 1px 4px;
    border-radius: 8px;
    border: 1px solid #000;
    box-shadow: 0 0 5px rgba(0,255,0,0.5);
}

.machine-card .op-name-mini {
    font-size: 8px;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    text-align: center;
    max-width: 55px;
    line-height: 1.1;
    text-shadow: 1px 1px 2px #000;
}

.machine-card .status-time-box {
    position: absolute;
    top: 52px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 900;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
    z-index: 2;
}

/* MODAL TABLE OVERRIDES */
#operator-modal-body .lavorazioni-table td.tempo-col {
    font-weight: 800;
}
#operator-modal-body .tempo-hours { color: #fff; display: block; }
#operator-modal-body .tempo-minutes { color: #666; font-size: 0.8em; }

 . g a n t t - m o d a l   {   b a c k g r o u n d :   # 1 1 1 ;   b o r d e r - r a d i u s :   1 2 p x ;   b o x - s h a d o w :   0   1 0 p x   5 0 p x   r g b a ( 0 , 0 , 0 , 0 . 8 ) ;   c o l o r :   # f f f ;   o v e r f l o w :   h i d d e n ;   b o r d e r :   1 p x   s o l i d   # 3 3 3 ;   a n i m a t i o n :   m o d a l F a d e I n   0 . 3 s   e a s e ;   d i s p l a y :   f l e x ;   f l e x - d i r e c t i o n :   c o l u m n ;   } 
 
 @ k e y f r a m e s   m o d a l F a d e I n   {   f r o m   {   o p a c i t y :   0 ;   t r a n s f o r m :   t r a n s l a t e Y ( 2 0 p x ) ;   }   t o   {   o p a c i t y :   1 ;   t r a n s f o r m :   t r a n s l a t e Y ( 0 ) ;   }   } 
 
 



/* GANTT & ODL LINKS */
.odl-link, .machine-card .odl-link, .details-table .odl-link {
    color: var(--primary) !important;
    text-decoration: underline !important;
    cursor: zoom-in !important;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* --- HEIDENHAIN CNC STYLES --- */
.cnc-badge {
    position: absolute;
    top: 38px;
    left: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}
.cnc-badge.lavoro { background: #00ff00; color: #000; box-shadow: 0 0 10px rgba(0,255,0,0.4); }
.cnc-badge.hold { background: #ffaa00; color: #000; box-shadow: 0 0 10px rgba(255,170,0,0.4); }
.cnc-badge.allarme { 
    background: #ff0000; color: #fff; 
    box-shadow: 0 0 15px #ff0000;
    animation: blink-red 1s infinite alternate;
}
.cnc-badge.idle { background: #444; color: #aaa; }

@keyframes blink-red {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.7; transform: scale(1.05); }
}

.cnc-preview-btn {
    position: absolute;
    top: 70px;
    left: 10px;
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    border: 1px solid #444;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 0.7rem;
    z-index: 10;
    transition: all 0.2s;
}
.cnc-preview-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
}

.screenshot-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 10px;
}
.screenshot-img {
    max-width: 100%;
    border-radius: 8px;
    border: 2px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}
.screenshot-info {
    font-size: 0.9rem;
    color: #aaa;
    display: flex;
    gap: 20px;
}
.screenshot-info b { color: var(--primary); }