/**
 * MOBILE SIDEBAR MENU — Slide-out Panel
 * Inspired by DHI design, ADIGO brand colors
 * Version: 4.0.0
 */

/* ========================================
   HAMBURGER ICON
   ======================================== */

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    position: relative;
}

.hamburger-box {
    width: 26px;
    height: 20px;
    display: inline-block;
    position: relative;
}

.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
    width: 26px;
    height: 2.5px;
    background-color: var(--dark);
    border-radius: 2px;
    position: absolute;
    transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.hamburger-inner {
    display: block;
    top: 50%;
    margin-top: -1.25px;
}

.hamburger-inner::before,
.hamburger-inner::after {
    content: "";
    display: block;
}

.hamburger-inner::before { top: -8px; }
.hamburger-inner::after  { bottom: -8px; }

/* Hamburger → X animation */
.mobile-menu-toggle.active .hamburger-inner {
    transform: rotate(45deg);
    background-color: var(--primary);
}
.mobile-menu-toggle.active .hamburger-inner::before {
    top: 0;
    opacity: 0;
}
.mobile-menu-toggle.active .hamburger-inner::after {
    bottom: 0;
    transform: rotate(-90deg);
    background-color: var(--primary);
}

/* ========================================
   OVERLAY
   ======================================== */

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.35s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.mobile-sidebar-overlay.visible {
    display: block;
}

.mobile-sidebar-overlay.active {
    opacity: 1;
}

/* ========================================
   SIDEBAR PANEL
   ======================================== */

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.mobile-sidebar.open {
    transform: translateX(0);
}

/* ========================================
   SIDEBAR HEADER
   ======================================== */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.sidebar-brand .custom-logo-link img,
.sidebar-brand img {
    height: 36px;
    width: auto;
}

.sidebar-logo-text {
    font-size: 26px;
    font-weight: 800;
    color: var(--primary, #C3110D);
    letter-spacing: -0.5px;
    line-height: 1;
}

.sidebar-logo-sub {
    font-size: 14px;
    font-weight: 500;
    color: #888;
    letter-spacing: 0.5px;
}

.sidebar-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #f5f5f5;
    color: #555;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-close:hover,
.sidebar-close:focus {
    background: var(--primary, #C3110D);
    color: #fff;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu-item {
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-menu-item:last-child {
    border-bottom: none;
}

/* Links */
.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #222;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
}

.sidebar-link-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    color: #999;
    transition: color 0.2s;
}

/* Hover & Active states */
.sidebar-link:hover,
.sidebar-link:focus {
    background: #fafafa;
    color: var(--primary, #C3110D);
}

.sidebar-link:hover .sidebar-icon,
.sidebar-link:focus .sidebar-icon {
    color: var(--primary, #C3110D);
}

.sidebar-menu-item.active > .sidebar-link {
    color: var(--primary, #C3110D);
    background: rgba(195, 17, 13, 0.04);
    border-left: 3px solid var(--primary, #C3110D);
}

.sidebar-menu-item.active > .sidebar-link .sidebar-icon {
    color: var(--primary, #C3110D);
}

/* ========================================
   ACCORDION / DROPDOWN
   ======================================== */

.sidebar-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f5f5f5;
    color: #888;
    font-size: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar-accordion-toggle[aria-expanded="true"] .sidebar-chevron {
    background: var(--primary, #C3110D);
    color: #fff;
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.35s ease;
    background: #fafafa;
}

.sidebar-submenu.open {
    max-height: 300px;
    padding: 4px 0;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px 12px 58px;
    font-size: 14px;
    font-weight: 400;
    color: #555;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-sublink:hover,
.sidebar-sublink:focus {
    color: var(--primary, #C3110D);
    background: rgba(195, 17, 13, 0.04);
}

.sidebar-sublink i {
    color: var(--primary, #C3110D);
    opacity: 0.6;
}

/* ========================================
   SIDEBAR FOOTER
   ======================================== */

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
}

/* CTA Primary — Red */
.sidebar-cta-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    background: var(--primary, #C3110D);
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
    letter-spacing: 0.3px;
}

.sidebar-cta-primary:hover {
    background: #a00d0a;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(195, 17, 13, 0.35);
}

/* CTA Secondary — Outlined */
.sidebar-cta-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    color: var(--primary, #C3110D);
    border: 1.5px solid var(--primary, #C3110D);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
}

.sidebar-cta-secondary:hover {
    background: var(--primary, #C3110D);
    color: #fff;
}

/* Social Icons */
.sidebar-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-top: 12px;
}

.sidebar-social-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eee;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-social-icon:hover {
    background: var(--primary, #C3110D);
    color: #fff;
    transform: translateY(-2px);
}

/* Language Switcher */
.sidebar-lang {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 8px;
}

.sidebar-lang-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    background: #eee;
    text-decoration: none;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.sidebar-lang-btn.active,
.sidebar-lang-btn:hover {
    background: var(--primary, #C3110D);
    color: #fff;
}

/* ========================================
   RESPONSIVE: Show hamburger on mobile
   ======================================== */

@media (max-width: 968px) {
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .header-ctas {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .main-navigation {
        display: none !important;
    }
    
    .language-switcher-select {
        display: none !important;
    }
}

/* Body scroll lock */
body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ========================================
   DARK MODE
   ======================================== */

body.dark-mode .mobile-sidebar {
    background: #1a1a1a;
}

body.dark-mode .sidebar-header {
    border-bottom-color: #333;
}

body.dark-mode .sidebar-logo-text {
    color: var(--primary, #C3110D);
}

body.dark-mode .sidebar-logo-sub {
    color: #777;
}

body.dark-mode .sidebar-close {
    background: #2a2a2a;
    color: #aaa;
}

body.dark-mode .sidebar-close:hover {
    background: var(--primary, #C3110D);
    color: #fff;
}

body.dark-mode .sidebar-link {
    color: #ddd;
}

body.dark-mode .sidebar-link:hover,
body.dark-mode .sidebar-link:focus {
    background: #222;
}

body.dark-mode .sidebar-icon {
    color: #666;
}

body.dark-mode .sidebar-menu-item {
    border-bottom-color: #2a2a2a;
}

body.dark-mode .sidebar-menu-item.active > .sidebar-link {
    background: rgba(195, 17, 13, 0.1);
}

body.dark-mode .sidebar-chevron {
    background: #2a2a2a;
    color: #888;
}

body.dark-mode .sidebar-submenu {
    background: #151515;
}

body.dark-mode .sidebar-sublink {
    color: #aaa;
}

body.dark-mode .sidebar-sublink:hover {
    background: rgba(195, 17, 13, 0.08);
}

body.dark-mode .sidebar-footer {
    background: #151515;
    border-top-color: #333;
}

body.dark-mode .sidebar-social-icon {
    background: #2a2a2a;
    color: #aaa;
}

body.dark-mode .sidebar-lang-btn {
    background: #2a2a2a;
    color: #aaa;
}

body.dark-mode .hamburger-inner,
body.dark-mode .hamburger-inner::before,
body.dark-mode .hamburger-inner::after {
    background-color: #fff;
}

/* ========================================
   SAFE AREA (iPhone X+)
   ======================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar-footer {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   LANGUAGE TOGGLE — Subtle Header Button
   ======================================== */

.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: transparent;
    border: 1.5px solid #ddd;
    border-radius: 20px;
    color: #555;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

.lang-toggle:hover,
.lang-toggle:focus {
    border-color: var(--primary, #C3110D);
    color: var(--primary, #C3110D);
    background: rgba(195, 17, 13, 0.04);
}

.lang-toggle-icon {
    font-size: 13px;
    opacity: 0.7;
}

.lang-toggle-label {
    font-weight: 700;
}

/* Sidebar lang buttons as buttons, not links */
.sidebar-lang-btn {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* Dark mode */
body.dark-mode .lang-toggle {
    border-color: #444;
    color: #aaa;
}

body.dark-mode .lang-toggle:hover {
    border-color: var(--primary, #C3110D);
    color: var(--primary, #C3110D);
}

/* Responsive: ensure toggle visible */
@media (max-width: 768px) {
    .lang-toggle {
        padding: 5px 10px;
        font-size: 11px;
    }
}
