/* worklist.css — PoliMed src/css */
/* Stili: worklist sala, card esami, badge stato, modali worklist */

        :root {
            --accent: #167D87;
            --accent-dark: #0f5a61;
            --bg-main: #f4f7f6;
            --border: #d0d9dd;
            --text-main: #2c3e50;
            --white: #ffffff;
            --success: #27ae60;
            --warning: #f39c12;
            --danger: #e74c3c;
            --info: #3498db;
            --rosso: #e74c3c;
            --giallo: #f39c12;
            --verde: #27ae60;
            --bianco: #95a5a6;
        }

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

        body {
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            background: var(--bg-main);
            color: var(--text-main);
        }

        .main-container {
            overflow-y: auto !important;
            overflow-x: hidden !important;
        }

        .content-area {
            overflow-y: auto !important;
            height: auto !important;
            min-height: 0 !important;
        }

        /* Header */
        .header {
            background: var(--accent);
            color: white;
            padding: 12px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }

        .header h1 {
            font-size: 1.2em;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header .sala-badge {
            background: rgba(255, 255, 255, 0.2);
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.85em;
            font-weight: 600;
        }

        .header .stats {
            display: flex;
            gap: 20px;
            font-size: 0.9em;
        }

        .header .stat-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .header .stat-value {
            font-weight: 700;
            font-size: 1.1em;
        }

        /* Pulsanti controlli - Stile piattaforma MEDOS */
        .btn-refresh {
            background: var(--accent);
            color: white;
            border: none;
            padding: 0 20px;
            height: 38px;
            border-radius: 6px;
            font-family: 'Inter', system-ui, sans-serif;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.9em;
            transition: filter 0.2s, transform 0.1s;
        }

        .btn-refresh:hover {
            filter: brightness(1.1);
            transform: translateY(-1px);
        }

        .btn-refresh svg {
            stroke: currentColor;
        }

        .btn-refresh.btn-nav {
            background: transparent;
            color: var(--accent);
            border: 1px solid var(--border);
        }

        .btn-refresh.btn-nav:hover {
            background: #f4f9f9;
            filter: none;
            transform: translateY(-1px);
        }


        .btn-link-nav {
            background: white;
            color: var(--text-main);
            border: 1px solid var(--border);
            padding: 0 16px;
            height: 38px;
            border-radius: 6px;
            font-family: 'Inter', system-ui, sans-serif;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.85em;
            text-decoration: none;
            transition: all 0.2s;
        }

        .btn-link-nav:hover {
            background: #f4f7f6;
            border-color: var(--accent);
            color: var(--accent);
            padding-left: 20px;
        }

        .btn-link-nav svg {
            stroke: currentColor;
        }

        /* Controlli - Layout con sale a sinistra, azioni a destra */
        .controls {
            background: white;
            padding: 12px 20px;
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }

        .control-group.actions {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .controls select,
        .controls button {
            height: 36px;
            padding: 0 14px;
            border: 1px solid var(--border);
            border-radius: 6px;
            font-family: inherit;
            font-size: 0.9em;
            cursor: pointer;
        }

        .controls button {
            background: var(--accent);
            color: white;
            border: none;
            font-weight: 600;
            transition: all 0.2s;
        }

        .controls button:hover {
            background: var(--accent-dark);
            transform: translateY(-1px);
        }

        .controls button.secondary {
            background: white;
            color: var(--text-main);
            border: 1px solid var(--border);
        }

        .controls button.secondary:hover {
            background: var(--bg-main);
        }

        /* Selettore sale in linea - Stile piattaforma MEDOS */
        .sale-selector-line {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            align-items: center;
        }

        .sale-toggle {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0 16px;
            height: 38px;
            border: 1px solid var(--border);
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85em;
            font-weight: 600;
            background: white;
            color: var(--text-main);
            transition: all 0.2s;
            white-space: nowrap;
            font-family: 'Inter', system-ui, sans-serif;
        }

        .sale-toggle:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .sale-toggle.active {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
        }

        .sale-toggle input {
            display: none;
        }

        .sale-toggle-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

        /* Lista esami */
        .container {
            padding: 20px;
        }

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

        /* Card esame */
        .exam-card {
            background: white;
            border-radius: 10px;
            border: 2px solid transparent;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
            padding: 16px 20px;
            display: grid;
            grid-template-columns: 50px 1fr auto auto;
            gap: 20px;
            align-items: center;
            transition: all 0.2s;
            cursor: pointer;
        }

        .exam-card:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            transform: translateY(-1px);
        }

        .exam-card.priorita-rosso {
            border-left: 4px solid var(--rosso);
        }

        .exam-card.priorita-giallo {
            border-left: 4px solid var(--giallo);
        }

        .exam-card.priorita-verde {
            border-left: 4px solid var(--verde);
        }

        .exam-card.priorita-bianco {
            border-left: 4px solid var(--bianco);
        }

        /* Stato esame */
        .stato-badge {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2em;
        }

        .stato-prenotato {
            background: #ecf0f1;
            color: #7f8c8d;
        }

        .stato-accettato {
            background: #fff3cd;
            color: #856404;
        }

        .stato-in_attesa {
            background: #d1ecf1;
            color: #0c5460;
        }

        .stato-in_esecuzione {
            background: #d4edda;
            color: #155724;
            animation: pulse 2s infinite;
        }

        .stato-completato {
            background: #cce5ff;
            color: #004085;
        }

        .stato-in_refertazione {
            background: #e2d4f0;
            color: #5a3d7a;
        }

        .stato-refertato {
            background: #c3e6cb;
            color: #1e7e34;
        }

        .stato-firmato {
            background: #28a745;
            color: white;
        }

        .stato-consegnato {
            background: #17a2b8;
            color: white;
        }

        @keyframes pulse {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.7;
            }
        }

        /* Info paziente */
        .patient-info h3 {
            font-size: 1.1em;
            font-weight: 700;
            margin-bottom: 4px;
            color: var(--text-main);
        }

        .patient-info .details {
            display: flex;
            gap: 15px;
            font-size: 0.85em;
            color: #5f6b7b;
            flex-wrap: wrap;
        }

        .patient-info .detail-item {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .patient-info .exam-type {
            display: inline-block;
            background: var(--bg-main);
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            color: var(--accent);
            margin-top: 6px;
        }

        .patient-info .contrasto-badge {
            display: inline-block;
            background: #d1ecf1;
            color: #0c5460;
            padding: 2px 6px;
            border-radius: 4px;
            font-size: 0.7em;
            font-weight: 600;
            margin-left: 6px;
        }

        .ritardo-badge {
            display: inline-block;
            padding: 1px 5px;
            border-radius: 3px;
            font-size: 0.75em;
            font-weight: 600;
            margin-left: 4px;
        }

        .ritardo-badge.puntual {
            background: #d4edda;
            color: #155724;
        }

        .ritardo-badge.ritardo-paziente {
            background: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }

        .ritardo-badge.ritardo-centro {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .ritardo-badge.arrivato {
            background: #e2f0f1;
            color: #167D87;
        }

        /* Timer TAT */
        .tat-timer {
            text-align: center;
            font-family: 'SF Mono', Monaco, monospace;
        }

        .tat-timer .time {
            font-size: 1.3em;
            font-weight: 700;
            color: var(--text-main);
        }

        .tat-timer .label {
            font-size: 0.75em;
            color: #7f8c8d;
            text-transform: uppercase;
        }

        .tat-timer.warning .time {
            color: var(--warning);
        }

        .tat-timer.danger .time {
            color: var(--danger);
            animation: blink 1s infinite;
        }

        @keyframes blink {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.5;
            }
        }

        /* Azioni */
        .actions {
            display: flex;
            gap: 8px;
        }

        .actions button {
            height: 36px;
            padding: 0 16px;
            border: none;
            border-radius: 6px;
            font-family: inherit;
            font-size: 0.85em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }

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

        .btn-avvia:hover {
            background: #219a52;
            transform: translateY(-1px);
        }

        .btn-completa {
            background: var(--info);
            color: white;
        }

        .btn-completa:hover {
            background: #2980b9;
        }

        .btn-pacs {
            background: #6c757d;
            color: white;
        }

        .btn-pacs:hover {
            background: #5a6268;
        }

        /* Modal */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal-overlay.show {
            display: flex;
        }

        .modal {
            background: white;
            border-radius: 12px;
            width: 90%;
            max-width: 500px;
            max-height: 90vh;
            overflow: hidden;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }

        .modal-header {
            background: var(--accent);
            color: white;
            padding: 16px 20px;
            font-weight: 700;
            font-size: 1.1em;
        }

        .modal-body {
            padding: 20px;
        }

        .modal-body .form-group {
            margin-bottom: 16px;
        }

        .modal-body label {
            display: block;
            font-size: 0.85em;
            font-weight: 600;
            color: #5f6b7b;
            margin-bottom: 6px;
        }

        .modal-body input,
        .modal-body select,
        .modal-body textarea {
            width: 100%;
            height: 40px;
            padding: 0 12px;
            border: 1px solid var(--border);
            border-radius: 6px;
            font-family: inherit;
            font-size: 0.95em;
        }

        .modal-body textarea {
            height: 80px;
            padding: 10px 12px;
            resize: vertical;
        }

        .modal-footer {
            padding: 16px 20px;
            border-top: 1px solid var(--border);
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .modal-footer button {
            height: 38px;
            padding: 0 20px;
            border: none;
            border-radius: 6px;
            font-family: inherit;
            font-weight: 600;
            cursor: pointer;
        }

        .btn-annulla {
            background: #ecf0f1;
            color: #5f6b7b;
        }

        .btn-conferma {
            background: var(--accent);
            color: white;
        }

        /* Loading */
        .loading {
            text-align: center;
            padding: 40px;
            color: #7f8c8d;
        }

        .spinner {
            width: 40px;
            height: 40px;
            border: 3px solid var(--border);
            border-top-color: var(--accent);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 15px;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* Empty state */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #7f8c8d;
        }

        .empty-state .icon {
            font-size: 4em;
            margin-bottom: 20px;
            opacity: 0.3;
        }

        /* Sezioni In Attesa / Chiamati */
        .section-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin: 25px 0 15px 0;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--border);
        }

        .section-header h2 {
            margin: 0;
            font-size: 1.1em;
            color: var(--text-main);
            font-weight: 600;
        }

        .section-count {
            background: #e9ecef;
            color: #495057;
            padding: 2px 10px;
            border-radius: 12px;
            font-size: 0.85em;
            font-weight: 600;
        }

        .chiamati-header {
            border-bottom-color: #167D87;
        }

        .chiamati-header h2 {
            color: #167D87;
        }

        .chiamati-list .exam-card {
            border-left: 4px solid #adb5bd;
            background: #f1f3f5;
            opacity: 0.75;
        }

        .chiamati-list .exam-card h3 {
            color: #6c757d;
        }

        .chiamati-list .stato-badge {
            background: #adb5bd !important;
        }

        /* Sezione Completati */
        .completati-header {
            border-bottom-color: #28a745;
        }

        .completati-header h2 {
            color: #28a745;
        }

        .completati-list .exam-card {
            border-left: 4px solid #c3e6cb;
            background: #f8fff9;
            opacity: 0.6;
        }

        .badge-completato {
            display: inline-block;
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
            padding: 3px 10px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
        }

        /* Pulsante Chiama */
        .btn-chiama {
            background: #167D87;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: background 0.2s;
        }

        .btn-chiama:hover {
            background: #0f5f68;
        }

        /* Stato badge chiamato */
        .stato-chiamato {
            background: #167D87;
            color: white;
        }

        /* Pulsante Annulla */
        .btn-annulla {
            background: #6c757d;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        .btn-annulla:hover {
            background: #5a6268;
        }

        /* Lampeggio rosso fattura da aggiornare */
        @keyframes lampeggia-fattura {

            0%,
            100% {
                border-color: #e74c3c;
                box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
            }

            50% {
                border-color: #e74c3c;
                box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.35);
            }
        }

        .exam-card.fattura-da-aggiornare {
            border-left-color: #e74c3c !important;
            animation: lampeggia-fattura 1.5s ease-in-out infinite;
        }

        .exam-card.fattura-da-aggiornare::after {
            content: '! Fattura da aggiornare';
            position: absolute;
            top: 4px;
            right: 8px;
            background: #e74c3c;
            color: white;
            font-size: 0.7em;
            font-weight: 700;
            padding: 2px 7px;
            border-radius: 10px;
            z-index: 10;
        }

        /* Pulsante Modifica Esame */
        .btn-modifica {
            background: transparent;
            color: #167D87;
            border: 1px solid #167D87;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-modifica:hover {
            background: #167D87;
            color: white;
        }

        /* Pulsante Concludi Esame */
        .btn-concludi {
            background: #27ae60;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        .btn-concludi:hover {
            background: #219a52;
        }

        /* Pulsante Esporta a PACS */
        .btn-esporta-pacs {
            background: #9b59b6;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: background 0.2s;
        }

        .btn-esporta-pacs:hover {
            background: #8e44ad;
        }

        .btn-esporta-pacs:disabled {
            background: #bdc3c7;
            cursor: not-allowed;
        }

        /* Modal Esporta - Stili opzioni */
        .export-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            margin-top: 8px;
        }

        .export-option-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            padding: 16px 12px;
            border: 2px solid #e0e0e0;
            border-radius: 10px;
            background: white;
            cursor: pointer;
            transition: all 0.2s;
        }

        .export-option-btn:hover {
            border-color: #167D87;
            background: #f8fffe;
            transform: translateY(-2px);
        }

        .export-option-btn.export-pacs:hover {
            border-color: #9b59b6;
            background: #faf5fc;
        }

        .export-option-btn span {
            font-size: 0.8em;
            font-weight: 600;
            color: #2c3e50;
        }

        .export-option-btn.export-pacs span {
            color: #9b59b6;
        }

        #export-status {
            font-size: 0.85em;
            text-align: center;
        }

        #export-status.success {
            background: #d4edda;
            color: #155724;
        }

        #export-status.error {
            background: #f8d7da;
            color: #721c24;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .exam-card {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            .header .stats {
                display: none;
            }
        }
