/* ===================================================================
   MODAL-OFFCANVAS.CSS - Bake App
   - Contains all styles for Bootstrap modals and the various offcanvas
     panels used throughout the application.
=================================================================== */

/* ===================================
   1. GENERAL MODAL STYLING
=================================== */
.modal {
    --bs-modal-zindex: 1060; /* Ensure modals appear over most content */
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
}

.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: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    outline: 0;
}

.modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.25rem;
}

/* Specific styling for the fullscreen Visual Explorer */
.modal-fullscreen .modal-content {
    background-color: rgba(0, 43, 54, 0.95);
    backdrop-filter: blur(10px);
}

.modal-fullscreen .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===================================
   2. GENERAL OFFCANVAS STYLING
=================================== */
.offcanvas {
    position: fixed;
    bottom: 0;
    z-index: 1070; /* Highest z-index to appear over modals if needed */
    display: flex;
    flex-direction: column;
    max-width: 100%;
    visibility: hidden;
    background-color: rgba(255, 255, 255, 0.95);
    background-clip: padding-box;
    outline: 0;
    transition: transform 0.3s ease-in-out;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Make the close button white on dark headers */
.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.offcanvas-title {
    margin-bottom: 0;
    line-height: 1.5;
}

.offcanvas-body {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.offcanvas-end {
    top: 0;
    right: 0;
    width: 400px;
    border-left: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
}

.offcanvas-start {
    top: 0;
    left: 0;
    width: 400px;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
}

.offcanvas.show {
    transform: none;
    visibility: visible;
}

/* ===================================
   4. MOBILE OVERRIDES
=================================== */
/* Enhanced Mobile Offcanvas Fixes */
@media (max-width: 767px) {
    /* Ensure offcanvas stays within viewport bounds */
    .offcanvas-end {
        max-width: 100vw !important;
        right: 0 !important;
        transform: translateX(100%);
        position: fixed !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 1075 !important; /* Higher than navbar */
    }
    
    .offcanvas-start {
        width: 100vw !important;
        max-width: 100vw !important;
        left: 0 !important;
        transform: translateX(-100%);
        position: fixed !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 1075 !important;
    }
    
    /* Show state positioning */
    .offcanvas.show {
        transform: none !important;
        visibility: visible !important;
    }
    
    /* Enhanced close button visibility and accessibility */
    .offcanvas .btn-close,
    .offcanvas .btn-close-white {
        position: relative !important;
        z-index: 1080 !important;
        padding: 1rem !important;
        margin: 0 !important;
        background-size: 1.5rem !important;
        opacity: 1 !important;
        filter: invert(1) grayscale(100%) brightness(200%) !important;
    }
    
    /* Ensure header stays accessible */
    .offcanvas-header {
        position: relative !important;
        z-index: 1076 !important;
        padding: 1rem 1.25rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    /* Body content positioning */
    .offcanvas-body {
        position: relative !important;
        z-index: 1074 !important;
        overflow-y: auto !important;
        padding: 1rem !important;
    }
}


/* In modal-offcanvas.css, use this block to replace the previous one */

/* --- Corrected Full-Screen Visual Recipe Browser --- */

/* Apply a custom background/backdrop effect to the entire modal view */
#visualExplorerModal.modal {
   background-color: rgba(0, 43, 54, 0.95); /* --bs-body-bg with opacity */
   backdrop-filter: blur(8px);
}

/* Make the modal's components transparent to show the new backdrop */
#visualExplorerModal .modal-content,
#visualExplorerModal .modal-header {
    background-color: transparent;
    border: none;
}

/* Ensure the header and its close button are visible on top */
#visualExplorerModal .modal-header {
    /* Use a z-index to guarantee the header stays on top of any other content */
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Force the close button to be the white variant, which is visible on dark backgrounds */
#visualExplorerModal .modal-header .btn-close {
    filter: invert(1) grayscale(100) brightness(200);
}

/* Remove padding from the modal body so the card container can manage its own spacing */
#visualExplorerModal .modal-body {
    padding: 0;
}

/* Fix Browse Modal Z-Index Issues */
#visualExplorerModal {
    z-index: 1080 !important;
}

#visualExplorerModal .modal-dialog {
    z-index: 1081 !important;
}

#visualExplorerModal .modal-content {
    z-index: 1082 !important;
}

/* Ensure modal appears above navbar on mobile */
@media (max-width: 768px) {
    #visualExplorerModal {
        z-index: 1080 !important;
    }
    
    .modal-backdrop {
        z-index: 1075 !important;
    }
}

/* Enhanced backdrop for mobile */
@media (max-width: 768px) {
    .offcanvas-backdrop {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 1070 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
    }
    
    .offcanvas-backdrop.show {
        opacity: 1 !important;
    }
}
/* Enhanced Offcanvas Z-Index Management */
.offcanvas {
    z-index: 1080 !important; /* Higher than navbar */
}

/* Specific mobile fixes */
@media (max-width: 768px) {
    .offcanvas-end,
    .offcanvas-start {
        z-index: 1080 !important;
        position: fixed !important;
        top: 0 !important;
        height: 100vh !important;
    }
    
    /* Ensure offcanvas appears above sticky navbar */
    .offcanvas.show {
        z-index: 1080 !important;
    }
    
    /* Enhanced backdrop layering */
    .offcanvas-backdrop {
        z-index: 1075 !important;
    }
}

/* Enhanced responsive offcanvas */
@media (max-width: 991px) {
  .offcanvas-end {
    width: min(90vw, 500px) !important;
  }
}

@media (max-width: 767px) and (orientation: landscape) {
  .offcanvas-end {
    width: min(70vw, 400px) !important;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .offcanvas-end {
    width: 100vw !important;
  }
}
@media screen and (orientation: landscape) and (max-height: 500px) {
  #recipeInfoOffcanvas .offcanvas-header {
    min-height: 150px !important;
    padding: 0.75rem !important;
  }
  
  #recipeInfoOffcanvas .recipe-info-image {
    width: 100px !important;
    height: 100px !important;
  }
  
  #recipeInfoOffcanvas .offcanvas-body {
    font-size: 0.9rem !important;
    line-height: 1.4 !important;
  }
}
