/* Bottom Sheet ───────────────────────────────────────────────────────── */

/* ============================================================================
   CSS Custom Properties (Fallback)
   ============================================================================ */

:root {
    --c-surface: #fff;
    --c-surface-alt: #f9fafb;
    --c-text: #111827;
    --c-text-muted: #6b7280;
    --c-border: #e5e7eb;
    --c-error: #ef4444;
    --c-error-light: rgba(239, 68, 68, 0.1);
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --text-xs: 0.6875rem;
    --text-sm: 0.75rem;
    --text-base: 0.8125rem;
}

/* Prevent body scroll when sheet is open */
body.bs-open {
    overflow: hidden;
}

/* ============================================================================
   Bottom Sheet Base
   ============================================================================ */

.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    will-change: opacity;
    transition: opacity 0.3s, visibility 0.3s;
}

.bottom-sheet.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================================================
   Backdrop
   ============================================================================ */

.bs-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet.active .bs-backdrop {
    opacity: 1;
}

/* ============================================================================
   Container
   ============================================================================ */

.bs-container {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: var(--c-surface, #fff);
    border-radius: 1.5rem 1.5rem 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    will-change: transform;
    backface-visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bottom-sheet.active .bs-container {
    transform: translateY(0);
}

.bottom-sheet.closing .bs-container {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================================================
   Drag Handle
   ============================================================================ */

.bs-handle {
    width: 100%;
    padding: 1rem 0 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.bs-handle::before {
    content: '';
    width: 36px;
    height: 4px;
    background: var(--c-border, #e5e7eb);
    border-radius: 2px;
}

/* ============================================================================
   Close Button
   ============================================================================ */

.bs-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-surface-alt, #f9fafb);
    border: 1px solid var(--c-border, #e5e7eb);
    border-radius: 50%;
    cursor: pointer;
    color: var(--c-text, #111827);
    transition: all 0.2s;
    z-index: 10;
}

.bs-close:hover {
    transform: scale(1.1) rotate(90deg);
    background: var(--c-error-light, #fee2e2);
    color: var(--c-error, #dc2626);
}

.bs-close svg {
    width: 16px;
    height: 16px;
}

/* ============================================================================
   Content
   ============================================================================ */

.bs-content {
    padding: 1rem 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.bs-content::-webkit-scrollbar {
    display: none;
}

/* ============================================================================
   Desktop Styles (≥768px)
   ============================================================================ */

@media (min-width: 768px) {
    .bottom-sheet {
        align-items: center;
        padding: 1rem;
    }

    .bs-container {
        width: 90%;
        max-width: 500px;
        border-radius: 1rem;
        transform: scale(0.9);
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
    }

    .bottom-sheet.active .bs-container {
        transform: scale(1);
        opacity: 1;
    }

    .bottom-sheet.closing .bs-container {
        transform: scale(0.9);
        opacity: 0;
    }

    .bs-handle {
        display: none;
    }

    .bs-close {
        top: 1.5rem;
        right: 1.5rem;
    }

    .bs-content {
        padding: 2rem 2.5rem;
    }
}

/* Hide handle on desktop */
@media (min-width: 768px) {
    .bs-handle {
        display: none;
    }
}

/* ============================================================================
   Size Variants
   ============================================================================ */

/* Small */
.bs-container.bs-sm {
    max-width: 400px;
}

/* Medium (default) */
.bs-container.bs-md {
    max-width: 500px;
}

/* Large */
.bs-container.bs-lg {
    max-width: 700px;
}

/* Full width on mobile */
@media (max-width: 767px) {

    .bs-container.bs-sm,
    .bs-container.bs-md,
    .bs-container.bs-lg {
        max-width: none;
        width: 100%;
    }
}

/* ============================================================================
   Header & Footer
   ============================================================================ */

.bs-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-border, #e5e7eb);
    flex-shrink: 0;
}

.bs-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--c-text, #111827);
}

.bs-subtitle {
    font-size: 0.875rem;
    color: var(--c-text-muted, #6b7280);
    margin: 0.25rem 0 0;
}

.bs-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--c-border, #e5e7eb);
    flex-shrink: 0;
    display: flex;
    gap: 0.75rem;
}

.bs-footer .btn {
    flex: 1;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-6);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background-color: var(--c-text);
    color: var(--c-surface);
}

.btn-primary:hover {
    opacity: 0.85;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-outline {
    border: 1px solid var(--c-border);
    background-color: var(--c-surface);
    color: var(--c-text);
}

.btn-outline:hover {
    background-color: var(--c-surface-alt);
}