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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

.upload-section {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    background: #e7e9ff;
    border-color: #764ba2;
}

.upload-area.dragover {
    background: #e7e9ff;
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-content .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.upload-content p {
    color: #6c757d;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.file-info {
    margin-top: 15px;
    padding: 15px;
    background: #d4edda;
    border-radius: 8px;
    display: none;
}

.file-info.show {
    display: block;
}

.controls-section {
    padding: 20px 30px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
}

.controls-section > div {
    flex: 1 1 auto;
    min-width: 200px;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

#searchInput {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
}

.stats {
    display: flex;
    gap: 20px;
    color: #6c757d;
    font-size: 0.9rem;
}

.stats span {
    background: #f8f9fa;
    padding: 5px 12px;
    border-radius: 15px;
}

#filteredCount {
    background: #667eea;
    color: white;
    display: none;
}

#filteredCount.show {
    display: inline-block;
}

.table-section {
    padding: 0;
    max-height: 70vh;
    overflow: auto;
    width: 100%;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

/* Tabella compatta */
.data-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: auto;
}

.data-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    font-size: 0.8rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th .col-header-text {
    display: inline-block;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.data-table td {
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
}

.data-table td:hover {
    overflow: visible;
    white-space: normal;
    word-break: break-word;
    background: #fff;
    z-index: 5;
    position: relative;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: #6c757d;
}

.empty-state .icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.empty-state .sub {
    font-size: 1rem;
    opacity: 0.7;
}

.data-table tr:hover td {
    background: #f8f9fa;
}

.data-table tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tr.filtered {
    display: none;
}

.data-table tr.highlight td {
    background: #fff3cd !important;
}

.tracking-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    background: #e7e9ff;
    padding: 4px 10px;
    border-radius: 15px;
    display: inline-block;
    transition: all 0.2s;
}

.tracking-link:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

/* Controlli colonne */
.column-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.column-selector {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.column-selector-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-selector-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.column-selector-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.column-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
}

.column-item:hover {
    background: #f8f9fa;
}

.column-item input[type="checkbox"] {
    cursor: pointer;
}

.column-item label {
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* Paginazione */
.pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pagination-controls button {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.page-info {
    padding: 6px 15px;
    background: white;
    border-radius: 6px;
    font-weight: 600;
    color: #667eea;
    border: 1px solid #e9ecef;
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #6c757d;
}

.items-per-page select {
    padding: 6px 10px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

/* Tooltip personalizzato */
.tooltip-preview {
    position: fixed;
    background: #333;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    max-width: 400px;
    word-wrap: break-word;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.tooltip-preview.show {
    opacity: 1;
}

.tooltip-preview::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #333;
}

/* Modalità compatta */
.compact-mode .data-table {
    font-size: 0.75rem;
}

.compact-mode .data-table th {
    padding: 6px 4px;
    font-size: 0.7rem;
}

.compact-mode .data-table td {
    padding: 4px;
    font-size: 0.75rem;
}

/* Tabella adattata */
.fit-mode .data-table {
    table-layout: fixed;
    width: 100%;
}

.fit-mode .data-table th,
.fit-mode .data-table td {
    max-width: none;
    word-wrap: break-word;
    white-space: normal;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .stats {
        justify-content: center;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

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