/**
 * Products Page Styles
 * Three-column layout matching network/about page aesthetic
 */

/* ========================================
   PAGE SETUP
   ======================================== */

body.products-page {
    overflow: hidden;
}

body.products-page .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #fff;
}

body.products-page footer {
    display: none !important;
}

/* ========================================
   PRODUCTS APP CONTAINER
   ======================================== */

.products-app {
    padding-top: 68px; /* Header height */
    height: 100vh;
    overflow: hidden;
}

@media (max-width: 768px) {
    .products-app {
        padding-bottom: 60px; /* Space for bottom tab bar */
        height: calc(100vh - 60px); /* Adjust height to account for tab bar */
    }
}

/* ========================================
   THREE-COLUMN GRID
   ======================================== */

.products-layout {
    display: grid;
    grid-template-columns: 5fr 4fr 3fr;
    height: calc(100vh - 68px);
    overflow: hidden;
}

.products-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #e5e5e5;
    background: #fff;
}

.products-column:last-child {
    border-right: none;
}

/* ========================================
   LEFT COLUMN - VISUALS
   ======================================== */

.products-column--visual {
    background: #fcfcfc;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.products-visual-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.products-visual-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

.products-visual-empty .placeholder-content {
    color: #999;
}

.products-visual-empty .placeholder-content svg {
    color: #ccc;
    margin-bottom: 1rem;
}

.products-visual-empty .placeholder-content h3 {
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin-bottom: 0.5rem;
}

.products-visual-empty .placeholder-content p {
    font-size: 0.75rem;
    color: #999;
}

/* Product visual image */
.products-visual-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.products-visual-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

.products-visual-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.products-visual-image {
    opacity: 0;
    transition: opacity 2s ease-in-out;
}

.products-visual-image.loaded {
    opacity: 1;
}

/* ========================================
   CENTER COLUMN - DETAIL
   ======================================== */

.products-column--detail {
    background: #fff;
    overflow-y: auto;
}

.products-detail-container {
    padding: 2rem;
    min-height: 100%;
}

/* Hide mobile-only elements on desktop */
.products-drag-handle,
.products-pull-tab {
    display: none;
}

/* Empty state */
.products-detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

.products-detail-empty .placeholder-content {
    color: #999;
}

.products-detail-empty .placeholder-content svg {
    color: #ccc;
    margin-bottom: 1rem;
}

.products-detail-empty .placeholder-content h3 {
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin-bottom: 0.5rem;
}

.products-detail-empty .placeholder-content p {
    font-size: 0.75rem;
    color: #999;
}

/* Detail content */
.products-detail-content {
    max-width: 100%;
}

.products-detail-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
}

.products-detail-title {
    font-size: 1rem;
    font-weight: 500;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
}

.products-detail-subtitle {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

.products-detail-price {
    font-size: 0.85rem;
    color: #22c55e;
    font-weight: 500;
    margin-top: 0.5rem;
}

.products-detail-price.muted {
    color: #666;
}

.products-detail-body {
    font-size: 0.8rem;
    line-height: 1.7;
    color: #333;
    margin-bottom: 1.5rem;
}

.products-detail-body p {
    margin: 0 0 1rem 0;
}

.products-detail-body p:last-child {
    margin-bottom: 0;
}

.products-detail-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e5e5;
}

.products-detail-actions .btn {
    font-size: 0.7rem;
}

/* Subdomain reservation section */
.products-subdomain-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e5e5;
}

.products-subdomain-section h4 {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.products-subdomain-section p {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 1rem;
}

/* ========================================
   RIGHT COLUMN - NAVIGATION
   ======================================== */

.products-column--nav {
    background: #fafafa;
}

.products-nav-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.products-nav-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    flex-shrink: 0;
}

.products-nav-header h2 {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #1a1a1a;
    margin: 0;
}

.products-nav-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-decoration: none;
    color: #1a1a1a;
}

.nav-item:hover {
    border-color: #1a1a1a;
    background: #fafafa;
}

.nav-item.active {
    border-color: #1a1a1a;
    border-width: 2px;
    padding: calc(1rem - 1px);
    background: #fff;
}

.nav-item-label {
    font-size: 0.8rem;
    font-weight: 400;
    color: inherit;
}

.nav-item-price {
    font-size: 0.7rem;
    color: #666;
    font-weight: 400;
}

.nav-item.active .nav-item-price {
    color: #22c55e;
}

/* HTMX loading indicator */
.htmx-request .products-detail-container {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Hide mobile nav toggle on desktop */
/* Mobile nav toggle button styling is handled in base.css */
.mobile-nav-overlay {
    display: none;
}

@media (max-width: 1200px) {
    .products-layout {
        grid-template-columns: 1fr 1fr;
    }
    
    .products-column--nav {
        display: none;
    }
}

@media (max-width: 768px) {
    .products-layout {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    /* Column 5 (visual) - full screen fixed */
    .products-column--visual {
        position: fixed;
        top: 68px; /* Header height */
        left: 0;
        right: 0;
        bottom: 60px; /* Tab bar height */
        width: 100%;
        height: calc(100vh - 68px - 60px);
        z-index: 1;
        order: 1;
    }
    
    /* Column 4 (detail) - starts mostly off-screen below, draggable bottom sheet */
    .products-column--detail {
        position: fixed;
        top: calc(95vh - 120px); /* Start mostly off-screen, showing ~80px peek */
        left: 0;
        right: 0;
        bottom: 60px; /* Tab bar height */
        width: 100%;
        height: calc(100vh - 68px - 60px);
        overflow: visible; /* No internal scrolling - whole container moves */
        z-index: 2;
        background: #fff;
        order: 2;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        border-radius: 20px 20px 0 0;
        will-change: transform;
        touch-action: pan-y; /* Allow vertical panning */
    }
    
    /* Bounce animation for content updates */
    .products-column--detail.bounce {
        animation: bottomSheetBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
    
    @keyframes bottomSheetBounce {
        0% {
            transform: translateY(var(--current-translate, 0));
        }
        25% {
            transform: translateY(calc(var(--current-translate, 0) - 8px));
        }
        50% {
            transform: translateY(calc(var(--current-translate, 0) + 5px));
        }
        70% {
            transform: translateY(calc(var(--current-translate, 0) - 3px));
        }
        85% {
            transform: translateY(calc(var(--current-translate, 0) + 2px));
        }
        100% {
            transform: translateY(var(--current-translate, 0));
        }
    }
    
    /* Drag handle - show on mobile */
    .products-drag-handle {
        display: flex;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 40px;
        align-items: center;
        justify-content: center;
        cursor: grab;
        z-index: 10;
        background: #fff;
        border-radius: 20px 20px 0 0;
    }
    
    .products-drag-handle:active {
        cursor: grabbing;
    }
    
    .products-drag-handle-bar {
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin-top: 8px;
    }
    
    /* Pull-up tab indicator - show on mobile */
    .products-pull-tab,
    #products-pull-tab {
        display: flex !important;
        position: fixed !important;
        bottom: calc(60px + 20px) !important; /* Tab bar height + offset */
        left: 50% !important;
        transform: translateX(-50%) translateY(0) !important;
        width: 56px !important;
        height: 32px !important;
        background: #fff !important;
        border: 1px solid #e5e5e5 !important;
        border-radius: 20px 20px 0 0 !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        z-index: 3 !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        color: #000000 !important;
        font-family: inherit !important;
        font-size: inherit !important;
        font-weight: inherit !important;
        text-transform: none !important;
        letter-spacing: normal !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .products-pull-tab.hidden,
    #products-pull-tab.hidden {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateX(-50%) translateY(20px) !important;
    }
    
    .products-pull-tab:hover:not(.hidden),
    #products-pull-tab:hover:not(.hidden) {
        background: #f5f5f5 !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15) !important;
        transform: translateX(-50%) translateY(-2px) !important;
        color: #000000 !important;
    }
    
    .products-pull-tab:active:not(.hidden),
    #products-pull-tab:active:not(.hidden) {
        transform: translateX(-50%) translateY(0px) !important;
        background: #fff !important;
        color: #000000 !important;
    }
    
    .products-pull-tab svg,
    #products-pull-tab svg {
        width: 20px !important;
        height: 20px !important;
        stroke: #000000 !important;
        fill: none !important;
        stroke-width: 2.5 !important;
        stroke-linecap: round !important;
        stroke-linejoin: round !important;
        transition: transform 0.3s ease !important;
        color: #000000 !important;
    }
    
    .products-pull-tab svg polyline,
    #products-pull-tab svg polyline {
        stroke: #000000 !important;
        fill: none !important;
    }
    
    .products-pull-tab:not(.hidden) svg {
        animation: slideUpBounce 0.6s ease-out;
    }
    
    @keyframes slideUpBounce {
        0% {
            transform: translateY(10px);
            opacity: 0;
        }
        60% {
            transform: translateY(-2px);
        }
        100% {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Hide pull tab when bottom sheet is fully expanded */
    .products-column--detail.expanded ~ .products-pull-tab,
    .products-column--detail.expanded + .products-pull-tab {
        opacity: 0;
        pointer-events: none;
    }
    
    /* Detail container - scrollable content */
    .products-detail-container {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: 40px; /* Space for drag handle */
        padding: 2rem;
        padding-top: calc(2rem + 40px); /* Space for drag handle + padding */
        padding-bottom: calc(10vh + 50px); /* 10% margin + space for scroll indicator */
        position: relative;
        min-height: 100%;
    }
    
    /* Scroll indicator button */
    .products-scroll-indicator {
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid #e5e5e5;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        transition: opacity 0.3s ease, transform 0.3s ease;
        opacity: 0;
        pointer-events: none;
    }
    
    .products-scroll-indicator.visible {
        opacity: 1;
        pointer-events: auto;
    }
    
    .products-scroll-indicator:hover {
        transform: translateX(-50%) translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
    
    .products-scroll-indicator svg {
        width: 20px;
        height: 20px;
        stroke: #1a1a1a;
        stroke-width: 2;
    }
    
    /* Column 3 (nav) - slide-out menu */
    .products-column--nav {
        order: 3;
        display: block !important; /* Override display: none from 1200px breakpoint */
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        background: #fff;
        transition: right 0.3s ease;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }
    
    .products-column--nav.mobile-nav-open {
        right: 0;
    }
    
    /* Mobile nav toggle button */
    /* Mobile nav toggle button is now in header - styling handled in base.css */
    
    /* Mobile nav overlay */
    .mobile-nav-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Prevent body scroll when menu is open */
    body.mobile-nav-open {
        overflow: hidden;
    }
}
