/* ========== MODAL STYLES (LEGAL DOCUMENTS & CONTACT) ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto !important; /* Allow scrolling on modal background */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.modal.show {
    display: flex;
    align-items: flex-start; /* Changed from center to allow scrolling */
    justify-content: center;
    padding: 20px 0; /* Add padding for smaller screens */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, var(--white), var(--lavender-pale));
    margin: 20px auto;
    border-radius: 20px;
    max-width: 600px;
    width: 95%;
    box-shadow: 0 20px 60px var(--shadow-dark);
    position: relative;
    animation: slideUp 0.4s ease;
    border: 2px solid var(--golden-yellow);
    max-height: calc(100vh - 40px); /* Prevent overflow beyond viewport */
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--white);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10001;
    border: 2px solid rgba(255, 255, 255, 0.3);
    line-height: 1;
}

.close-modal:hover {
    color: var(--white);
    background: var(--plum-deep);
    transform: rotate(90deg);
    border-color: var(--golden-yellow);
}

/* Make close button more visible on mobile */
@media (max-width: 768px) {
    .close-modal {
        width: 48px;
        height: 48px;
        font-size: 32px;
        background: rgba(119, 65, 123, 0.8);
        border: 2px solid var(--golden-yellow);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
}

.modal-header {
    background: linear-gradient(135deg, var(--plum-deep), var(--fuchsia-muted));
    padding: 30px 30px 20px;
    border-radius: 18px 18px 0 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.3;
    animation: float 20s linear infinite;
}

.modal-icon {
    font-size: 2.5rem;
    color: var(--golden-yellow);
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.2);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 15px;
    border: 3px solid var(--golden-yellow);
}

.modal-header h2 {
    color: var(--white);
    margin: 0;
    font-size: 1.8rem;
    position: relative;
    z-index: 1;
    word-wrap: break-word;
}

.modal-body {
    padding: 30px;
    overflow-y: auto !important; /* Force scrollable body */
    -webkit-overflow-scrolling: touch;
    flex: 1; /* Take remaining space */
    max-height: calc(80vh - 150px); /* Adjust based on header size */
}

.modal-message {
    text-align: center;
    font-size: 1.2rem;
    color: var(--plum-deep);
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px dashed var(--lavender-purple);
    font-weight: 500;
}

.modal-section {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.modal-section:hover {
    transform: translateX(5px);
    border-color: var(--floral-pink);
    box-shadow: 0 5px 15px rgba(200, 106, 165, 0.1);
}

.modal-section i {
    font-size: 2rem;
    color: var(--floral-pink);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--lavender-pale), var(--periwinkle-pale));
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-section h3 {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-section p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Contact Modal Specific Styles */
.contact-modal-content .modal-body {
    max-height: calc(80vh - 150px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 25px;
}

.contact-form {
    margin-top: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--plum-deep);
    font-weight: 600;
    font-size: 0.95rem;
}

.form-group label i {
    margin-right: 8px;
    color: var(--floral-pink);
    width: 20px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--periwinkle-pale);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Open Sans', sans-serif;
    transition: all 0.3s ease;
    background: var(--white);
    -webkit-appearance: none; /* Fix for iOS */
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--floral-pink);
    box-shadow: 0 0 0 3px rgba(200, 106, 165, 0.1);
}

.submit-btn {
    width: 100%;
    padding: 14px !important;
    font-size: 1.1rem !important;
    margin-top: 10px;
    margin-bottom: 10px;
}

.form-success {
    text-align: center;
    padding: 30px 20px;
}

.form-success i {
    font-size: 4rem;
    color: #4CAF50;
    margin-bottom: 20px;
}

/* ========== MOBILE RESPONSIVE MODAL STYLES ========== */
@media (max-width: 768px) {
    .modal.show {
        padding: 10px 0;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 92%;
        margin: 15px auto;
        max-height: calc(100vh - 30px);
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 20px 20px 15px;
    }
    
    .modal-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        margin-bottom: 10px;
    }
    
    .modal-header h2 {
        font-size: 1.5rem;
        padding-right: 40px; /* Make room for close button */
    }
    
    .modal-body {
        padding: 20px;
        max-height: calc(100vh - 180px);
    }
    
    .modal-message {
        font-size: 1rem;
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .modal-section {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 18px 15px;
        margin-bottom: 15px;
    }
    
    .modal-section i {
        margin: 0 auto;
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
    }
    
    .modal-section h3 {
        font-size: 1.1rem;
    }
    
    .modal-section p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* Contact modal specific mobile */
    .contact-modal-content .modal-body {
        max-height: calc(100vh - 160px);
        padding: 15px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .submit-btn {
        padding: 14px !important;
        font-size: 1rem !important;
    }
    
    .form-success {
        padding: 25px 15px;
    }
    
    .form-success i {
        font-size: 3.5rem;
    }
    
    .form-success h3 {
        font-size: 1.3rem;
    }
    
    .form-success p {
        font-size: 0.95rem;
    }
    
    .close-success-btn {
        padding: 12px 25px;
        font-size: 0.95rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 10px auto;
    }
    
    .modal-header {
        padding: 15px 15px 10px;
    }
    
    .modal-icon {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
        padding-right: 35px;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(100vh - 150px);
    }
    
    .modal-section {
        padding: 15px 12px;
        gap: 12px;
    }
    
    .modal-section i {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .modal-section h3 {
        font-size: 1rem;
    }
    
    .modal-section p {
        font-size: 0.85rem;
    }
    
    .close-modal {
        width: 40px;
        height: 40px;
        font-size: 28px;
        right: 10px;
        top: 10px;
    }
}

/* Handle very small devices */
@media (max-width: 360px) {
    .modal-body {
        padding: 12px;
    }
    
    .modal-section {
        padding: 12px 10px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px 10px;
    }
}

/* Landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .modal.show {
        align-items: center;
        padding: 5px 0;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 10px 15px 5px;
    }
    
    .modal-icon {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    .modal-body {
        max-height: 70vh;
        padding: 15px;
    }
    
    .modal-section {
        padding: 12px;
        margin-bottom: 10px;
    }
    
    .modal-section i {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    
    /* Contact form in landscape */
    .contact-modal-content .modal-body {
        max-height: 70vh;
    }
    
    .form-group {
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 6px 10px;
    }
}

/* Ensure touch targets are large enough */
@media (max-width: 768px) {
    .close-modal,
    .submit-btn,
    .close-success-btn,
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-group label {
        padding: 5px 0;
    }
    
    /* Make links in modals more tappable */
    .modal-section a,
    .modal-message a {
        padding: 8px 0;
        display: inline-block;
    }
}

/* ========== ADDITIONAL MOBILE MODAL FIXES FOR CONTACT ========== */
@media (max-width: 768px) {
    /* Ensure contact modal is properly scrollable */
    #contactModal.modal {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        align-items: flex-start;
        padding: 10px 0;
    }
    
    #contactModal.modal.show {
        display: flex !important;
    }
    
    /* Fix for iOS to ensure scrolling works */
    .contact-modal-content {
        max-height: none !important;
        height: auto !important;
        margin: 10px auto !important;
    }
    
    .contact-modal-content .modal-body {
        max-height: 70vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for select dropdowns on iOS */
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}