/**
 * FB Resources Frontend Styles
 * Version: 1.0.0
 */

/* Floating Button */
.fbr-button-wrapper {
    position: fixed;
    z-index: 999998;
}

.fbr-floating-button {
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    font-size: 20px;
    font-weight: normal;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Split transitions for better control */
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
                height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    font-family: inherit;
    overflow: hidden;
    /* Responsive min-width will be set in media queries */
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
}

/* Text and icon styles */
.fbr-button-text {
    display: inline-block;
    transition: opacity 0.25s ease, transform 0.25s ease;
    opacity: 1;
    transform: translateX(0);
}

.fbr-button-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-size: 16px; /* Default desktop size */
    line-height: 1;
}

/* Scrolled state - transforms button into circle with icon */
.fbr-floating-button.scrolled {
    border-radius: 50%;
    /* Padding will be handled by responsive media queries */
}

/* Hide text and show icon when scrolled */
.fbr-floating-button.scrolled .fbr-button-text {
    opacity: 0;
    transform: translateX(-20px);
    transition-delay: 0s;
}

.fbr-floating-button.scrolled .fbr-button-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transition-delay: 0.25s;
}

/* Reverse delays when not scrolled for smooth reopening */
.fbr-floating-button:not(.scrolled) .fbr-button-text {
    transition-delay: 0.25s;
}

.fbr-floating-button:not(.scrolled) .fbr-button-icon {
    transition-delay: 0s;
}

.fbr-floating-button:hover,
.fbr-floating-button:focus {
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    outline: none;
}

/* Hover state for non-scrolled button */
.fbr-floating-button:not(.scrolled):hover {
    transform: translateY(-2px);
}

/* Hover state for scrolled button */
.fbr-floating-button.scrolled:hover {
    transform: scale(1.1);
}

.fbr-floating-button:active {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.fbr-floating-button:not(.scrolled):active {
    transform: translateY(0);
}

.fbr-floating-button.scrolled:active {
    transform: scale(1);
}

/* Popup Overlay */
.fbr-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fbr-popup-overlay.active {
    opacity: 1;
}

/* Popup Container */
.fbr-popup {
    background: #fff;
    border-radius: 8px;
    min-width: 280px;
    max-width: 600px;
    width: auto;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.fbr-popup-overlay.active .fbr-popup {
    transform: scale(1);
}

/* Popup Header */
.fbr-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.fbr-popup-title {
    margin: 0;
    margin-right: 20px;
    font-size: 22px;
    color: #333;
    white-space: nowrap;
    min-width: max-content;
}

.fbr-popup-close {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
    font-weight: normal;
}

.fbr-popup-close:hover {
    background: #e0e0e0;
    color: #000;
}

/* Popup Content */
.fbr-popup-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

/* Resources List */
.fbr-resources-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fbr-resource-item {
    margin-bottom: 15px;
}

.fbr-resource-link {
    display: block;
    padding: 12px 20px;
    background: #f8f9fa;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    white-space: nowrap;
    min-width: max-content;
}

.fbr-resource-link:hover {
    opacity: 0.8;
    background: #e9ecef;
    transform: translateX(5px);
}

.fbr-resource-link:focus {
    outline: 2px solid;
    outline-offset: 2px;
}

/* No Resources Message */
.fbr-no-resources {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 0;
}

/* Device Visibility Classes with Scroll Animation Support */
@media (min-width: 992px) {
    .fbr-button-wrapper:not(.fbr-visible-desktop) {
        display: none !important;
    }
    
    .fbr-floating-button {
        font-size: 20px;
        padding: 12px 20px;
        width: auto;
        min-width: 48px;
        min-height: 48px;
    }
    
    .fbr-floating-button.scrolled {
        padding: 12px !important;
        width: 48px !important;
        height: 48px !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .fbr-button-wrapper:not(.fbr-visible-tablet) {
        display: none !important;
    }
    
    .fbr-floating-button {
        font-size: 18px;
        padding: 10px 18px;
        width: auto;
        min-width: 42px;
        min-height: 42px;
    }
    
    .fbr-floating-button.scrolled {
        /* Perfect circle: equal padding on all sides */
        padding: 11px !important;
        width: 42px !important;
        height: 42px !important;
    }
    
    /* Tablet icon size */
    .fbr-floating-button .fbr-button-icon {
        font-size: 14px;
    }
}

@media (max-width: 767px) {
    .fbr-button-wrapper:not(.fbr-visible-mobile) {
        display: none !important;
    }
    
    /* Mobile adjustments */
    .fbr-floating-button {
        font-size: 16px;
        padding: 8px 14px;
        width: auto;
        min-width: 40px;
        min-height: 40px;
    }
    
    .fbr-floating-button.scrolled {
        /* Perfect circle: equal padding on all sides */
        padding: 10px !important;
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Mobile icon size */
    .fbr-floating-button .fbr-button-icon {
        font-size: 12px;
    }
    
    /* Full screen modal on mobile */
    .fbr-popup-overlay {
        padding: 0;
    }
    
    .fbr-popup {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .fbr-popup-content {
        max-height: calc(100vh - 70px);
    }
    
    .fbr-resource-link {
        font-size: 18px;
        padding: 15px 20px;
    }
}

/* Animation keyframes */
@keyframes fbr-pulse {
    0% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }
    100% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

/* Optional pulse animation for button */
.fbr-floating-button.pulse {
    animation: fbr-pulse 2s infinite;
}

/* Accessibility improvements */
.fbr-floating-button:focus,
.fbr-popup-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .fbr-floating-button {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .fbr-floating-button {
        transition: none;
    }
    
    .fbr-button-text,
    .fbr-button-icon {
        transition: none;
    }
    
    .fbr-floating-button:hover,
    .fbr-floating-button:focus {
        transform: none;
    }
}

/* Print styles */
@media print {
    .fbr-button-wrapper,
    .fbr-popup-overlay {
        display: none !important;
    }
}