/* Modern Modal Styles */
.helios-modal {
    display: none;
    position: fixed;
    z-index: 12500;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Changed from hidden to auto to allow scrolling */
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.helios-modal.show {
    display: flex;
    align-items: flex-start; /* Changed from center to allow proper scrolling */
    justify-content: center;
    opacity: 1;
    padding: 1rem; /* Add padding to prevent content from touching edges */
}

.helios-modal-dialog {
    position: relative;
    width: 95%;
    max-width: 1200px; /* Adjusted max-width */
    margin: 2rem auto;
    pointer-events: none;
    transform: translateY(-30px) scale(0.95);
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    max-height: 100%; /* Ensure it doesn't exceed viewport height */
}

/* Larger dialog for extra large screens */
@media (min-width: 1600px) {
    .helios-modal-dialog {
        max-width: 1400px; /* Increased width for extra large screens */
    }
}

/* Even larger dialog for ultra wide screens */
@media (min-width: 1920px) {
    .helios-modal-dialog {
        max-width: 1600px; /* Increased width for ultra wide screens */
    }
}

/* Larger dialog for big screens */
@media (min-width: 1400px) {
    .helios-modal-dialog {
        max-width: 1400px;
    }
}

@media (min-width: 1600px) {
    .helios-modal-dialog {
        max-width: 1600px;
    }
}

.helios-modal.show .helios-modal-dialog {
    transform: translateY(0) scale(1);
}

.helios-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: none;
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    outline: 0;
    overflow: hidden;
    max-height: calc(100vh - 4rem); /* Ensure content fits in viewport with padding */
}

.helios-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem; /* Adjusted padding */
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.helios-modal-title {
    margin: 0;
    font-size: 1.8rem; /* Adjusted font size */
    font-weight: 600;
    color: #222;
    letter-spacing: -0.02em;
    width: calc(100% - 60px); /* Ensure title doesn't overlap close button */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.helios-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevent button from shrinking */
}

.helios-modal-close i {
    font-size: 1.25rem;
    line-height: 1;
}

.helios-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
    transform: rotate(90deg);
}

.helios-modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 2rem;
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Increase modal body height for larger screens */
@media (min-width: 1200px) {
    .helios-modal-body {
        max-height: 80vh; /* Increased height for big screens */
        padding: 2.5rem; /* More padding on larger screens */
    }
    
    .helios-modal-content {
        max-height: 85vh; /* Ensure content container can accommodate the larger body */
    }
    
    .helios-modal-dialog {
        margin: 3rem auto; /* More vertical space on large screens */
    }
    
    .helios-modal-header {
        padding: 2rem 2.5rem; /* Larger header padding */
    }
    
    .helios-modal-title {
        font-size: 2rem; /* Larger title on big screens */
    }
    
    /* Larger text for better readability on big screens */
    .treatment-description p,
    .helios-modal-body .item-description p {
        font-size: 1.2rem;
        line-height: 1.7;
        margin-bottom: 1.5rem;
    }
    
    .treatment-description ul li,
    .helios-modal-body .item-description ul li {
        font-size: 1.2rem;
        margin-bottom: 0.875rem;
    }
    
    .helios-modal-body h2 {
        font-size: 2rem;
        margin-bottom: 1.75rem;
    }
}

/* Larger body content for big screens */
@media (min-width: 1400px) {
    .helios-modal-body {
        padding: 2.5rem 3rem;
    }
}

@media (min-width: 1600px) {
    .helios-modal-body {
        padding: 3rem 4rem;
    }
}

/* Modern treatment content styles */
.helios-modal-body {
    display: block; /* Changed from flex to block to prevent layout issues */
}

/* For modern treatment layout */
.helios-modal-body .treatment-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Enhanced layout for larger screens */
@media (min-width: 1200px) {
    .helios-modal-body .treatment-container {
        gap: 3rem; /* Increased spacing for better readability */
    }
    
    .treatment-description {
        padding-left: 3rem; /* More spacing between image and text */
    }
}

/* Larger content spacing for big screens */
@media (min-width: 1400px) {
    .helios-modal-body .treatment-container {
        gap: 3rem;
    }
    
    .treatment-description p {
        font-size: 1.2rem;
        line-height: 1.7;
        margin-bottom: 1.5rem;
    }
    
    .treatment-description ul li {
        font-size: 1.2rem;
        margin-bottom: 0.875rem;
    }
    
    .helios-modal-body h2 {
        font-size: 2rem;
        margin-bottom: 1.75rem;
    }
}

@media (min-width: 1600px) {
    .helios-modal-body .treatment-container {
        gap: 4rem;
    }
    
    .treatment-description p {
        font-size: 1.25rem;
        line-height: 1.8;
        margin-bottom: 1.75rem;
    }
    
    .treatment-description ul li {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .helios-modal-body h2 {
        font-size: 2.25rem;
        margin-bottom: 2rem;
    }
}

/* Global fixes to prevent horizontal scrolling in modals */
.helios-modal-body * {
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
}

/* Fix for pre and code elements that might cause horizontal scrolling */
.helios-modal-body pre,
.helios-modal-body code {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Treatment image styles */
.treatment-image {
    flex: 0 0 40%;
    max-width: 40%;
}

.treatment-image img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    object-fit: cover;
    transition: transform 0.3s ease;
    max-height: 550px; /* Adjusted max height */
    display: block; /* Prevent inline spacing issues */
}

/* Larger images for big screens */
@media (min-width: 1200px) {
    .treatment-image img {
        max-height: 650px; /* Increased height for big screens */
    }
}

.treatment-image img:hover {
    transform: scale(1.02);
}

/* Treatment description styles */
.treatment-description {
    flex: 1;
    min-width: 50%;
    max-width: 60%;
    padding-left: 2rem;
}

.treatment-description p {
    margin-bottom: 1.25rem;
    line-height: 1.6;
    color: #333;
    font-size: 1.1rem; /* Adjusted font size */
}

.treatment-description ul {
    padding-left: 1.25rem;
    margin-bottom: 1.25rem;
    color: #333;
}

.treatment-description ul li {
    margin-bottom: 0.75rem;
    list-style-type: none;
    position: relative;
    padding-left: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.treatment-description ul li:before {
    content: "•";
    color: #0078d4;
    font-weight: bold;
    position: absolute;
    left: 0;
    top: 0;
    font-size: 1.2rem;
}

/* Ensure all content is properly contained */
.treatment-description * {
    max-width: 100%;
}

/* Prevent horizontal overflow */
.treatment-description table,
.treatment-description img,
.treatment-description iframe,
.treatment-description embed,
.treatment-description object {
    max-width: 100%;
    height: auto;
}

.treatment-description strong,
.treatment-description b {
    font-weight: 600;
    color: #222;
}

/* Treatment benefits section */
.treatment-benefits {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: rgba(0, 120, 212, 0.05);
    border-radius: 12px;
    border-left: 4px solid #0078d4;
}

.treatment-benefits h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #0078d4;
    font-weight: 600;
}

/* Treatment details table */
.treatment-details {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.treatment-details th,
.treatment-details td {
    padding: 0.75rem 1rem;
    text-align: left;
}

.treatment-details th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
}

.treatment-details tr:nth-child(even) {
    background-color: #f9f9f9;
}

.treatment-details tr:hover {
    background-color: #f0f7ff;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .helios-modal-body {
        padding: 1.5rem;
    }
    
    .helios-modal-body .treatment-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .treatment-image {
        flex: 0 0 100%;
        margin-bottom: 1.5rem;
        width: 100%;
        max-width: 100%;
    }
    
    .treatment-description {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        padding-left: 0;
    }
    
    .helios-modal-dialog {
        width: 95%;
        max-width: 95%;
        margin: 1rem auto;
    }
    
    .helios-modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .helios-modal-title {
        font-size: 1.6rem;
    }
    
    .treatment-description p,
    .helios-modal-body .item-description p {
        font-size: 1.1rem;
    }
    
    /* Fix for row-fluid in modals */
    .helios-modal-body .row-fluid {
        flex-direction: column;
        gap: 1rem;
    }
    
    .helios-modal-body .span4,
    .helios-modal-body .span8 {
        flex: 0 0 100%;
        width: 100%;
    }
}

@media (max-width: 767px) {
    .helios-modal.show {
        align-items: flex-start;
        padding: 0.5rem;
    }
    
    .helios-modal-dialog {
        width: 100%;
        max-width: 100%;
        margin: 0.5rem auto;
    }
    
    .helios-modal-content {
        max-height: calc(100vh - 1rem);
        border-radius: 12px;
        height: auto;
    }
    
    .helios-modal-header {
        padding: 0.875rem 1.125rem;
    }
    
    .helios-modal-title {
        font-size: 1.3rem;
    }
    
    .helios-modal-close {
        width: 36px;
        height: 36px;
    }
    
    .helios-modal-body {
        padding: 1.25rem;
        min-height: 70vh; /* Increased height for mobile view */
        height: auto;
    }
    
    .helios-modal-body .treatment-container {
        gap: 1.25rem;
        min-height: 100%;
    }
    
    .treatment-description p,
    .helios-modal-body .item-description p {
        font-size: 1rem;
        margin-bottom: 0.875rem;
        line-height: 1.5;
    }
    
    .treatment-description ul li,
    .helios-modal-body .item-description ul li {
        font-size: 1rem;
        margin-bottom: 0.5rem;
        line-height: 1.4;
    }
    
    .helios-modal-body h2 {
        font-size: 1.4rem;
        margin-bottom: 0.875rem;
    }
    
    /* Ensure images are responsive */
    .helios-modal-body img {
        max-width: 100%;
        height: auto;
    }
    
    /* Fix for horizontal scrolling */
    .helios-modal-body {
        overflow-x: hidden;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Ensure tables don't cause horizontal scrolling */
    .helios-modal-body table {
        width: 100% !important;
        max-width: 100%;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for treatment image on mobile */
    .treatment-image {
        margin-bottom: 1rem;
    }
    
    .treatment-image img {
        max-height: 350px !important;
    }
    
    /* Fix for any fixed width elements */
    .helios-modal-body [style*="width"] {
        max-width: 100% !important;
        width: auto !important;
    }
}


/* Legacy content styling improvements */
.helios-modal-body .row-fluid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    width: 100%;
}

.helios-modal-body .span4 {
    flex: 0 0 40%;
    max-width: 40%;
}

.helios-modal-body .span8 {
    flex: 1;
    min-width: 50%;
    max-width: 60%;
    padding-left: 1rem;
}

.helios-modal-body .item-description {
    margin-top: 1rem;
}

.helios-modal-body .item-description p {
    margin-bottom: 1.25rem;
    line-height: 1.6;
    color: #333;
    font-size: 1.1rem; /* Adjusted font size */
}

.helios-modal-body .item-description ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.helios-modal-body .item-description ul li {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.helios-modal-body h2 {
    font-size: 1.8rem; /* Adjusted heading size */
    font-weight: 600;
    color: #222;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

/* Fix for old picture class */
.helios-modal-body .picture {
    width: 100% !important;
    height: auto !important;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.helios-modal-body .picture img {
    width: 100% !important;
    height: auto !important;
    max-height: 550px !important; /* Adjusted max height */
    display: block;
    transition: transform 0.3s ease;
    object-fit: cover;
}

.helios-modal-body .picture img:hover {
    transform: scale(1.02);
}

/* Responsive fixes for legacy content */
@media (max-width: 991px) {
    .helios-modal-body .row-fluid {
        flex-direction: column;
        gap: 1rem;
    }
    
    .helios-modal-body .span4,
    .helios-modal-body .span8 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-left: 0;
    }
    
    .helios-modal-body h2 {
        font-size: 1.6rem;
        margin-bottom: 1.25rem;
    }
    
    .helios-modal-body .picture {
        margin-bottom: 1.25rem;
    }
    
    .helios-modal-body .picture img {
        max-height: 450px !important;
    }
}

/* Additional mobile fixes */
@media (max-width: 767px) {
    .helios-modal-body .row-fluid {
        gap: 0.75rem;
    }
    
    .helios-modal-body h2 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    .helios-modal-body .item-description p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .helios-modal-body .item-description ul li {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    /* Ensure all content is properly contained */
    .helios-modal-body * {
        max-width: 100%;
    }
    
    /* Fix for tables in modals */
    .helios-modal-body table {
        display: block;
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for images in modals */
    .helios-modal-body img {
        max-width: 100%;
        height: auto !important;
    }
}
