/* Shared Modal Styles */
.modal {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-x: hidden;
    overflow-y: auto;
    transition: opacity 0.3s ease;
    opacity: 1;
    padding-top: 30px;
    padding-bottom: 30px;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.in,
.modal.show {
    display: block !important;
    opacity: 1 !important;
}

/* Modal width controls */
.modal-dialog {
    position: relative;
    margin: 30px auto !important;
    width: calc(100% - 60px) !important;
    max-width: 750px !important;
    min-width: 280px !important;
    top: 0 !important;
    transform: none !important;
    transition: width 0.3s ease !important;
}

.modal-content {
    position: relative;
    background-color: #ddd;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
    background-clip: padding-box;
    outline: 0;
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100% !important; /* Force content to fit inside dialog */
    max-width: 100% !important; /* Ensure content never exceeds dialog */
    overflow: hidden !important; /* Prevent overflow */
}

/* Force the modal body to respect container width */
.modal-body {
    color: black;
    font-size: 1.3rem;
    line-height: 1.5;
    position: relative;
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden !important; /* Prevent horizontal overflow */
    width: 100% !important; /* Force width to match container */
    word-wrap: break-word !important; /* Force text wrapping */
}

/* Ensure all content inside the modal respects width */
.modal-body * {
    max-width: 100% !important; /* Ensure all children respect container width */
    box-sizing: border-box !important; /* Include padding in width calculations */
}

/* Modal structure elements */
.modal-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-title {
    margin: 0;
    font-size: 2rem;
    font-weight: bold;
}

.modal-footer {
    padding: 15px;
    text-align: right;
    border-top: 1px solid #e5e5e5;
}

/* Close button */
.modal .close {
    float: right;
    font-size: 21px;
    font-weight: bold;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    opacity: 0.2;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.modal .close:hover {
    opacity: 0.5;
}

/* Modal open body style */
body.modal-open {
    overflow: hidden;
    padding-right: 15px; /* Match Bootstrap's padding adjustment */
}

/* Override Bootstrap's modal-open padding */
body.modal-open {
    padding-right: 0 !important;
}

/* EULA Content Styles */
#eulaContent {
    font-size: 14px;
    line-height: 1.5;
}

#eulaContent strong {
    font-weight: bold;
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
}

#eulaContent p {
    margin-bottom: 10px;
}

#eulaContent ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

#eulaContent ul li {
    margin-bottom: 5px;
}

/* Modal Typography */
.modal h2 {
    font-size: 24px;
    margin-bottom: 20px;
}

.modal h3 {
    font-size: 18px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal p, .modal ul {
    margin-bottom: 15px;
}

.modal ul {
    padding-left: 20px;
}

.modal ul li {
    margin-bottom: 5px;
}

.eula-content {
    padding: 15px;
}

/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-backdrop.in {
    opacity: 0.5;
}

/* RESPONSIVE BREAKPOINTS - CONSOLIDATED */
/* Large screens to medium screens */
@media (max-width: 992px) {
    .modal-dialog {
        max-width: 650px;
        width: calc(100% - 40px);
    }
}

/* Medium screens to small screens */
@media (max-width: 768px) {
    .modal-dialog {
        max-width: 550px;
        width: calc(100% - 30px);
    }
}

/* Small screens and below */
@media (max-width: 576px) {
    /* Generic modal styles */
    .modal-dialog {
        max-width: 95% !important;
        width: 95% !important;
        margin: 10px auto !important;
    }
    
    .modal-content {
        border-radius: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Specific targeting for our modals */
    #eulaModal .modal-dialog,
    #tos .modal-dialog {
        width: 90% !important;
        max-width: 450px !important;
        margin: 20px auto !important;
    }
    
    #eulaModal .modal-content,
    #tos .modal-content {
        max-width: 450px !important; 
        width: 100% !important;
    }
    
    /* Make close button easier to tap */
    .modal-header .close {
        font-size: 28px;
        padding: 8px 12px; 
        margin: -8px; 
    }
    
    /* Improve scrolling area */
    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 15px;
        font-size: 1.1rem;
    }
    
    /* Title should be smaller on mobile 
    .modal-title {
        font-size: 1.3rem;
    }
    */
    
    /* Improve footer button */
    .modal-footer .btn {
        min-width: 80px;
        padding: 8px 16px;
    }
    
    /* Adjust content padding */
    .eula-content {
        padding: 10px;
    }
}

/* Mobile screens */
@media (max-width: 480px) {
    .modal-dialog,
    #tos .modal-dialog {
        width: 92% !important;
        max-width: 360px !important;
        margin: 15px auto !important;
    }
    
    .modal-content,
    #tos .modal-content {
        max-width: 360px !important;
        width: 100% !important;
    }
}

/* Small mobile screens */
@media (max-width: 375px) {
    .modal-dialog,
    #tos .modal-dialog {
        width: 95% !important;
        max-width: 330px !important;
        margin: 10px auto !important;
    }
    
    .modal-content,
    #tos .modal-content {
        max-width: 330px !important;
        width: 100% !important;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .modal-dialog,
    #tos .modal-dialog {
        width: 95% !important;
        max-width: 300px !important;
        margin: 10px auto !important;
    }
    
    .modal-content,
    #tos .modal-content {
        max-width: 300px !important;
        width: 100% !important;
    }
    
    .modal-body {
        padding: 10px;
        max-height: 55vh;
    }
}