/**
 * Carichi in Arrivo - Styles
 * Version: 1.8.0
 * Integrato con QMS Core CSS e Theme Variables
 */

/* ======================
   LAYOUT
====================== */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Header Compact */
.header-compact {
    padding: 1rem 1.5rem;
    background: var(--qms-primary, #6366f1);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-compact h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

/* ======================
   ENHANCED BADGES & INDICATORS
====================== */
/* Badge Slot Prenotato (Verde) */
.badge-slot-prenotato {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--qms-success, #10b981);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
    animation: pulse-soft 2s ease-in-out infinite;
}

/* Badge Non Prenotato (Grigio) */
.badge-no-slot {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--qms-muted, #6b7280);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Countdown Timer */
.countdown-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--qms-info, #3b82f6);
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.countdown-timer.urgent {
    background: var(--qms-danger, #ef4444);
    animation: pulse-urgent 1s ease-in-out infinite;
}

.countdown-timer.soon {
    background: var(--qms-warning, #f59e0b);
}

/* Alert Ritardo */
.alert-ritardo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--qms-danger-light, rgba(239, 68, 68, 0.1));
    border-left: 4px solid var(--qms-danger, #ef4444);
    border-radius: 8px;
    margin-bottom: 1rem;
    animation: slide-in-down 0.5s ease-out;
    color: var(--qms-text, #111827);
}

.alert-ritardo .icon {
    font-size: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
}

/* Pulse Animations */
@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6); }
}

@keyframes pulse-urgent {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 4px 16px rgba(239, 68, 68, 0.8); }
}

@keyframes slide-in-down {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ======================
   KPI CARDS
====================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--qms-surface, #fff);
    border: 1px solid var(--qms-border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.kpi-icon {
    font-size: 2.5rem;
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--qms-text, #111827);
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--qms-text-muted, #6b7280);
    margin-top: 0.25rem;
}

.kpi-period {
    font-size: 0.75rem;
    color: var(--qms-text-muted, #9ca3af);
    margin-top: 0.25rem;
    font-weight: 500;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.kpi-trend.trend-up {
    color: #ef4444;
}

.kpi-trend.trend-down {
    color: #10b981;
}

.kpi-trend.trend-neutral {
    color: #6b7280;
}

.kpi-trend-icon {
    font-size: 0.875rem;
}

.kpi-success .kpi-value {
    color: var(--qms-success, #10b981);
}

.kpi-danger .kpi-value {
    color: var(--qms-danger, #ef4444);
}

/* ======================
   TOOLBAR
====================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-input {
    min-width: 250px;
    padding: 0.625rem 1rem;
    border: 1px solid var(--qms-border, #d1d5db);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--qms-surface, #fff);
    color: var(--qms-text, #111827);
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--qms-primary, #6366f1);
}

.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--qms-border, #d1d5db);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--qms-surface, #fff);
    color: var(--qms-text, #111827);
    cursor: pointer;
}

/* ======================
   TABLE
====================== */
.table-container {
    background: var(--qms-surface, #fff);
    border: 1px solid var(--qms-border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--qms-surface-alt, #f9fafb);
    border-bottom: 2px solid var(--qms-border, #e5e7eb);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--qms-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    border-bottom: 1px solid var(--qms-border-light, #f3f4f6);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.table tbody tr:hover {
    background: var(--qms-surface-hover, #f9fafb);
    border-left-color: #3b82f6;
}

/* Bordi colorati sottili basati sullo stato (miglior scansione visiva) */
.table tbody tr[data-stato="atteso"],
.table tbody tr[data-stato="in_attesa"] {
    border-left-color: #f39c12;
}

.table tbody tr[data-stato="in_verifica"] {
    border-left-color: #9b59b6;
}

.table tbody tr[data-stato="accettato"] {
    border-left-color: #10b981;
}

.table tbody tr[data-stato="respinto"] {
    border-left-color: #ef4444;
}

.table tbody tr[data-stato="parziale"] {
    border-left-color: #f59e0b;
}

.table td {
    padding: 1rem;
    font-size: 0.9375rem;
    color: var(--qms-text, #111827);
}

.loading-row {
    text-align: center !important;
    padding: 3rem 1rem !important;
    color: var(--qms-text-muted, #6b7280);
}

/* ======================
   BADGES
====================== */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
}

.badge[title] {
    cursor: help;
}

.badge-success {
    background: #10b981;
    color: #000000;
    font-weight: 600;
}

.badge-danger {
    background: #ef4444;
    color: #ffffff;
    font-weight: 600;
}

.badge-warning {
    background: #f39c12;
    color: #000000;
    font-weight: 600;
}

.badge-info {
    background: #3b82f6;
    color: #ffffff;
    font-weight: 600;
}

.badge-secondary {
    background: #6b7280;
    color: #ffffff;
    font-weight: 600;
}

/* ======================
   BUTTONS
====================== */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--qms-primary, #6366f1);
    color: white;
}

.btn-primary:hover {
    background: var(--qms-primary-dark, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.btn-secondary {
    background: var(--qms-surface-alt, #f3f4f6);
    color: var(--qms-text, #374151);
}

.btn-secondary:hover {
    background: var(--qms-border, #e5e7eb);
}

.btn-success {
    background: var(--qms-success, #10b981);
    color: white;
}

.btn-success:hover {
    background: var(--qms-success-dark, #059669);
}

.btn-danger {
    background: var(--qms-danger, #ef4444);
    color: white;
}

.btn-danger:hover {
    background: var(--qms-danger-dark, #dc2626);
}

.btn-warning {
    background: var(--qms-warning, #f59e0b);
    color: white;
}

.btn-warning:hover {
    background: var(--qms-warning-dark, #d97706);
}

.btn-info {
    background: var(--qms-info, #3b82f6);
    color: white;
}

.btn-info:hover {
    background: var(--qms-info-dark, #2563eb);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* ======================
   MODALS
====================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--qms-surface, #fff);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-lg {
    max-width: 900px;
}

.modal-xl {
    max-width: 1200px;
}

.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
    margin: 2.5vh auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--qms-border, #e5e7eb);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--qms-text, #111827);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--qms-text-muted, #9ca3af);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--qms-surface-hover, #f3f4f6);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--qms-border, #e5e7eb);
}

/* ======================
   FORMS
====================== */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #E5E7EB;
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--qms-border, #d1d5db);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--qms-surface, #fff);
    color: var(--qms-text, #111827);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--qms-primary, #6366f1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ======================
   TABS
====================== */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--qms-border, #e5e7eb);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--qms-text-muted, #6b7280);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--qms-text, #111827);
    background: var(--qms-surface-hover, #f9fafb);
}

.tab.active {
    color: var(--qms-primary, #6366f1);
    border-bottom-color: var(--qms-primary, #6366f1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ======================
   DETAILS
====================== */
.details-content {
    min-height: 200px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--qms-text-muted, #6b7280);
}

.detail-value {
    font-size: 1rem;
    color: var(--qms-text, #111827);
    font-weight: 500;
}

.details-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1.5rem;
    border-top: 1px solid var(--qms-border, #e5e7eb);
}

/* ======================
   DOCUMENTS
====================== */
.upload-section {
    padding: 1.5rem;
    background: var(--qms-surface-alt, #f9fafb);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.upload-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.125rem;
    color: var(--qms-text, #111827);
}

.docs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--qms-surface, #fff);
    border: 1px solid var(--qms-border, #e5e7eb);
    border-radius: 8px;
}

.doc-icon {
    font-size: 2rem;
}

.doc-info {
    flex: 1;
}

.doc-name {
    font-weight: 600;
    color: var(--qms-text, #111827);
}

.doc-meta {
    font-size: 0.8125rem;
    color: var(--qms-text-muted, #6b7280);
    margin-top: 0.25rem;
}

.doc-actions {
    display: flex;
    gap: 0.5rem;
}

/* ======================
   CERTIFICATES
====================== */
.cert-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.cert-valid {
    background: var(--qms-success-light, rgba(16, 185, 129, 0.1));
    border: 2px solid var(--qms-success, #10b981);
}

.cert-invalid {
    background: var(--qms-danger-light, rgba(239, 68, 68, 0.1));
    border: 2px solid var(--qms-danger, #ef4444);
}

.cert-icon {
    font-size: 3rem;
}

.cert-message {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
}

.cert-warnings,
.cert-missing {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.cert-warnings {
    background: var(--qms-warning-light, rgba(245, 158, 11, 0.1));
    border-left: 4px solid var(--qms-warning, #f59e0b);
}

.cert-missing {
    background: var(--qms-danger-light, rgba(239, 68, 68, 0.1));
    border-left: 4px solid var(--qms-danger, #ef4444);
}

.cert-warnings h4,
.cert-missing h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.cert-warnings ul,
.cert-missing ul {
    margin: 0;
    padding-left: 1.5rem;
}

.cert-warnings li,
.cert-missing li {
    margin-bottom: 0.5rem;
}

/* ======================
   EMPTY STATE
====================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    color: var(--qms-text, #111827);
}

.empty-state p {
    margin: 0 0 1.5rem;
    color: var(--qms-text-muted, #6b7280);
}

/* ======================
   ALERTS
====================== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9375rem;
}

.alert-success {
    background: var(--qms-success-light, rgba(16, 185, 129, 0.1));
    color: var(--qms-success-dark, #065f46);
    border-left: 4px solid var(--qms-success, #10b981);
}

/* ======================
   TOAST
====================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--qms-surface, white);
    color: var(--qms-text, #111827);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    min-width: 300px;
    max-width: 500px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: var(--qms-success-light, rgba(16, 185, 129, 0.1));
    color: var(--qms-success-dark, #065f46);
    border-left: 4px solid var(--qms-success, #10b981);
}

.toast-error {
    background: var(--qms-danger-light, rgba(239, 68, 68, 0.1));
    color: var(--qms-danger-dark, #991b1b);
    border-left: 4px solid var(--qms-danger, #ef4444);
}

.toast-warning {
    background: var(--qms-warning-light, rgba(245, 158, 11, 0.1));
    color: var(--qms-warning-dark, #92400e);
    border-left: 4px solid var(--qms-warning, #f59e0b);
}

.toast-info {
    background: var(--qms-info-light, rgba(59, 130, 246, 0.1));
    color: var(--qms-info-dark, #1e40af);
    border-left: 4px solid var(--qms-info, #3b82f6);
}

/* ======================
   SPINNER
====================== */
.spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid rgba(99,102,241,0.2);
    border-top-color: var(--qms-primary, #6366f1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ======================
   UTILITIES
====================== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--qms-text-muted, #6b7280);
}

/* ======================
   CARD HOVER EFFECTS
====================== */
.card {
    transition: box-shadow 0.15s ease, transform 0.05s ease;
}

.card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    transform: translateY(-2px);
}

/* ======================
   RESPONSIVE
====================== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        flex-direction: column;
    }

    .search-input {
        min-width: 100%;
    }

    .table-container {
        overflow-x: auto;
    }

    .table {
        min-width: 800px;
    }

    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .details-actions {
        flex-direction: column;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab {
        white-space: nowrap;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        min-width: 100%;
    }
}


/* ======================
   TEMPI SCARICO
====================== */
.timing-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.timeline-step {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.25rem;
    background: var(--qms-surface, white);
    border: 2px solid var(--qms-border, #e5e7eb);
    border-radius: 12px;
    transition: all 0.2s;
}

.timeline-step:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.timeline-icon {
    font-size: 2.5rem;
    min-width: 60px;
    text-align: center;
}

.timeline-info {
    flex: 1;
}

.timeline-info strong {
    font-size: 1.125rem;
    color: var(--qms-text, #111827);
}

.timing-stats .stat-box {
    padding: 1.25rem;
    background: var(--qms-surface, white);
    border: 2px solid var(--qms-border, #e5e7eb);
    border-radius: 12px;
    text-align: center;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--qms-text-muted, #6b7280);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--qms-primary, #6366f1);
}
