/* Modern CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.1);
}

/* Global Styles */
body {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Glassmorphism Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Modern Home Cards */
.home-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
}

.home-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.home-card .card-img-top {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card-img-top {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.card-img-top.loading {
    opacity: 0.8;
    pointer-events: none;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 0.375rem;
    backdrop-filter: blur(2px);
    transition: opacity 0.3s ease-in-out;
}

.card-img-top.loading {
    position: relative;
}

.card-img-top.loading .loading-overlay {
    opacity: 1;
}

.loading-spinner {
    text-align: center;
}

.loading-text {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Prevent hover effects on cards with loading states */
.card:hover .card-img-top.loading {
    transform: none;
}

/* Ensure smooth transitions for non-loading cards */
.card:not(.loading):hover .card-img-top:not(.loading) {
    transform: scale(1.05);
}

/* Image navigation arrows */
.image-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.image-nav-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.image-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.image-nav-arrow.prev {
    left: 10px;
}

.image-nav-arrow.next {
    right: 10px;
}

/* Show arrows on card hover */
.card:hover .image-nav-arrow {
    opacity: 1;
    visibility: visible;
}

/* Show arrows on modal image hover */
#upgradeModal .position-relative:hover .image-nav-arrow {
    opacity: 1;
    visibility: visible;
}

/* Hide arrows when loading */
.card-img-top.loading + .image-nav-arrow,
.card:has(.card-img-top.loading) .image-nav-arrow {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

/* Ensure arrows are always on top */
.image-nav-arrow {
    z-index: 25;
}

/* Arrow icons */
.image-nav-arrow i {
    font-size: 16px;
}

.home-card:hover .card-img-top {
    transform: scale(1.05);
}

.home-card .card-body {
    padding: 1.5rem;
}

.home-card .card-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.home-card .card-text {
    color: #718096;
    font-size: 0.9rem;
}

/* Image Navigation Counter */
.image-counter {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 5;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.image-counter:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-2px);
}

/* Swipe Area for Image Navigation */
.swipe-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    cursor: grab;
    touch-action: pan-x;
}

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

/* Search Input Group Styling */
.search-input-group {
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.search-input-group:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.search-icon {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 1.2rem;
}

.search-input {
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    background: white;
}

.search-input:focus {
    box-shadow: none;
    border: none;
}

.search-btn {
    background: var(--primary-gradient);
    border: none;
    padding: 1rem 2rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.search-btn .btn-text {
    margin-right: 0.5rem;
}

.search-btn .btn-icon {
    transition: transform 0.3s ease;
}

.search-btn:hover .btn-icon {
    transform: scale(1.2);
}

/* Modern Buttons */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 25px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

/* Upgrade Pills */
.upgrade-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.upgrade-pill {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
}

.upgrade-pill:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.upgrade-pill.active {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.upgrade-pill i {
    font-size: 1rem;
}

/* Loading Animation for Upgrade Modal */
.upgrade-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    margin: 1rem 0;
}

.upgrade-spinner {
    width: 3rem;
    height: 3rem;
    border: 0.3em solid rgba(102, 126, 234, 0.3);
    border-top: 0.3em solid var(--primary-gradient);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Enhancements */
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .home-card .card-img-top {
        height: 200px;
    }
    
    .home-card .card-body {
        padding: 1rem;
    }
}

/* Shimmer Animation */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gradient);
}

/* Loading Indicator Styles */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 0.375rem;
    transition: opacity 0.3s ease;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Fade out animation for loading indicator */
.loading-indicator.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Magical Loading Animation Styles */
.magic-spinner {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.magic-ring {
    position: relative;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #667eea, #764ba2, #f093fb, #f5576c, #667eea);
    animation: magical-rotate 3s linear infinite;
}

.magic-ring::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    background: white;
    border-radius: 50%;
}

.magic-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    font-size: 32px;
    color: #667eea;
    animation: magic-pulse 1.5s ease-in-out infinite alternate;
}

.magic-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.sparkle {
    position: absolute;
    font-size: 16px;
    color: #ffd700;
    animation: sparkle-twinkl 2s ease-in-out infinite;
}

.sparkle:nth-child(1) {
    top: 10%;
    left: 20%;
    animation-delay: 0s;
}

.sparkle:nth-child(2) {
    top: 20%;
    right: 15%;
    animation-delay: 0.3s;
}

.sparkle:nth-child(3) {
    bottom: 20%;
    left: 15%;
    animation-delay: 0.6s;
}

.sparkle:nth-child(4) {
    bottom: 10%;
    right: 20%;
    animation-delay: 0.9s;
}

.sparkle:nth-child(5) {
    top: 50%;
    left: 5%;
    animation-delay: 1.2s;
}

.sparkle:nth-child(6) {
    top: 50%;
    right: 5%;
    animation-delay: 1.5s;
}

.magic-text h5, .magic-text h6 {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: text-glow 2s ease-in-out infinite alternate;
}

@keyframes magical-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes magic-pulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes sparkle-twinkl {
    0%, 100% { 
        opacity: 0; 
        transform: scale(0.5) rotate(0deg);
    }
    50% { 
        opacity: 1; 
        transform: scale(1) rotate(180deg);
    }
}

@keyframes text-glow {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.2); }
}

/* Smaller version for mobile with better centering */
@media (max-width: 768px) {
    .magic-spinner {
        width: 60px;
        height: 60px;
    }
    
    .magic-icon {
        font-size: 20px;
    }
    
    .sparkle {
        font-size: 10px;
    }
    
    .magic-text h6 {
        font-size: 1rem;
        line-height: 1.2;
    }
    
    .magic-text small {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    /* Improve mobile magical loading centering */
    #mobileMagicalLoading .d-flex {
        padding: 2rem 1rem;
    }
    
    #mobileMagicalLoading .magic-text {
        margin-top: 0;
        padding: 0;
    }
}

/* Value Display Enhancement */
.bg-light {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Cache Indicator - Optimized for Performance */
.cache-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.cache-indicator.show {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

.cache-indicator i {
    font-size: 10px;
}
