/**
 * Mobile Menu Fixes
 * Ensures mobile menu works with or without Bootstrap
 */

/* Offcanvas Base Styles - Fallback if Bootstrap missing */
.offcanvas {
    position: fixed;
    bottom: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    visibility: hidden;
    background-color: #fff;
    background-clip: padding-box;
    outline: 0;
    transition: transform 0.3s ease-in-out;
}

.offcanvas-start {
    top: 0;
    left: 0;
    width: 320px;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
}

.offcanvas.show {
    visibility: visible;
    transform: translateX(0);
}

/* Offcanvas Backdrop */
.offcanvas-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
}

.offcanvas-backdrop.fade {
    opacity: 0;
}

.offcanvas-backdrop.show {
    opacity: 1;
}

/* Prevent body scroll when menu open */
body.offcanvas-open {
    overflow: hidden;
}

/* Mobile Menu Specific Styles */
.pi-secondary {
    background-color: #1f244c;
    color: #fff;
}

.offcanvas-header {
    padding: 1.5rem 1rem;
}

.offcanvas-body {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* Close Button */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em;
    color: #000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.25rem;
    opacity: 0.5;
    cursor: pointer;
}

.btn-close:hover {
    opacity: 0.75;
}

.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Hamburger Button Animation */
.pi-sidebar-link {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.pi-sidebar-link-inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 30px;
    height: 30px;
}

.pi-sidebar-link-inner span {
    background-color: currentColor;
    height: 3px;
    transition: all 0.3s ease;
}

/* Menu Active State */
.pi-sidebar-link.active .pi-sidebar-link-inner span {
    transform: scale(0);
}

.pi-sidebar-link.active .pi-sidebar-link-inner span:nth-child(5) {
    transform: rotate(45deg) scale(1.5);
}

.pi-sidebar-link.active .pi-sidebar-link-inner span:nth-child(4) {
    transform: rotate(-45deg) scale(1.5);
}

/* Mobile Menu Navigation */
.secondary-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.secondary-nav li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.secondary-nav a {
    display: block;
    padding: 0.75rem 0;
    color: #fff;
    text-decoration: none;
    transition: padding-left 0.3s ease;
}

.secondary-nav a:hover {
    padding-left: 10px;
    color: #b1812d;
}

/* Submenu Styles */
.secondary-nav .sub-menu {
    list-style: none;
    padding-left: 1rem;
    display: none;
}

.secondary-nav .menu-item-has-children.open > .sub-menu {
    display: block;
}

.secondary-nav .menu-item-has-children > a::after {
    content: '\203A';
    float: right;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

.secondary-nav .menu-item-has-children.open > a::after {
    transform: rotate(90deg);
}

/* Responsive Adjustments */
@media (max-width: 575.98px) {
    .offcanvas-start {
        width: 85vw;
        max-width: 320px;
    }
}

/* Ensure proper z-index layering */
.offcanvas {
    z-index: 1045;
}

.offcanvas-backdrop {
    z-index: 1040;
}

/* Smooth transitions */
.offcanvas,
.offcanvas-backdrop {
    transition: all 0.3s ease-in-out;
}

/* Search form in mobile menu */
.offcanvas-search .search-form {
    margin-bottom: 1rem;
}

.offcanvas-search input[type="search"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 4px;
}

.offcanvas-search input[type="search"]::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Fix for RTL */
[dir="rtl"] .offcanvas-start {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
}

[dir="rtl"] .offcanvas-start.show {
    transform: translateX(0);
}
