/**
 * Bottom Sheet Component
 * Mobile-friendly bottom sheet for filters, options, and actions
 * 
 * Requirements: 14.5
 */

/* ========== Bottom Sheet Overlay ========== */
.gx-bottom-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.56);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-200, 200ms) var(--ease-out, ease-out),
                visibility var(--duration-200, 200ms) var(--ease-out, ease-out);
    z-index: var(--z-modal-backdrop, 400);
    -webkit-tap-highlight-color: transparent;
}

.gx-bottom-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== Bottom Sheet Container ========== */
.gx-bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(85vh, 600px);
    background: var(--surface-primary, #ffffff);
    border-radius: var(--radius-xl, 24px) var(--radius-xl, 24px) 0 0;
    box-shadow: 0 -24px 80px rgba(2, 6, 23, 0.22);
    transform: translateY(100%);
    transition: transform var(--duration-300, 300ms) cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-modal, 500);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.gx-bottom-sheet.active {
    transform: translateY(0);
}

/* ========== Bottom Sheet Handle ========== */
.gx-bottom-sheet-handle {
    width: 46px;
    height: 4px;
    border-radius: var(--radius-full, 9999px);
    background: var(--border-strong, rgba(15, 23, 42, 0.15));
    margin: 0.65rem auto 0.4rem;
    flex-shrink: 0;
    cursor: grab;
}

.gx-bottom-sheet-handle:active {
    cursor: grabbing;
}

/* ========== Bottom Sheet Header ========== */
.gx-bottom-sheet-header {
    padding: 0.5rem 1rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
}

.gx-bottom-sheet-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: var(--font-bold, 700);
    color: var(--text-primary, #0f172a);
    letter-spacing: -0.01em;
}

.gx-bottom-sheet-close {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.12));
    background: var(--surface-secondary, rgba(15, 23, 42, 0.04));
    color: var(--text-primary, rgba(15, 23, 42, 0.9));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color var(--duration-150, 150ms) var(--ease-out, ease-out),
                transform var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-bottom-sheet-close:hover {
    background: var(--surface-tertiary, rgba(15, 23, 42, 0.08));
}

.gx-bottom-sheet-close:active {
    transform: translateY(1px);
}

.gx-bottom-sheet-close svg {
    width: 20px;
    height: 20px;
}

/* ========== Bottom Sheet Content ========== */
.gx-bottom-sheet-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
}

/* ========== Bottom Sheet Footer ========== */
.gx-bottom-sheet-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    background: var(--surface-primary, #ffffff);
}

.gx-bottom-sheet-footer .gx-btn {
    flex: 1;
}

/* ========== Filter-Specific Styles ========== */
.gx-filter-section {
    margin-bottom: 1.5rem;
}

.gx-filter-section:last-child {
    margin-bottom: 0;
}

.gx-filter-section-title {
    font-size: 0.875rem;
    font-weight: var(--font-semibold, 600);
    color: var(--text-primary, #0f172a);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gx-filter-section-title svg {
    width: 18px;
    height: 18px;
    color: var(--color-primary-500, #6366f1);
}

/* Filter Options - Checkbox/Radio Style */
.gx-filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.gx-filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    min-height: 44px;
    background: var(--surface-secondary, #f8fafc);
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: all var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-filter-option:hover {
    border-color: var(--color-primary-300, #a5b4fc);
    background: var(--color-primary-50, #eef2ff);
}

.gx-filter-option.selected {
    border-color: var(--color-primary-500, #6366f1);
    background: var(--color-primary-50, #eef2ff);
}

.gx-filter-option input[type="checkbox"],
.gx-filter-option input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary-500, #6366f1);
    flex-shrink: 0;
}

.gx-filter-option-label {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: var(--font-medium, 500);
    color: var(--text-primary, #0f172a);
}

.gx-filter-option-count {
    font-size: 0.8125rem;
    color: var(--text-muted, #64748b);
    background: var(--surface-tertiary, #e2e8f0);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full, 9999px);
}

/* Filter Chips - Horizontal Scroll */
.gx-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gx-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    min-height: 44px;
    background: var(--surface-secondary, #f8fafc);
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
    border-radius: var(--radius-full, 9999px);
    font-size: 0.875rem;
    font-weight: var(--font-medium, 500);
    color: var(--text-primary, #0f172a);
    cursor: pointer;
    transition: all var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-filter-chip:hover {
    border-color: var(--color-primary-300, #a5b4fc);
}

.gx-filter-chip.selected {
    background: var(--color-primary-500, #6366f1);
    border-color: var(--color-primary-500, #6366f1);
    color: white;
}

.gx-filter-chip svg {
    width: 16px;
    height: 16px;
}

/* Price Range Slider */
.gx-filter-price-range {
    padding: 0.5rem 0;
}

.gx-filter-price-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.gx-filter-price-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.625rem 0.75rem;
    min-height: 44px;
    background: var(--surface-secondary, #f8fafc);
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
    border-radius: var(--radius-md, 12px);
}

.gx-filter-price-input span {
    color: var(--text-muted, #64748b);
    font-weight: var(--font-medium, 500);
}

.gx-filter-price-input input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    font-weight: var(--font-semibold, 600);
    color: var(--text-primary, #0f172a);
    outline: none;
}

.gx-filter-price-separator {
    color: var(--text-muted, #64748b);
    font-weight: var(--font-medium, 500);
}

/* Range Slider */
.gx-filter-range-slider {
    position: relative;
    height: 6px;
    background: var(--surface-tertiary, #e2e8f0);
    border-radius: var(--radius-full, 9999px);
    margin: 0.5rem 0;
}

.gx-filter-range-track {
    position: absolute;
    height: 100%;
    background: var(--color-primary-500, #6366f1);
    border-radius: var(--radius-full, 9999px);
}

.gx-filter-range-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: white;
    border: 2px solid var(--color-primary-500, #6366f1);
    border-radius: var(--radius-full, 9999px);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    cursor: grab;
    touch-action: none;
}

.gx-filter-range-thumb:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Sort Options */
.gx-sort-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.gx-sort-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    min-height: 44px;
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: all var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-sort-option:hover {
    background: var(--surface-secondary, #f8fafc);
}

.gx-sort-option.selected {
    background: var(--color-primary-50, #eef2ff);
}

.gx-sort-option-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted, #64748b);
}

.gx-sort-option.selected .gx-sort-option-icon {
    color: var(--color-primary-500, #6366f1);
}

.gx-sort-option-label {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: var(--font-medium, 500);
    color: var(--text-primary, #0f172a);
}

.gx-sort-option-check {
    width: 20px;
    height: 20px;
    color: var(--color-primary-500, #6366f1);
    opacity: 0;
    transition: opacity var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-sort-option.selected .gx-sort-option-check {
    opacity: 1;
}

/* Active Filters Bar */
.gx-active-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-default, rgba(15, 23, 42, 0.06));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.gx-active-filters::-webkit-scrollbar {
    display: none;
}

.gx-active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--color-primary-100, #e0e7ff);
    color: var(--color-primary-700, #4338ca);
    border-radius: var(--radius-full, 9999px);
    font-size: 0.8125rem;
    font-weight: var(--font-medium, 500);
    white-space: nowrap;
}

.gx-active-filter-tag button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: var(--radius-full, 9999px);
    transition: background-color var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-active-filter-tag button:hover {
    background: var(--color-primary-200, #c7d2fe);
}

.gx-active-filter-tag button svg {
    width: 14px;
    height: 14px;
}

.gx-clear-filters {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.12));
    border-radius: var(--radius-full, 9999px);
    font-size: 0.8125rem;
    font-weight: var(--font-medium, 500);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-clear-filters:hover {
    border-color: var(--color-error-500, #ef4444);
    color: var(--color-error-500, #ef4444);
}

/* Mobile Filter Trigger Button */
.gx-filter-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    min-height: 44px;
    background: var(--surface-primary, #ffffff);
    border: 1px solid var(--border-default, rgba(15, 23, 42, 0.12));
    border-radius: var(--radius-md, 12px);
    font-size: 0.875rem;
    font-weight: var(--font-semibold, 600);
    color: var(--text-primary, #0f172a);
    cursor: pointer;
    transition: all var(--duration-150, 150ms) var(--ease-out, ease-out);
}

.gx-filter-trigger:hover {
    border-color: var(--color-primary-500, #6366f1);
    color: var(--color-primary-500, #6366f1);
}

.gx-filter-trigger svg {
    width: 20px;
    height: 20px;
}

.gx-filter-trigger .gx-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-primary-500, #6366f1);
    color: white;
    font-size: 0.6875rem;
    font-weight: var(--font-bold, 700);
    border-radius: var(--radius-full, 9999px);
}

@media (max-width: 1023px) {
    .gx-filter-trigger {
        display: inline-flex;
    }
}

/* ========== Dark Mode ========== */
[data-theme="dark"] .gx-bottom-sheet-overlay {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .gx-bottom-sheet {
    background: var(--surface-primary, #0f172a);
}

[data-theme="dark"] .gx-bottom-sheet-handle {
    background: var(--border-strong, #475569);
}

[data-theme="dark"] .gx-bottom-sheet-header {
    border-bottom-color: var(--border-default, rgba(148, 163, 184, 0.1));
}

[data-theme="dark"] .gx-bottom-sheet-title {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-bottom-sheet-close {
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
    background: var(--surface-secondary, #1e293b);
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-bottom-sheet-close:hover {
    background: var(--surface-tertiary, #334155);
}

[data-theme="dark"] .gx-bottom-sheet-footer {
    border-top-color: var(--border-default, rgba(148, 163, 184, 0.1));
    background: var(--surface-primary, #0f172a);
}

[data-theme="dark"] .gx-filter-section-title {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-filter-option {
    background: var(--surface-secondary, #1e293b);
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
}

[data-theme="dark"] .gx-filter-option:hover {
    border-color: var(--color-primary-400, #818cf8);
    background: var(--color-primary-900, #312e81);
}

[data-theme="dark"] .gx-filter-option.selected {
    border-color: var(--color-primary-400, #818cf8);
    background: var(--color-primary-900, #312e81);
}

[data-theme="dark"] .gx-filter-option-label {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-filter-option-count {
    background: var(--surface-tertiary, #334155);
    color: var(--text-secondary, #94a3b8);
}

[data-theme="dark"] .gx-filter-chip {
    background: var(--surface-secondary, #1e293b);
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-filter-chip:hover {
    border-color: var(--color-primary-400, #818cf8);
}

[data-theme="dark"] .gx-filter-chip.selected {
    background: var(--color-primary-500, #6366f1);
    border-color: var(--color-primary-500, #6366f1);
}

[data-theme="dark"] .gx-filter-price-input {
    background: var(--surface-secondary, #1e293b);
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
}

[data-theme="dark"] .gx-filter-price-input input {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-filter-range-slider {
    background: var(--surface-tertiary, #334155);
}

[data-theme="dark"] .gx-filter-range-thumb {
    background: var(--surface-primary, #0f172a);
}

[data-theme="dark"] .gx-sort-option:hover {
    background: var(--surface-secondary, #1e293b);
}

[data-theme="dark"] .gx-sort-option.selected {
    background: var(--color-primary-900, #312e81);
}

[data-theme="dark"] .gx-sort-option-label {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-active-filters {
    background: var(--surface-secondary, #1e293b);
    border-bottom-color: var(--border-default, rgba(148, 163, 184, 0.1));
}

[data-theme="dark"] .gx-active-filter-tag {
    background: var(--color-primary-900, #312e81);
    color: var(--color-primary-300, #a5b4fc);
}

[data-theme="dark"] .gx-active-filter-tag button:hover {
    background: var(--color-primary-800, #3730a3);
}

[data-theme="dark"] .gx-clear-filters {
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
    color: var(--text-secondary, #94a3b8);
}

[data-theme="dark"] .gx-filter-trigger {
    background: var(--surface-primary, #0f172a);
    border-color: var(--border-default, rgba(148, 163, 184, 0.1));
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .gx-filter-trigger:hover {
    border-color: var(--color-primary-400, #818cf8);
    color: var(--color-primary-400, #818cf8);
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
    .gx-bottom-sheet-overlay,
    .gx-bottom-sheet,
    .gx-bottom-sheet-close,
    .gx-filter-option,
    .gx-filter-chip,
    .gx-sort-option {
        transition: none !important;
    }
    
    .gx-bottom-sheet-close:active,
    .gx-filter-range-thumb:active {
        transform: translate(-50%, -50%) !important;
    }
}

/* ========== Desktop - Hide Bottom Sheet, Show Sidebar ========== */
@media (min-width: 1024px) {
    .gx-bottom-sheet-overlay,
    .gx-bottom-sheet {
        display: none !important;
    }
}
