/**
 * FastDownloader v3.0 - Premium Creative CSS
 * Modern glassmorphism, animations, Instagram-inspired design
 */

/* ========================================
   ANIMATION KEYFRAMES
   ======================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes shine {
    from { left: -100%; }
    to { left: 200%; }
}

@keyframes ringPulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

.animate-in {
    animation: fadeInUp 0.5s ease-out;
}

/* ========================================
   LOADING STATE
   ======================================== */
.fd-loading {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}

.fd-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.fd-loader {
    position: relative;
    width: 100px;
    height: 100px;
}

.fd-loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
}

.fd-loader-ring:nth-child(1) {
    border-top-color: #833ab4;
    animation: spin 1.5s linear infinite;
}

.fd-loader-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-right-color: #fd1d1d;
    animation: spin 1.2s linear infinite reverse;
}

.fd-loader-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-bottom-color: #fcb045;
    animation: spin 0.9s linear infinite;
}

.fd-loader-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    color: #833ab4;
    animation: pulse 2s ease-in-out infinite;
}

.fd-loader-icon svg {
    width: 100%;
    height: 100%;
}

.fd-loading-text {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.fd-loading-dots span {
    display: inline-block;
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.fd-loading-dots span:nth-child(1) { animation-delay: 0s; }
.fd-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.fd-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ========================================
   RESULTS CONTAINER
   ======================================== */
.fd-result {
    max-width: 480px;
    margin: 30px auto;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.1),
        0 8px 25px rgba(131, 58, 180, 0.08);
}

/* ========================================
   HEADER
   ======================================== */
.fd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.fd-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.fd-icon-badge {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(131, 58, 180, 0.4);
}

.fd-icon-badge .material-icons {
    font-size: 26px;
    color: #fff;
}

.fd-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fd-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.fd-speed {
    font-size: 13px;
    color: #69f0ae;
    font-weight: 600;
}

.fd-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.fd-badge .material-icons {
    font-size: 16px;
}

.fd-badge-success {
    background: rgba(105, 240, 174, 0.2);
    color: #69f0ae;
}

.fd-badge-count {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ========================================
   CAPTION
   ======================================== */
.fd-caption {
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.fd-caption p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

/* ========================================
   MEDIA CONTAINER (Single)
   ======================================== */
.fd-media-container {
    padding: 20px 24px;
}

.fd-media-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    cursor: pointer;
}

.fd-media {
    display: block;
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.fd-media-wrapper:hover .fd-media {
    transform: scale(1.02);
}

.fd-media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fd-media-wrapper:hover .fd-media-overlay {
    opacity: 1;
}

.fd-media-overlay .material-icons {
    font-size: 64px;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ========================================
   STATS
   ======================================== */
.fd-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.02);
}

.fd-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #555;
}

.fd-stat .material-icons {
    font-size: 20px;
    color: #fd1d1d;
}

/* ========================================
   PROGRESS BAR (Gallery)
   ======================================== */
.fd-progress-bar {
    display: flex;
    gap: 6px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.fd-progress-dot {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fd-progress-dot:hover {
    background: rgba(255, 255, 255, 0.4);
}

.fd-progress-dot.active {
    background: linear-gradient(90deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    box-shadow: 0 0 10px rgba(253, 29, 29, 0.5);
}

/* ========================================
   VIEWER (Gallery)
   ======================================== */
.fd-viewer {
    background: #0a0a0a;
    padding: 20px;
}

.fd-viewer-main {
    position: relative;
    display: flex;
    align-items: center;
}

#fdMainMedia {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

#fdMainMedia .fd-media {
    max-height: 450px;
}

.fd-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
    z-index: 10;
}

.fd-nav:hover:not(:disabled) {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 100%);
    border-color: transparent;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 25px rgba(131, 58, 180, 0.4);
}

.fd-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.fd-nav-prev { left: 10px; }
.fd-nav-next { right: 10px; }

.fd-viewer-counter {
    text-align: center;
    padding: 12px 0 0;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

#fdCounter {
    color: #fff;
    font-size: 16px;
}

/* ========================================
   THUMBNAILS
   ======================================== */
.fd-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    padding: 16px 24px;
    background: #f8f9fa;
}

.fd-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.25s ease;
}

.fd-thumb:hover {
    transform: scale(1.05);
    border-color: rgba(131, 58, 180, 0.5);
}

.fd-thumb.active {
    border-color: #833ab4;
    box-shadow: 0 0 0 3px rgba(131, 58, 180, 0.2);
}

.fd-thumb img,
.fd-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fd-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.fd-thumb-number {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

/* ========================================
   DOWNLOAD BUTTON
   ======================================== */
.fd-download-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 20px 24px 24px;
    padding: 18px 32px;
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border-radius: 16px;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 16px;
    font-weight: 700;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(131, 58, 180, 0.4);
}

.fd-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(131, 58, 180, 0.5);
}

.fd-btn-icon {
    width: 24px;
    height: 24px;
}

.fd-btn-icon svg {
    width: 100%;
    height: 100%;
}

.fd-btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 3s infinite;
}

/* ========================================
   ERROR STATE
   ======================================== */
.fd-error {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 480px;
    margin: 30px auto;
    padding: 20px 24px;
    background: linear-gradient(145deg, #fff5f5 0%, #fff 100%);
    border-radius: 16px;
    border-left: 4px solid #fd1d1d;
    box-shadow: 0 10px 30px rgba(253, 29, 29, 0.1);
}

.fd-error-icon .material-icons {
    font-size: 32px;
    color: #fd1d1d;
}

.fd-error-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fd-error-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.fd-error-message {
    font-size: 14px;
    color: #666;
}

.fd-error-dismiss {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.fd-error-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
}

.fd-error-dismiss .material-icons {
    font-size: 20px;
    color: #999;
}

/* ========================================
   BUTTON SPINNER
   ======================================== */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 540px) {
    .fd-result {
        margin: 20px 15px;
        border-radius: 20px;
    }
    
    .fd-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .fd-icon-badge {
        width: 42px;
        height: 42px;
    }
    
    .fd-title {
        font-size: 16px;
    }
    
    .fd-thumbs {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .fd-download-btn {
        margin: 16px 16px 20px;
        padding: 16px 24px;
        font-size: 15px;
    }
}
