﻿/** * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 * 
 * Mobile Navigation Slide Panel
 * Premium slide-in navigation with glassmorphism styling
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --mobile-nav-width: 85%;
    --mobile-nav-max-width: 380px;
    --mobile-nav-bg: rgba(255, 255, 255, 0.92);
    --mobile-nav-blur: 24px;
    --mobile-nav-overlay: rgba(0, 0, 0, 0.45);
    --mobile-nav-transition: 320ms cubic-bezier(0.4, 0, 0.2, 1);
    --mobile-nav-border: rgba(0, 0, 0, 0.06);
    --mobile-nav-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
    --mobile-nav-accent: #237465;
    --mobile-nav-accent-light: rgba(35, 116, 101, 0.08);
    --mobile-nav-text-primary: #1a1a2e;
    --mobile-nav-text-secondary: #64748b;
    --mobile-nav-item-height: 56px;
}

/* ========================================
   Overlay Backdrop
   ======================================== */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--mobile-nav-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--mobile-nav-transition), visibility var(--mobile-nav-transition);
    z-index: 9998;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Slide Panel Container
   ======================================== */
.mobile-nav-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--mobile-nav-width);
    max-width: var(--mobile-nav-max-width);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: var(--mobile-nav-bg);
    backdrop-filter: blur(var(--mobile-nav-blur));
    -webkit-backdrop-filter: blur(var(--mobile-nav-blur));
    box-shadow: var(--mobile-nav-shadow);
    transform: translateX(100%);
    transition: transform var(--mobile-nav-transition);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Josefin Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.mobile-nav-panel.active {
    transform: translateX(0);
}

/* Subtle glassmorphism border effect */
.mobile-nav-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.5) 100%
    );
    pointer-events: none;
}

/* ========================================
   Panel Header
   ======================================== */
.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--mobile-nav-border);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.5);
}

.mobile-nav-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--mobile-nav-text-primary);
    letter-spacing: -0.02em;
}

.mobile-nav-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--mobile-nav-text-secondary);
    cursor: pointer;
    transition: all 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-close:hover,
.mobile-nav-close:focus {
    background: var(--mobile-nav-accent-light);
    color: var(--mobile-nav-accent);
}

.mobile-nav-close i {
    font-size: 20px;
}

/* ========================================
   Navigation Content Area
   ======================================== */
.mobile-nav-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Important for flex child scrolling */
}

/* Main navigation list */
.mobile-nav-main {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Prevent a second scrollbar when the panel is closed */
    overflow-y: hidden;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
    background: var(--mobile-nav-bg);
    z-index: 1;
}

.mobile-nav-panel.active .mobile-nav-main {
    overflow-y: auto;
}

.mobile-nav-main.hidden {
    display: none;
}

/* Sub-navigation panels */
.mobile-nav-sub-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Keep sub-panels non-scrollable until they are active */
    overflow-y: hidden;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--mobile-nav-transition);
    z-index: 50;
}

.mobile-nav-sub-panel.active {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    overflow-y: auto;
}

/* ========================================
   Category Items (Main Level)
   ======================================== */
.mobile-nav-category {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    transition: background 150ms ease;
}

.mobile-nav-category:hover,
.mobile-nav-category:focus {
    background: var(--mobile-nav-accent-light);
}

.mobile-nav-category-inner {
    display: flex;
    align-items: center;
    width: 100%;
    height: var(--mobile-nav-item-height);
    border-bottom: 1px solid var(--mobile-nav-border);
}

.mobile-nav-category:last-child .mobile-nav-category-inner {
    border-bottom: none;
}

.mobile-nav-category-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 10px;
    margin-right: 14px;
    flex-shrink: 0;
}

.mobile-nav-category-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.mobile-nav-category-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--mobile-nav-text-primary);
}

.mobile-nav-category-chevron {
    color: var(--mobile-nav-text-secondary);
    font-size: 14px;
    opacity: 0.6;
    transition: transform 150ms ease;
}

.mobile-nav-category:hover .mobile-nav-category-chevron {
    transform: translateX(3px);
    opacity: 1;
}

/* ========================================
   Sub-Panel Header (Back Button)
   ======================================== */
.mobile-nav-sub-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--mobile-nav-border);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-nav-back {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 8px 12px 8px 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--mobile-nav-accent);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 150ms ease;
}

.mobile-nav-back:hover {
    background: var(--mobile-nav-accent-light);
}

.mobile-nav-back i {
    margin-right: 8px;
    font-size: 12px;
}

.mobile-nav-sub-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--mobile-nav-text-primary);
    padding-right: 80px; /* Offset for back button */
}

/* ========================================
   Sub-Panel Sections
   ======================================== */
.mobile-nav-section {
    padding: 16px 0 8px;
}

.mobile-nav-section:last-child {
    padding-bottom: 100px; /* Space for bottom navigation */
}

.mobile-nav-section-header {
    padding: 0 20px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--mobile-nav-text-secondary);
}

/* ========================================
   Navigation Items (Sub Level)
   ======================================== */
.mobile-nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: inherit;
    transition: background 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus {
    background: var(--mobile-nav-accent-light);
    text-decoration: none;
}

.mobile-nav-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.mobile-nav-item-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.mobile-nav-item-content {
    flex: 1;
    min-width: 0;
}

.mobile-nav-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--mobile-nav-text-primary);
    line-height: 1.3;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.mobile-nav-item-desc {
    font-size: 12px;
    color: var(--mobile-nav-text-secondary);
    line-height: 1.4;
    margin-top: 2px;
}

/* Free badge */
.mobile-nav-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

/* ========================================
   Static Links Section (Bottom)
   ======================================== */
.mobile-nav-static {
    padding: 16px;
    border-top: 1px solid var(--mobile-nav-border);
    background: #f8fafc;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.mobile-nav-static-link {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--mobile-nav-text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: background 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-static-link:hover {
    background: var(--mobile-nav-accent-light);
    text-decoration: none;
}

.mobile-nav-static-link i {
    width: 20px;
    margin-right: 12px;
    color: var(--mobile-nav-accent);
    text-align: center;
}

.mobile-nav-static-link.primary {
    background: var(--mobile-nav-accent);
    color: white;
    margin-top: 8px;
}

.mobile-nav-static-link.primary:hover {
    background: #1a574c;
}

.mobile-nav-static-link.primary i {
    color: white;
}

/* Secondary CTA - Dashboard/Login */
.mobile-nav-static-link.secondary {
    margin-top: 8px;
    background: transparent;
    color: var(--mobile-nav-accent);
    border: 1.5px solid var(--mobile-nav-accent);
}

.mobile-nav-static-link.secondary:hover {
    background: var(--mobile-nav-accent);
    color: #ffffff;
}

.mobile-nav-static-link.secondary i {
    color: var(--mobile-nav-accent);
}

.mobile-nav-static-link.secondary:hover i {
    color: #ffffff;
}

/* ========================================
   See All Section (Landing Page Links)
   ======================================== */
.mobile-nav-see-all {
    padding: 16px 20px;
    margin-top: 8px;
    border-top: 1px solid var(--mobile-nav-border);
}

.mobile-nav-see-all-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--mobile-nav-accent-light) 0%, rgba(16, 185, 129, 0.08) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    text-decoration: none;
    color: var(--mobile-nav-accent);
    font-size: 14px;
    font-weight: 600;
    transition: all 200ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-see-all-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.1) 100%);
    border-color: rgba(16, 185, 129, 0.3);
    text-decoration: none;
    color: var(--mobile-nav-accent);
}

.mobile-nav-see-all-btn span {
    flex: 1;
}

.mobile-nav-see-all-btn i {
    font-size: 12px;
    transition: transform 200ms ease;
}

.mobile-nav-see-all-btn:hover i {
    transform: translateX(4px);
}

/* ========================================
   Body Scroll Lock
   ======================================== */
body.mobile-nav-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========================================
   Hide on Large Desktop (>=1600px)
   ======================================== */
@media (min-width: 1600px) {
    .mobile-nav-overlay,
    .mobile-nav-panel {
        display: none !important;
    }
}

/* ========================================
   Small Screen Adjustments
   ======================================== */
@media (max-width: 380px) {
    .mobile-nav-panel {
        width: 100%;
        max-width: none;
    }
    
    .mobile-nav-header {
        padding: 16px 20px;
    }
    
    .mobile-nav-category {
        padding: 0 12px;
    }
    
    .mobile-nav-item {
        padding: 12px 16px;
    }
}

/* ========================================
   Footer with CTA Button
   ======================================== */
.mobile-nav-footer {
    padding: 16px 20px;
    margin-top: auto;
    border-top: 1px solid var(--mobile-nav-border);
    background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
}

.mobile-nav-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--mobile-nav-accent) 0%, #1a574c 100%);
    color: #ffffff;
    font-family: 'Josefin Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-decoration: none;
    border: none;
    border-radius: 12px;
    box-shadow: 
        0 4px 14px rgba(35, 116, 101, 0.35),
        0 2px 6px rgba(35, 116, 101, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transition: 
        transform 200ms ease,
        box-shadow 200ms ease,
        background 200ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-cta:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(35, 116, 101, 0.4),
        0 4px 10px rgba(35, 116, 101, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #1f8d78 0%, #165a4e 100%);
    text-decoration: none;
    color: #ffffff;
}

.mobile-nav-cta:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(35, 116, 101, 0.3),
        0 1px 4px rgba(35, 116, 101, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mobile-nav-cta i {
    font-size: 14px;
    opacity: 0.9;
}

/* ========================================
   Footer User Section (Signed-in Users)
   ======================================== */
.mobile-nav-footer-user {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--mobile-nav-border);
}

.mobile-nav-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mobile-nav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mobile-nav-accent) 0%, #1a574c 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(35, 116, 101, 0.25);
}

.mobile-nav-user-email {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--mobile-nav-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-nav-footer-actions {
    display: flex;
    gap: 8px;
}

.mobile-nav-footer-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--mobile-nav-border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--mobile-nav-text-primary);
    text-decoration: none;
    transition: all 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-footer-btn:hover,
.mobile-nav-footer-btn:focus {
    background: var(--mobile-nav-accent-light);
    border-color: rgba(35, 116, 101, 0.2);
    color: var(--mobile-nav-accent);
    text-decoration: none;
}

.mobile-nav-footer-btn i {
    font-size: 12px;
}

.mobile-nav-footer-btn-logout {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.mobile-nav-footer-btn-logout:hover,
.mobile-nav-footer-btn-logout:focus {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: rgba(220, 38, 38, 0.3);
    color: #b91c1c;
}

/* ========================================
   Safe Area Support (Notch devices)
   ======================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .mobile-nav-header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
    
    .mobile-nav-static {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .mobile-nav-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   Reduced Motion Support
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .mobile-nav-overlay,
    .mobile-nav-panel,
    .mobile-nav-main,
    .mobile-nav-sub,
    .mobile-nav-category,
    .mobile-nav-item {
        transition: none;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    /* Only apply if explicitly enabled via class */
    .mobile-nav-panel.dark-mode {
        --mobile-nav-bg: rgba(30, 41, 59, 0.95);
        --mobile-nav-border: rgba(255, 255, 255, 0.1);
        --mobile-nav-text-primary: #f1f5f9;
        --mobile-nav-text-secondary: #94a3b8;
        --mobile-nav-accent-light: rgba(35, 116, 101, 0.2);
    }
}

