/**
 * Gate14 - Bottom Sheet Mobile Navigation
 * Styles for mobile category navigation
 */

/* Overlay */
.g14-bs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.g14-bs-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Bottom Sheet Container */
.g14-bs-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.g14-bs-container.active {
    transform: translateY(0);
}

/* Handle */
.g14-bs-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 12px auto 8px;
    cursor: grab;
}

.g14-bs-handle:active {
    cursor: grabbing;
}

/* Header */
.g14-bs-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.g14-bs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #64748b;
    overflow-x: auto;
    scrollbar-width: none;
}

.g14-bs-breadcrumb::-webkit-scrollbar {
    display: none;
}

.g14-bs-breadcrumb-item {
    white-space: nowrap;
    transition: color 0.2s ease;
}

.g14-bs-breadcrumb-item:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: #cbd5e1;
}

.g14-bs-breadcrumb-item.active {
    color: #1a1a2e;
    font-weight: 600;
}

.g14-bs-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    color: #64748b;
    flex-shrink: 0;
}

.g14-bs-close:hover {
    background: #e2e8f0;
    color: #1a1a2e;
    transform: rotate(90deg);
}

/* Search Bar - HIDDEN */
.g14-bs-search {
    display: none !important;
}

.g14-bs-search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.g14-bs-search-input:focus {
    outline: none;
    border-color: #00a09e;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 160, 158, 0.1);
}

.g14-bs-search-icon {
    position: absolute;
    left: 32px;
    top: 12px;
    font-size: 18px;
    pointer-events: none;
}

/* Content */
.g14-bs-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

/* View Container */
.g14-bs-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 100%;
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.g14-bs-view.active {
    position: relative;
    transform: translateX(0);
    opacity: 1;
}

.g14-bs-view.exiting {
    transform: translateX(-30%);
    opacity: 0;
}

/* Categories List */
.g14-bs-categories-list {
    padding: 0 20px 20px;
}

/* Category Item */
.g14-bs-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
}

.g14-bs-category-item:hover {
    background: #f8fafc;
    border-color: #e5e7eb;
}

.g14-bs-category-item:active {
    transform: scale(0.98);
}

.g14-bs-category-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.g14-bs-category-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #f0fdfa 0%, #e6f7f5 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    overflow: hidden;
}

/* Category product image */
.g14-bs-category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gate14 logo fallback */
.g14-bs-category-logo {
    width: 80%;
    height: 80%;
    object-fit: contain;
    padding: 4px;
}

/* FontAwesome icon fallback */
.g14-bs-fa-icon {
    font-size: 24px;
    color: #0f766e;
}

/* Hide old megamenu when Gate14 navigation is active */
body.g14-bs-open .cbp-megamenu,
body.g14-bs-open .menu-dropdown,
body.g14-bs-open #desktop_top_menu > ul {
    display: none !important;
}

/* Hide old desktop menu completely if Gate14 is enabled */
@media (min-width: 1025px) {
    .cbp-megamenu,
    .menu-dropdown {
        transition: opacity 0.3s;
    }
}

.g14-bs-category-info {
    flex: 1;
    min-width: 0;
}

.g14-bs-category-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.g14-bs-category-count {
    font-size: 13px;
    color: #64748b;
}

.g14-bs-category-arrow {
    font-size: 24px;
    color: #cbd5e1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.g14-bs-category-item:hover .g14-bs-category-arrow {
    color: #00a09e;
    transform: translateX(4px);
}

/* Link items (no children) */
a.g14-bs-category-item .g14-bs-category-icon {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Back Button */
.g14-bs-back-button {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

.g14-bs-back-btn {
    width: 100%;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;
    transition: all 0.2s ease;
}

.g14-bs-back-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.g14-bs-back-icon {
    font-size: 18px;
}

/* Category description (sublevel items) */
.g14-bs-category-description {
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
    line-height: 1.4;
    margin-top: 4px;
}

/* Sublevel items: no icon, name bigger */
.g14-bs-sublevel .g14-bs-category-name {
    font-size: 16px;
    font-weight: 700;
    white-space: normal;
}

.g14-bs-sublevel .g14-bs-category-content {
    gap: 0;
    padding-right: 12px;
}

.g14-bs-sublevel .g14-bs-category-arrow {
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}

/* Empty State */
.g14-bs-empty {
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
}

.g14-bs-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.g14-bs-empty-text {
    font-size: 15px;
}

/* Loading State */
.g14-bs-loading {
    padding: 40px 20px;
    text-align: center;
}

.g14-bs-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #00a09e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Desktop - Show as dropdown instead of bottom sheet */
@media (min-width: 1025px) {
    /* Only hide if it's a true desktop with mouse, not tablet */
    @media (hover: hover) and (pointer: fine) {
        /* Transform bottom sheet into dropdown for desktop */
        .g14-bs-container {
            position: fixed;
            top: 80px; /* Below header */
            left: 50%;
            transform: translateX(-50%) translateY(-20px);
            bottom: auto;
            width: 90%;
            max-width: 1200px;
            max-height: 80vh;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .g14-bs-container.active {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
            pointer-events: all;
        }
        
        /* Hide handle on desktop */
        .g14-bs-handle {
            display: none;
        }
        
        /* Desktop header style */
        .g14-bs-header {
            padding: 20px 32px;
            border-bottom: 2px solid #e2e8f0;
        }
        
        .g14-bs-breadcrumb {
            font-size: 18px;
        }
        
        /* Desktop content - 3 columns for better fit */
        .g14-bs-content {
            max-height: calc(80vh - 80px);
        }
        
        .g14-bs-categories-list {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 16px;
            padding: 24px 32px;
        }
        
        /* Desktop category items */
        .g14-bs-category-item {
            padding: 20px;
        }
        
        .g14-bs-category-icon {
            width: 56px;
            height: 56px;
        }
        
        .g14-bs-fa-icon {
            font-size: 28px;
        }
        
        .g14-bs-category-name {
            font-size: 15px;
        }
        
        /* Desktop back button */
        .g14-bs-back-button {
            padding: 16px 32px;
        }
        
        /* Overlay for desktop */
        .g14-bs-overlay {
            background: rgba(0,0,0,0.4);
        }
    }
}

/* Small Mobile Adjustments */
@media (max-width: 375px) {
    .g14-bs-category-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .g14-bs-category-name {
        font-size: 14px;
    }
    
    .g14-bs-category-count {
        font-size: 12px;
    }
}

/* Safe Area for iPhones with notch */
@supports (padding: max(0px)) {
    .g14-bs-container {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Smooth scroll */
.g14-bs-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

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