/* Swipe Refresh Styles */

/* Ensure body can handle full height swipe detection */
html, body {
    min-height: 100vh;
    position: relative;
    margin: 0;
    padding: 0;
}

/* Progress bar positioned at top of page or below header */
.swipe-progress-bar {
    position: relative;
    width: 100%;
    height: 4px;
    background-color: transparent;
    z-index: 999;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    margin-bottom: 0;
}

/* When positioned at top of page */
.swipe-progress-bar.top-position {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    margin-bottom: 0;
}

.swipe-refresh-text.top-position {
    position: fixed;
    top: 4px;
    left: 0;
    right: 0;
    z-index: 9998;
    margin: 0;
}

.swipe-progress-bar .progress-fill {
    height: 100%;
    width: 0%;
    background-color: #2196F3;
    transition: width 0.2s ease, background-color 0.3s ease;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px rgba(33, 150, 243, 0.3);
}

/* Refreshing text */
.swipe-refresh-text {
    position: relative;
    width: 100%;
    text-align: center;
    padding: 8px 0;
    background-color: #f8f9fa;
    color: #6c757d;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border-bottom: 1px solid #e9ecef;
    z-index: 998;
}

/* When progress bar is active */
.swipe-progress-bar.active {
    opacity: 1;
    transform: translateY(0);
}

.swipe-refresh-text.active {
    opacity: 1;
    transform: translateY(0);
}

/* Progress fill when complete */
.swipe-progress-bar .progress-fill.complete {
    background-color: #4CAF50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}

/* Hide any demo containers */
.swipe-demo-container {
    position: absolute;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Prevent text selection during swipe */
body.swiping {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Smooth animations for progress states */
@keyframes progressPulse {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(33, 150, 243, 0.3); 
    }
    50% { 
        box-shadow: 0 0 15px rgba(33, 150, 243, 0.6); 
    }
}

.swipe-progress-bar .progress-fill.pulsing {
    animation: progressPulse 1.5s ease-in-out infinite;
}

/* Refreshing text animation */
@keyframes refreshPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.swipe-refresh-text.refreshing {
    animation: refreshPulse 1.2s ease-in-out infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .swipe-progress-bar {
        height: 3px;
    }
    
    .swipe-refresh-text {
        font-size: 13px;
        padding: 6px 0;
    }
}

/* Header integration styles */
header + .swipe-progress-bar,
.header + .swipe-progress-bar,
nav + .swipe-progress-bar,
.navbar + .swipe-progress-bar {
    margin-top: 0;
    border-top: 1px solid #e9ecef;
}

header + .swipe-refresh-text,
.header + .swipe-refresh-text,
nav + .swipe-refresh-text,
.navbar + .swipe-refresh-text {
    margin-top: 0;
}

/* Success state styles */
.swipe-progress-bar .progress-fill.success {
    background: linear-gradient(90deg, #4CAF50, #45a049);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

/* Loading state for refresh text */
.swipe-refresh-text.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #6c757d;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}