/**
 * Unified Bottom Sheet Modal System
 * Full-width pull-up modals with swipe gesture support
 */

/* Bottom Sheet Backdrop */
.bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bottom-sheet-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Bottom Sheet Container */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 90vh;
    height: auto;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 51;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Safe area for iOS */
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-sheet.active {
    transform: translateY(0);
}

/* Dragging state - disable transition for smooth drag */
.bottom-sheet.dragging {
    transition: none;
}

/* Pull Handle */
.bottom-sheet-handle {
    width: 100%;
    padding: 12px 0 8px 0;
    display: flex;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}

.bottom-sheet-handle:active {
    cursor: grabbing;
}

.bottom-sheet-handle-bar {
    width: 40px;
    height: 5px;
    background: #d1d5db;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.bottom-sheet-handle:hover .bottom-sheet-handle-bar {
    background: #9ca3af;
}

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

.bottom-sheet-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.bottom-sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.bottom-sheet-close:hover {
    background: #e2e8f0;
}

.bottom-sheet-close svg {
    width: 20px;
    height: 20px;
    stroke: #64748b;
}

/* Bottom Sheet Content */
.bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0; /* Important for flex children to scroll */
}

/* Prevent body scroll when sheet is open - but allow sheet content to scroll */
body.bottom-sheet-open {
    overflow: hidden;
    touch-action: none;
}

body.bottom-sheet-open .bottom-sheet-content {
    touch-action: pan-y;
    overflow-y: auto;
}

/* Animation for content inside */
.bottom-sheet.active .bottom-sheet-content {
    animation: bottomSheetContentFade 0.3s ease 0.1s both;
}

@keyframes bottomSheetContentFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Image header variant */
.bottom-sheet-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Close button overlay for image headers */
.bottom-sheet-close-overlay {
    position: absolute;
    top: 60px; /* Below handle */
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    transition: transform 0.2s ease;
}

.bottom-sheet-close-overlay:hover {
    transform: scale(1.1);
}

.bottom-sheet-close-overlay:active {
    transform: scale(0.95);
}

/* Velocity indicator for swipe feedback */
.bottom-sheet.fast-swipe {
    transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}


/* React Bottom Sheet Styles */
.bottom-sheet-react {
    animation: slideUpSheet 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Safe area padding for bottom buttons */
.pb-safe {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
}

/* Touch action for handle */
.touch-none {
    touch-action: none;
}
