/**
 * Biomarker Swipe Interface
 * Tinder-like swipe UI for mobile biomarker selection
 */

/* Hide swipe interface on desktop, show only on mobile */
.swipe-interface {
    display: none;
}

/* Mobile-only swipe interface */
@media (max-width: 768px) {
    .swipe-interface {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(180deg, #f8f9f7 0%, #eef1ec 100%);
        z-index: 1000;
        padding: env(safe-area-inset-top, 20px) 16px env(safe-area-inset-bottom, 20px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .swipe-interface.active {
        opacity: 1;
        visibility: visible;
    }

    /* Header */
    .swipe-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 0;
        flex-shrink: 0;
    }

    .swipe-close-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 0.9375rem;
        font-weight: 500;
        padding: 8px;
        margin-left: -8px;
        cursor: pointer;
        transition: color 0.2s ease;
    }

    .swipe-close-btn:active {
        color: var(--text-primary);
    }

    .swipe-close-btn svg {
        width: 20px;
        height: 20px;
    }

    .swipe-counter {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.875rem;
        color: var(--text-secondary);
    }

    .swipe-selected-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 28px;
        height: 28px;
        padding: 0 8px;
        background: var(--primary);
        color: white;
        border-radius: 14px;
        font-weight: 600;
        font-size: 0.8125rem;
    }

    /* Progress bar */
    .swipe-progress {
        flex-shrink: 0;
        margin-bottom: 16px;
    }

    .swipe-progress-bar {
        height: 4px;
        background: rgba(143, 168, 138, 0.2);
        border-radius: 2px;
        overflow: hidden;
    }

    .swipe-progress-fill {
        height: 100%;
        background: var(--primary);
        border-radius: 2px;
        transition: width 0.3s ease;
    }

    .swipe-progress-text {
        display: flex;
        justify-content: space-between;
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin-top: 8px;
    }

    /* Card stack container */
    .swipe-card-container {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
        min-height: 0;
    }

    /* Swipe card */
    .swipe-card {
        position: absolute;
        width: calc(100% - 16px);
        max-width: 360px;
        max-height: 100%;
        background: white;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
        overflow: hidden;
        cursor: grab;
        user-select: none;
        touch-action: pan-y;
        will-change: transform;
        transition: box-shadow 0.2s ease;
    }

    .swipe-card:active {
        cursor: grabbing;
    }

    .swipe-card.dragging {
        transition: none;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    /* Stacked cards behind */
    .swipe-card.stack-1 {
        transform: scale(0.95) translateY(12px);
        opacity: 0.7;
        z-index: 1;
    }

    .swipe-card.stack-2 {
        transform: scale(0.9) translateY(24px);
        opacity: 0.4;
        z-index: 0;
    }

    .swipe-card.top {
        z-index: 10;
    }

    /* Card content */
    .swipe-card-content {
        padding: 24px;
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: 65vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .swipe-card-category {
        display: inline-flex;
        align-items: center;
        padding: 6px 12px;
        background: rgba(143, 168, 138, 0.12);
        color: var(--primary-dark);
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 16px;
        width: fit-content;
    }

    .swipe-card-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1.3;
        margin-bottom: 16px;
    }

    .swipe-card-description {
        font-size: 0.9375rem;
        line-height: 1.7;
        color: var(--text-secondary);
        margin-bottom: 20px;
        flex-grow: 1;
    }

    /* Why it matters section */
    .swipe-card-why {
        background: rgba(143, 168, 138, 0.08);
        border-radius: 12px;
        padding: 16px;
        margin-top: auto;
    }

    .swipe-card-why-label {
        font-size: 0.6875rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--primary-dark);
        margin-bottom: 8px;
    }

    .swipe-card-why-text {
        font-size: 0.8125rem;
        line-height: 1.6;
        color: var(--text-secondary);
    }

    /* Swipe indicators */
    .swipe-indicator {
        position: absolute;
        top: 24px;
        padding: 12px 24px;
        border-radius: 12px;
        font-weight: 700;
        font-size: 1.125rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        opacity: 0;
        transform: scale(0.8) rotate(-15deg);
        transition: opacity 0.15s ease, transform 0.15s ease;
        pointer-events: none;
        z-index: 20;
    }

    .swipe-indicator.like {
        right: 24px;
        background: rgba(76, 175, 80, 0.95);
        color: white;
        border: 3px solid #4CAF50;
        transform-origin: right center;
    }

    .swipe-indicator.nope {
        left: 24px;
        background: rgba(244, 67, 54, 0.95);
        color: white;
        border: 3px solid #F44336;
        transform-origin: left center;
    }

    .swipe-card.swiping-right .swipe-indicator.like,
    .swipe-card.swiping-left .swipe-indicator.nope {
        opacity: 1;
        transform: scale(1) rotate(-12deg);
    }

    /* Super like indicator */
    .swipe-indicator.super {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.8);
        background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
        color: white;
        border: 3px solid #FFD700;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 16px 24px;
    }

    .swipe-indicator.super svg {
        width: 32px;
        height: 32px;
    }

    .swipe-card.swiping-up .swipe-indicator.super {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    /* Action buttons */
    .swipe-actions {
        display: flex;
        justify-content: center;
        gap: 32px;
        padding: 24px 0;
        flex-shrink: 0;
    }

    .swipe-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        border: none;
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .swipe-btn:active {
        transform: scale(0.95);
    }

    .swipe-btn svg {
        width: 28px;
        height: 28px;
    }

    .swipe-btn-skip {
        background: white;
        box-shadow: 0 2px 12px rgba(244, 67, 54, 0.2);
        color: #F44336;
    }

    .swipe-btn-skip:active {
        box-shadow: 0 4px 20px rgba(244, 67, 54, 0.3);
    }

    .swipe-btn-add {
        background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
        box-shadow: 0 4px 16px rgba(76, 175, 80, 0.35);
        color: white;
    }

    .swipe-btn-add:active {
        box-shadow: 0 6px 24px rgba(76, 175, 80, 0.45);
    }

    .swipe-btn-undo {
        width: 48px;
        height: 48px;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        color: var(--text-secondary);
    }

    .swipe-btn-undo:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .swipe-btn-undo svg {
        width: 20px;
        height: 20px;
    }

    /* Super like button */
    .swipe-btn-super {
        width: 52px;
        height: 52px;
        background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
        box-shadow: 0 4px 16px rgba(255, 215, 0, 0.4);
        color: white;
    }

    .swipe-btn-super:active {
        box-shadow: 0 6px 24px rgba(255, 215, 0, 0.5);
    }

    .swipe-btn-super svg {
        width: 24px;
        height: 24px;
    }

    /* Hint text */
    .swipe-hint {
        text-align: center;
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin-bottom: 8px;
        opacity: 0.8;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .swipe-hint-super {
        color: #FFA500;
        font-weight: 500;
    }

    /* Completion state */
    .swipe-complete {
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 32px;
        flex: 1;
    }

    .swipe-complete.active {
        display: flex;
    }

    .swipe-complete-icon {
        width: 80px;
        height: 80px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 24px;
        color: white;
    }

    .swipe-complete-icon svg {
        width: 40px;
        height: 40px;
    }

    .swipe-complete h2 {
        font-size: 1.5rem;
        color: var(--text-primary);
        margin-bottom: 8px;
    }

    .swipe-complete p {
        font-size: 1rem;
        color: var(--text-secondary);
        margin-bottom: 32px;
    }

    .swipe-complete-count {
        font-size: 3rem;
        font-weight: 700;
        color: var(--primary);
        margin-bottom: 8px;
    }

    .swipe-complete-label {
        font-size: 0.875rem;
        color: var(--text-secondary);
        margin-bottom: 32px;
    }

    .swipe-complete-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        max-width: 280px;
    }

    .swipe-complete-btn {
        padding: 16px 32px;
        border-radius: 12px;
        font-size: 1rem;
        font-weight: 600;
        border: none;
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .swipe-complete-btn:active {
        transform: scale(0.98);
    }

    .swipe-complete-btn-primary {
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
        box-shadow: 0 4px 16px rgba(143, 168, 138, 0.35);
    }

    .swipe-complete-btn-secondary {
        background: white;
        color: var(--text-primary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    /* Selected panel drawer */
    .swipe-drawer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        max-height: 70vh;
        display: flex;
        flex-direction: column;
    }

    .swipe-drawer.active {
        transform: translateY(0);
    }

    .swipe-drawer-handle {
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 2px;
        margin: 12px auto;
        flex-shrink: 0;
    }

    .swipe-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 20px 16px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        flex-shrink: 0;
    }

    .swipe-drawer-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--text-primary);
    }

    .swipe-drawer-close {
        background: none;
        border: none;
        color: var(--text-secondary);
        padding: 8px;
        cursor: pointer;
    }

    .swipe-drawer-close svg {
        width: 24px;
        height: 24px;
    }

    .swipe-drawer-content {
        flex: 1;
        overflow-y: auto;
        padding: 16px 20px;
        -webkit-overflow-scrolling: touch;
    }

    .swipe-drawer-empty {
        text-align: center;
        padding: 32px;
        color: var(--text-secondary);
    }

    .swipe-drawer-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .swipe-drawer-item:last-child {
        border-bottom: none;
    }

    .swipe-drawer-item-name {
        font-size: 0.9375rem;
        color: var(--text-primary);
    }

    .swipe-drawer-item-remove {
        background: none;
        border: none;
        color: #F44336;
        padding: 8px;
        cursor: pointer;
    }

    .swipe-drawer-item-remove svg {
        width: 18px;
        height: 18px;
    }

    /* Priority items in drawer */
    .swipe-drawer-item.priority {
        background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, transparent 100%);
        margin: 0 -20px;
        padding: 12px 20px;
        border-left: 3px solid #FFD700;
    }

    .swipe-drawer-item.priority .swipe-drawer-item-name {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .priority-star {
        font-size: 1rem;
    }

    .swipe-drawer-footer {
        padding: 16px 20px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        flex-shrink: 0;
    }

    .swipe-drawer-checkout {
        width: 100%;
        padding: 16px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: transform 0.15s ease;
    }

    .swipe-drawer-checkout:active {
        transform: scale(0.98);
    }

    /* Backdrop for drawer */
    .swipe-drawer-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 1000;
    }

    .swipe-drawer-backdrop.active {
        opacity: 1;
        visibility: visible;
    }

    /* Suggestion popup */
    .swipe-suggestion-popup {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1002;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .swipe-suggestion-popup.active {
        transform: translateY(0);
    }

    .suggestion-content {
        background: white;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .suggestion-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
    }

    .suggestion-icon {
        font-size: 1.25rem;
    }

    .suggestion-title {
        font-weight: 600;
        color: var(--text-primary);
        flex: 1;
    }

    .suggestion-close {
        background: none;
        border: none;
        color: var(--text-secondary);
        padding: 4px;
        cursor: pointer;
    }

    .suggestion-close svg {
        width: 20px;
        height: 20px;
    }

    .suggestion-text {
        font-size: 0.9375rem;
        line-height: 1.6;
        color: var(--text-secondary);
        margin-bottom: 16px;
    }

    .suggestion-text strong {
        color: var(--text-primary);
    }

    .suggestion-actions {
        display: flex;
        gap: 12px;
    }

    .suggestion-btn {
        flex: 1;
        padding: 14px 20px;
        border-radius: 12px;
        font-size: 0.9375rem;
        font-weight: 600;
        border: none;
        cursor: pointer;
        transition: transform 0.15s ease;
    }

    .suggestion-btn:active {
        transform: scale(0.98);
    }

    .suggestion-btn-skip {
        background: #f5f5f5;
        color: var(--text-secondary);
    }

    .suggestion-btn-add {
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: white;
    }

    /* Entry button - hidden since swipe auto-opens on mobile */
    .swipe-entry-btn {
        display: none;
    }

    /* Animation for card exit */
    @keyframes swipeRight {
        to {
            transform: translateX(150%) rotate(30deg);
            opacity: 0;
        }
    }

    @keyframes swipeLeft {
        to {
            transform: translateX(-150%) rotate(-30deg);
            opacity: 0;
        }
    }

    .swipe-card.exit-right {
        animation: swipeRight 0.3s ease forwards;
    }

    .swipe-card.exit-left {
        animation: swipeLeft 0.3s ease forwards;
    }

    /* Exit up animation for super like */
    @keyframes swipeUp {
        to {
            transform: translateY(-150%) scale(1.1);
            opacity: 0;
        }
    }

    .swipe-card.exit-up {
        animation: swipeUp 0.4s ease forwards;
    }

    /* Card entrance animation */
    @keyframes cardEnter {
        from {
            transform: scale(0.95) translateY(20px);
            opacity: 0;
        }
        to {
            transform: scale(1) translateY(0);
            opacity: 1;
        }
    }

    .swipe-card.entering {
        animation: cardEnter 0.3s ease forwards;
    }
}

/* Hide default content when swipe is active */
@media (max-width: 768px) {
    body.swipe-active {
        overflow: hidden;
    }
}
