/* Enhanced Overlay Styles for VOLC-TCS */
#overlay {
    display: none !important; /* Nascondi completamente l'overlay inizialmente */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 9999 !important; /* Sopra navbar Bootstrap (1030-1050) e tutto il resto */
    max-width: 100vw;
    max-height: 100vh;
    overflow: auto;
    backdrop-filter: blur(5px);
}

#overlay.active {
    display: flex !important; /* Mostra l'overlay quando è attivo */
    visibility: visible;
    opacity: 1;
}

/* Close Button Enhanced */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: #dc3545;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    z-index: 10000 !important; /* Sopra l'overlay */
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.close-btn:hover {
    background-color: #c82333;
    transform: scale(1.1);
}

/* Loading Icon Enhanced */
#loadingIcon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001 !important; /* Sopra l'overlay */
    background-color: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    text-align: center;
    font-size: 16px;
    color: #1a2a36;
}

/* Map Container */
#map-container {
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    margin: auto; /* Centra l'elemento */
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

/* DataTable Container Enhanced */
#datatable_container {
    position: relative; /* Necessario per il posizionamento corretto */
    width: 95%;
    height: 90%;
    max-width: 1400px;
    max-height: 900px;
    background-color: rgba(255, 255, 255, 0.98);
    color: #333;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: auto;
    backdrop-filter: blur(10px);
    /* Flexbox per centratura perfetta del contenuto interno */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Box sizing per includere padding nella larghezza */
    box-sizing: border-box;
}

#datatable_container.active {
    display: block !important;
}

/* Result Table Enhanced */
#result_table {
    width: 100% !important;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0; /* Margini per la spaziatura */
}

#result_table th {
    background-color: #1a2a36 !important;
    color: white !important;
    font-weight: 600;
    padding: 12px !important;
    border: none !important;
}

#result_table td {
    padding: 10px !important;
    border-bottom: 1px solid #e9ecef !important;
}

#result_table tbody tr:hover {
    background-color: rgba(26, 42, 54, 0.05) !important;
}

/* DataTable dentro il container dell'overlay */
#datatable_container .dataTables_wrapper {
    width: 100% !important;
}

#datatable_container .dataTables_scrollHead,
#datatable_container .dataTables_scrollBody {
    width: 100% !important;
}

/* Page Container for JSON/XML content */
#page_container {
    background-color: rgba(255, 255, 255, 0.98);
    color: #333;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
    overflow: auto;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    margin: auto; /* Centra l'elemento */
}

/* Enhanced pre styles for JSON/XML */
pre {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    color: #333;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #1a2a36;
}

/* Error Message Enhanced */
#overlay-error-message {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
    border-radius: 8px !important;
    padding: 15px !important;
    margin: 15px auto !important; /* Centra l'elemento */
    font-weight: 500;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 90%;
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002 !important; /* Sopra l'overlay */
}

/* IFrame styles */
#iframe {
    width: 95%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    background-color: white;
    margin: auto; /* Centra l'elemento */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #datatable_container,
    #page_container {
        width: 98%;
        height: 95%;
        padding: 15px;
    }
    
    #map-container {
        width: 98%;
        height: 95%;
    }
    
    .close-btn {
        top: 10px;
        right: 10px;
        font-size: 20px;
        padding: 6px 10px;
    }
    
    /* Assicura che l'overlay copra completamente la viewport mobile */
    #overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}

/* Responsive per tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    #datatable_container {
        width: 96%;
        height: 92%;
        padding: 25px;
    }
    
    #page_container {
        width: 94%;
        height: 92%;
        padding: 25px;
    }
}

/* DataTables wrapper enhancements */
.dataTables_wrapper {
    color: #333 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    margin-left: 8px;
}

.dataTables_length select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    margin: 0 8px;
}

.dataTables_info {
    color: #666 !important;
}

.dataTables_paginate .paginate_button {
    border-radius: 4px !important;
    margin: 2px !important;
}

.dataTables_paginate .paginate_button.current {
    background-color: #1a2a36 !important;
    color: white !important;
    border-color: #1a2a36 !important;
}

/* Assicura che nessun elemento sia visibile sopra l'overlay */
#overlay.active ~ * {
    z-index: 1 !important;
}

/* Nasconde navbar e altri elementi quando l'overlay è attivo */
body.overlay-active .navbar,
body.overlay-active .sidebar,
body.overlay-active .footer,
body.overlay-active .main-content {
    z-index: 1 !important;
}

/* Blocca lo scroll del body quando l'overlay è attivo */
body.overlay-active {
    overflow: hidden !important;
}

/* Loading Overlay Styles for Service Queries */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 42, 54, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(3px);
}

.loading-content {
    background: rgba(255, 255, 255, 0.98);
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    border: 1px solid rgba(26, 42, 54, 0.1);
}

.loading-content .spinner-border {
    border-width: 4px;
}

.loading-content .text-primary {
    color: #1a2a36 !important;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.loading-content .text-muted {
    color: #6c757d !important;
    font-size: 0.9rem;
}

/* Footer and development banner styles */
footer li {
    margin: 0 10px;
}

.development-banner {
    background-color: #ff9800;
    color: #fff;
    font-size: 12px;
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 10px;
    position: relative;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.gap-2 {
    gap: 0.5rem;
}

.nav-link {
    flex: 1;
}