/* Common CSS for Panel Application */

/* Base styles */
body { 
    max-width: 1440px; 
    margin: 20px auto; 
    padding: 0 20px; 
    font-family: Arial, sans-serif; 
    line-height: 1.4; 
}

/* Form elements */
.form-group { 
    margin-bottom: 15px; 
}
label { 
    display: block; 
    margin-bottom: 6px; 
    font-size: 16px; 
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"], 
textarea, input[type="file"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

input[type="time" i], input#expiring_courses_time, 
input#expiring_documents_time, input#expired_courses_time, input#expired_documents_time, 
input#important_docs_time, input#reports_time {
    width: 100px;
    padding: 12px;
    margin-bottom: 12px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

select {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

textarea { 
    height: 180px; 
}

/* Info and warning boxes */
.info { 
    background-color: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    display: none; /* Hidden by default */
    margin-top: 12px;
}

.info-status { 
    background-color: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
}

.info.info-visible {
    display: block; /* Show when toggled */
}

.info-dark {
    background-color: #e0e0e0;
    padding: 12px;
    border-radius: 6px;
    display: none; /* Hidden by default */
    margin-top: 12px;
}

.info-dark.info-visible {
    display: block; /* Show when toggled */
}

.warning { 
    background: #fff3cd; 
    color: #856404; 
    padding: 12px; 
    border: 1px solid #ffeeba;
    border-radius: 6px;
}

/* Manual toggle button styles */
.manual-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: nowrap; /* Keep title and button on same row */
}

.manual-toggle-wrapper > *:first-child {
    flex: 1 1 auto; /* Allow title to grow and shrink */
    min-width: 0; /* Allow title to shrink below content size */
    word-wrap: break-word; /* Break long words if needed */
    overflow-wrap: break-word;
}

.manual-toggle-btn {
    background-color: #8b7355 !important; /* Neutral brown color */
    color: white !important;
    padding: 8px 14px !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 0.9em !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    transition: background-color 0.2s !important;
    flex-shrink: 0 !important;
    width: auto !important;
    margin: 0 !important;
}

.manual-toggle-btn:hover {
    background-color: #6d5a44 !important;
}

.manual-toggle-btn svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.manual-toggle-btn .btn-text {
    display: inline;
}

/* Mobile: only show icon */
@media (max-width: 1000px) {
    .manual-toggle-btn {
        padding: 8px !important;
        min-width: auto !important;
    }
    
    .manual-toggle-btn .btn-text {
        display: none;
    }
    
    .manual-toggle-btn svg {
        width: 20px;
        height: 20px;
    }
}

/* Buttons */
button {
    background-color: #0c5aff;
    color: white;
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    text-decoration: none !important;
    text-align: center !important;
}

button:hover { 
    background-color: #2563eb; 
}

/* Center SVG icons in all buttons */
button svg,
a svg {
    flex-shrink: 0;
    vertical-align: middle;
    display: inline-block;
}

/* Icon heading class - centers icon and text horizontally */
.icon-element    {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-element svg {
    vertical-align: middle;
    flex-shrink: 0;
    width: 25px;
    height: 25px;
}

.remove-btn {
    background-color: #dc3545;
    color: white;
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    margin-left: 10px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}

.remove-btn:hover {
    background-color: #c82333;
}

input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    transform: scale(1.2);
}

/* Attachment interface styles */
.attachment-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.attachment-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.attachment-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.attachment-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

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

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

.attachment-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.attachment-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    transition: all 0.2s;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    text-align: center !important;
}

/* Center SVG icons vertically in action-btn buttons */
.action-btn svg {
    vertical-align: middle;
    flex-shrink: 0;
}

.action-btn:hover {
    background: #f8f9fa;
    border-color: #0c5aff;
}

.action-btn.download {
    background: #0c5aff;
    color: white;
    border-color: #0c5aff;
}

.action-btn.download:hover {
    background: #2563eb;
}

.action-btn.remove {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.action-btn.remove:hover {
    background: #c82333;
}

.upload-area {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: #0c5aff;
    background: #f0f8ff;
}

.upload-text {
    font-size: 16px;
    color: #666;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 12px;
    color: #999;
}

.btn-row { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 10px; 
}

/* Ensure links wrapping buttons are never underlined */
a,
a:link,
a:visited,
a:hover,
a:active {
    text-decoration: none !important;
}

/* Tab navigation styles */
nav[aria-label="Tabs"] {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
}

nav[aria-label="Tabs"] button {
    margin: 0px 8px;
}

.tab-navigation {
    padding: 10px 0px;
    display: block;
}

.tab-button {
    background: none;
    border: 3px solid transparent;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 16px 4px;
    white-space: nowrap;
}

.tab-button.active {
    border: 3px solid #0c5aff;
    color: #0c5aff;
}

.tab-button:hover {
    color: white;
    background-color: #2563eb;
}

/* Mobile Navigation Styles */
.mobile-header-wrapper {
    position: relative;
}

.mobile-nav-header {
    display: none;
}

.mobile-nav-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.mobile-nav-actions {
    display: none;
    align-items: center;
    gap: 16px;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.mobile-settings-btn {
    background-color: transparent;
    color: #374151;
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.mobile-settings-btn:hover {
    background-color: #f3f4f6;
}

.mobile-settings-btn svg {
    width: 24px;
    height: 24px;
}

.settings-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
    z-index: 1;
    color: #374151;
    transition: background-color 0.2s;
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

.mobile-menu-toggle:hover {
    background-color: #f3f4f6;
    color: #374151;
}

/* Subtab navigation styles */
.subtab-navigation {
    padding: 10px 0px;
}

.subtab-navigation nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
}

.subtab-button {
    background: none;
    border: 3px solid transparent;
    color: #6b7280;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 12px 4px;
    margin-right: 24px;
    white-space: nowrap;
    flex-shrink: 0;
}

.subtab-button.active {
    border: 3px solid #0c5aff;
    color: #0c5aff;
}

.subtab-button:hover {
    color: white;
    background-color: #2563eb;
}

.tab-content {
    min-height: 400px;
}


/* Dashboard styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #374151;
}

.stats-row {
    display: flex;
    margin-bottom: 8px;
}

.stat-label {
    color: #6b7280;
    margin-right: 8px;
}

.stat-value {
    font-weight: 600;
    color: #374151;
}

/* Table styles */
.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;    
    border-radius: 6px;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

table { 
    border-collapse: collapse; 
    width: 100%; 
    min-width: 900px; 
}

th, td { 
    border: 1px solid #ccc; 
    padding: 8px; 
    text-align: left; 
    white-space: nowrap; 
}

/* Document table specific alignment - first column left, others center */
.document-table th:not(:first-child),
.document-table td:not(:first-child) {
    text-align: center;
}

/* Tax code visibility toggle styles */
.tax-code-toggle {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tax-code-toggle label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
}

.tax-code-toggle input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    transform: scale(1.2);
}

/* Hide tax code toggle in print */
@media print {
    .tax-code-toggle {
        display: none !important;
    }
}

/* Fixed columns for courses tables - like Excel freeze panes */
.courses-table {
    border-collapse: separate;
    border-spacing: 0;
}

.courses-table th:first-child,
.courses-table td:first-child {
    position: sticky;
    left: 0 !important;
    z-index: 2;
    background: #f2f2f2;
}

.courses-table td:first-child {
    background: #fff;
}

.courses-table th:nth-child(2),
.courses-table td:nth-child(2) {
    position: sticky;
    z-index: 2;
    background: #f2f2f2;
}

.courses-table td:nth-child(2) {
    background: #fff;
}

.courses-table th:nth-child(3),
.courses-table td:nth-child(3) {
    position: sticky;
    z-index: 2;
    background: #f2f2f2;
    border-right: 3px solid #999;
}

.courses-table td:nth-child(3) {
    background: #fff;
}

/* Prevent border collapse on sticky columns */
.courses-table th:first-child,
.courses-table td:first-child,
.courses-table th:nth-child(2),
.courses-table td:nth-child(2) {
    box-shadow: 2px 0 0 0 #999;
}

.courses-table th:nth-child(3),
.courses-table td:nth-child(3) {
    box-shadow: 3px 0 5px -2px rgba(0,0,0,0.2);
}

/* Ensure headers stay fixed when scrolling vertically */
.courses-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.courses-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f2f2f2 !important;
}

/* Ensure header cells with both horizontal and vertical stickiness have higher z-index */
.courses-table th:first-child,
.courses-table th:nth-child(2),
.courses-table th:nth-child(3) {
    z-index: 6 !important;
}

/* Ensure sticky columns have proper background in print */
@media print {
    .courses-table th:first-child,
    .courses-table td:first-child,
    .courses-table th:nth-child(2),
    .courses-table td:nth-child(2),
    .courses-table th:nth-child(3),
    .courses-table td:nth-child(3) {
        background: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

th { 
    background: #f2f2f2; 
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Filter controls styles */
.filter-section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.filter-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: nowrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group.azienda {
    flex: 0 0 30%;
}

.filter-group.corso {
    flex: 0 0 30%;
}

.filter-group.giorni {
    flex: 0 0 10%;
}

.filter-group.aggiorna {
    flex: 1 1 auto;
    min-width: 0;
}

.filter-group.pulisci {
    flex: 1 1 auto;
    min-width: 0;
}

.filter-group label {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #495057;
}

/* FIX: Allineamento elementi filtri - tutti alla stessa altezza di 48px */
.filter-group select,
.filter-group input[type="number"],
.filter-group button {
    min-height: 48px;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 1em;
    box-sizing: border-box;
    margin-bottom: 0;
    width: 100%;
}

/* Specific button styles for filter groups */
.filter-group button {
    padding: 2px 4px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    flex-shrink: 1;
    line-height: 1.2;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

/* Center SVG icons vertically in filter-group buttons */
.filter-group button svg {
    vertical-align: middle;
    flex-shrink: 0;
}

.filter-group .select2-container {
    margin-bottom: 0;
}

.filter-group .select2-container .select2-selection--single {
    height: 48px !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    padding: 0;
    display: flex;
    align-items: center;
}

.filter-group .select2-container .select2-selection--single .select2-selection__rendered {
    padding: 0 8px;
    line-height: 1;
    color: #495057;
}

.filter-group .select2-container .select2-selection--single .select2-selection__arrow {
    height: 46px;
    right: 8px;
}

.filter-group button {
    background: #6c757d;
    color: white;
    cursor: pointer;
}

.filter-group button:hover {
    background: #5a6268;
}

/* Specific styles for "Pulisci filtri" button to make it more compact */
.filter-group.pulisci button {
    padding: 1px 3px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.1;
}

/* Green style for "Aggiorna" buttons */
.filter-group.aggiorna button {
    background: #28a745;
    color: white;
}

.filter-group.aggiorna button:hover {
    background: #218838;
}

/* General green button class for all "Aggiorna" buttons */
.btn-aggiorna {
    background: #28a745 !important;
    color: white !important;
    border: 1px solid #28a745 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
}

.btn-aggiorna:hover {
    background: #218838 !important;
    border: 1px solid #218838 !important;
}

/* Center SVG icons vertically in btn-aggiorna buttons */
.btn-aggiorna svg {
    vertical-align: middle;
    flex-shrink: 0;
}

/* Stats specific styles */
.stats {
    background: #e9ecef;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 1em;
    color: #495057;
}

/* Report template specific styles */
.duration-controls { 
    display: flex;
    flex-direction: column;
    gap: 10px; 
    margin: 15px 0; 
    padding: 12px; 
    background: #f8f9fa; 
    border-radius: 6px; 
    border: 1px solid #dee2e6;
    box-sizing: border-box;
}

.duration-controls label { 
    font-weight: bold; 
}

.duration-controls input[type="number"] { 
    width: 80px; 
    padding: 6px 8px; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    font-size: 16px;
}

.control-row-1 {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-row-2 {
    display: flex;
    align-items: center;
}

/* Ensure vertical centering for checkbox row within duration controls */
.control-row-2 label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.control-row-2 input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 0;
    vertical-align: middle;
}

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

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

/* Align controls in duration row perfectly on one baseline */
.duration-controls .input-group label {
    margin-bottom: 0;
}

.duration-controls .input-group input[type="number"] {
    height: 48px; /* match button height for perfect vertical alignment */
    margin-bottom: 0;
}

.duration-controls .button-group button {
    height: 48px; /* unify height with number input */
}

.muted {
    color: #666;
    text-align: center;
    padding: 40px;
    font-style: italic;
}

/* Desktop: tutto sulla stessa riga */
@media (min-width: 1001px) {
    .control-row-1 {
        flex-direction: row;
        flex-wrap: nowrap;
    }
}

/* Mobile: layout verticale */
@media (max-width: 1000px) {
    .duration-controls {
        width: 100%;
    }
    
    .control-row-1 {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }
    
    .control-row-2 {
        display: flex;
        gap: 10px;
    }
    
    .control-row-2 input[type="checkbox"] {
        flex-shrink: 0;
        margin-top: 2px;
    }
    
    .input-group {
        flex-direction: row;
        align-items: center;
        width: 100%;
    }
    
    .input-group label {
        flex: 0 0 auto;
    }
    
    .input-group input[type="number"] {
        flex: 1;
        min-width: 0;
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .button-group button {
        width: 100%;
        padding: 12px;
        font-size: 1em;
    }
}

/* Company management specific styles */
.company-row { 
    transition: background-color 0.2s; 
}

.company-row:hover { 
    background-color: #f8f9fa; 
}

.active-company { 
    background-color: #d4f6d4; 
}

.inactive-company { 
    background-color: #ffe6e6; 
}

.status-indicator { 
    font-weight: bold; 
    text-align: center; 
}

.status-active { 
    color: #28a745; 
}

.status-inactive { 
    color: #dc3545; 
}

.filter-controls { 
    margin: 15px 0; 
    padding: 10px; 
    background: #f8f9fa; 
    border-radius: 6px; 
}

.filter-controls label { 
    font-size: 16px; 
    display: inline-flex;            /* center checkbox and text vertically */
    align-items: center; 
    margin: 0; 
}

/* Ensure filter controls row contents are vertically centered */
.filter-controls .controls-row {
    align-items: center;
}

.filter-controls .checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-controls input[type="text"] { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid #ccc; 
    border-radius: 6px; 
    margin-bottom: 12px; 
    height: 48px;                    /* match typical control height */
}

.filter-controls input[type="checkbox"] { 
    margin-right: 8px; 
    transform: scale(1.2); 
    vertical-align: middle;          /* baseline fix */
    margin-top: 0;                   /* remove upward shift */
}

.company-selector { 
    margin: 20px 0; 
}

.company-selector select { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid #ccc; 
    border-radius: 6px; 
    font-size: 16px; 
}

/* Document mapping specific styles */
.mapping-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.mapping-row input {
    flex: 1;
    margin-bottom: 0;
}

.mapping-row button {
    margin: 0;
    padding: 8px 12px;
    font-size: 1em;
}

/* Danger button style */
button.danger { 
    background: #dc3545; 
}

button.danger:hover { 
    background: #c82333; 
}

/* Document management specific styles */
.document-row { 
    transition: background-color 0.2s; 
}

.document-row:hover { 
    background-color: #f8f9fa; 
}

.active-document { 
    background-color: #d4f6d4; 
}

.inactive-document { 
    background-color: #ffe6e6; 
}

/* Configuration template specific styles */
.status-info { 
    background: #e7f3ff; 
    padding: 12px; 
    border-radius: 6px; 
    margin: 12px 0; 
    border-left: 4px solid #0066cc; 
}

/* Popup container for notifications */
#popup-container { 
    position: fixed; 
    top: 20px; 
    right: 20px; 
    z-index: 1000; 
    max-width: 400px;
}

.notification {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.5s ease-out;
}

.notification-success { 
    border-left-color: #10b981;
    color: #065f46;
}

.notification-error { 
    border-left-color: #ef4444;
    color: #991b1b;
}

.notification-info { 
    border-left-color: #3b82f6;
    color: #1e40af;
}

.notification-warning { 
    border-left-color: #f59e0b;
    color: #92400e;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Gray button styling for "Torna al pannello" buttons */
button.nav {
    background-color: #6c757d !important;
    color: white !important;
    border: 1px solid #6c757d !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    text-decoration: none !important;
    text-align: center !important;
}

button.nav:hover {
    background-color: #5a6268 !important;
    border: 1px solid #5a6268 !important;
}

/* Center SVG icons vertically in nav buttons */
button.nav svg {
    vertical-align: middle;
    flex-shrink: 0;
}

.top-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.select2-dropdown {
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
}

/* Nascondi il bottone clear di Select2 e previeni spazio vuoto */
.select2-selection__clear {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    position: absolute !important;
    visibility: hidden !important;
}

/* Stili Select2 generali per tutta l'applicazione */
.select2-container--default .select2-selection--single {
    height: 48px !important;
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
}

/* Assicurati che la selezione non abbia padding extra per il bottone clear nascosto */
.select2-container--default .select2-selection--single.select2-selection--clearable {
    padding-right: 30px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-right: 0 !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 46px !important;
    padding-left: 8px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 8px !important;
    font-size: 1em !important;
}

.select2-dropdown {
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
}

/* Stili per ordinamento tabelle */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
    transition: background-color 0.2s;
}

.sortable-header:hover {
    background-color: #e8e8e8 !important;
}

.sort-arrow {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.sortable-header:hover .sort-arrow {
    opacity: 1;
}

.sort-arrow.active {
    opacity: 1;
    color: #007bff;
}

/* Loading overlay styles */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin-top: 20px;
    text-align: center;
}

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

.header-controls { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
}

.settings-btn { 
    background-color: #0c5aff; 
    color: white; 
    padding: 12px 16px; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 1em; 
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.settings-btn:hover { 
    background-color: #2563eb; 
}

/* Report options styles */
.report-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin: 20px 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.report-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #333;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allows flex items to shrink below their content size */
}

.report-card:hover {
    border-color: #4CAF50;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-decoration: none;
    color: #333;
}

.report-card h3 {
    margin: 0 0 10px 0;
    color: #4CAF50;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.report-card p {
    margin: 0;
    color: #666;
    font-size: 1em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    flex: 1;
}

/* Mobile-first adjustments */
@media (max-width: 1000px) {
    body { 
        margin: 10px; 
        padding: 0 12px; 
    }
    h1, h2 { 
        font-size: 1.25rem; 
    }
    label { 
        font-size: 16px; 
    }

    button, input, select, textarea { 
        font-size: 16px; 
    }

    .btn-row button { 
        flex: 1 1 100%; 
    }

    .btn-row a { 
        flex: 1 1 100%; 
    }

    .btn-row a button { 
        width: 100% !important;
    }

    button { 
        width: 100%; 
        margin: 5px 0; 
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Ensure all button types have centered text on mobile */
    .action-btn,
    .btn-aggiorna,
    button.nav,
    button.danger,
    .remove-btn,
    .filter-group button {
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .top-controls { 
        flex-direction: column; 
    }

    .top-controls button, .top-controls a { 
        width: 100%; 
        text-align: center !important;
    }

    .top-controls a button { 
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }

    form button[type="submit"] { 
        width: 100%; 
        margin: 10px 0; 
        text-align: center !important;
        justify-content: center !important;
    }

    a { 
        display: block !important; 
        width: 100% !important; 
    }

    a button { width: 100% !important; }

    .tab-button { 
        margin-right: 16px; 
        font-size: 13px; 
    }


    .tab-navigation {
        display: none;
        background: white;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        padding: 0;
        margin: 0;
    }

    .tab-navigation.mobile-menu-open {
        display: block;
    }

    .tab-navigation nav {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 0;
    }

    .tab-navigation .tab-button {
        width: 100%;
        text-align: left;
        padding: 12px 16px;
        margin: 0;
        border: none;
        border-left: 3px solid transparent;
        border-radius: 0;
    }

    .tab-navigation .tab-button.active {
        border-left: 3px solid #0c5aff;
        background-color: #f0f8ff;
    }

    .tab-navigation .tab-button:hover {
        background-color: #e5f2ff;
        color: #0c5aff;
    }

    .dashboard-grid { 
        grid-template-columns: 1fr; 
    }

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

    .filter-group { 
        flex: 1 1 100% !important;
        margin-bottom: 10px;
    }

    .stats-row { 
        justify-content: space-between; 
    }

    /* Exception: keep per-row remove buttons compact on mobile */
    .mapping-row button {
        width: auto;
        flex: 0 0 auto;
        display: inline-block;
    }

    /* Exception: keep subtab buttons on same row on mobile */
    .subtab-navigation nav {
        flex-wrap: nowrap;
    }

    .subtab-button {
        width: auto;
        flex: 0 0 auto;
    }

    /* Hide desktop header controls on mobile (we have mobile nav header instead) */
    .header-controls {
        display: none;
    }

    /* Show mobile nav actions on mobile - positioned on right side of h1 */
    .mobile-nav-actions {
        display: flex !important;
    }

    /* Hide hr after h1 on mobile */
    h1 + hr {
        display: none !important;
    }

    /* Align h1 to left on mobile */
    h1 {
        text-align: left !important;
    }

    /* Make nav buttons hover light gray on mobile instead of blue */
    .tab-navigation .tab-button:hover {
        color: #6b7280 !important;
        background-color: #f3f4f6 !important;
    }

    .report-options { 
        grid-template-columns: 1fr; 
        gap: 12px;
        margin: 15px 0;
    }

    .report-card { 
        padding: 15px; 
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .report-card h3 {
        font-size: 1.1em;
    }
    
    .report-card p {
        font-size: 0.9em;
    }
}
