/* ========================================
   VISUAL IMPROVEMENTS 2025
   Comprehensive enhancement package
   ======================================== */

/* Theme Transition Animations */
body,
body * {
    transition: background-color 0.3s ease,
                color 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Prevent transitions on page load */
body.no-transitions,
body.no-transitions * {
    transition: none !important;
}

/* Card Hover Effects - Enhanced Interactivity */
.company-card {
    border-radius: 12px !important; /* Increased from 8px */
    padding: 20px !important; /* Increased from 16px for less cramped feel */
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s ease,
                border-color 0.25s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.company-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.03) 0%, rgba(100, 180, 255, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 12px;
}

.company-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3),
                0 0 0 1px rgba(100, 180, 255, 0.3);
}

.company-card:hover::before {
    opacity: 1;
}

.company-card:active {
    transform: translateY(-2px);
}

/* Company Name - Bolder for better hierarchy */
.company-card .company-name,
.company-card h3 {
    font-weight: 700 !important; /* Increased from 600 */
    transition: color 0.2s ease;
}

.company-card:hover .company-name,
.company-card:hover h3 {
    color: var(--primary-cyan, #64ffda);
}

/* Metadata - Slightly smaller for better hierarchy */
.company-card .company-country,
.company-card .company-meta {
    font-size: 0.9rem !important; /* Reduced slightly */
    opacity: 0.85;
}

/* Enhanced Category Badges - Better Contrast & Color Coding */
.company-category,
.category-badge {
    font-weight: 600 !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    border-width: 1.5px !important; /* Increased border for better visibility */
    transition: transform 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.2s ease;
    display: inline-block;
}

.company-category:hover,
.category-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Category Color Coding */
.company-category[style*="border-color: rgb(0, 136, 204)"],
.company-category[style*="color: rgb(0, 136, 204)"] {
    /* Hardware - Blue - enhance contrast */
    background: rgba(0, 136, 204, 0.15) !important;
    border-color: rgba(0, 136, 204, 0.8) !important;
}

.company-category[style*="border-color: rgb(34, 197, 94)"],
.company-category[style*="color: rgb(34, 197, 94)"] {
    /* Software - Green - enhance contrast */
    background: rgba(34, 197, 94, 0.15) !important;
    border-color: rgba(34, 197, 94, 0.8) !important;
}

.company-category[style*="border-color: rgb(255, 128, 1)"],
.company-category[style*="color: rgb(255, 128, 1)"] {
    /* Investment - Orange - enhance contrast */
    background: rgba(255, 128, 1, 0.15) !important;
    border-color: rgba(255, 128, 1, 0.9) !important;
}

/* Stat Cards - Subtle Dividers */
.stats {
    gap: 24px !important; /* Increased spacing */
}

.stat-card {
    position: relative;
    transition: transform 0.25s ease,
                box-shadow 0.25s ease;
}

.stat-card:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background: linear-gradient(to bottom,
        transparent,
        rgba(100, 180, 255, 0.3),
        transparent
    );
}

.stat-card:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Filter Dropdowns - Modern Styling */
select,
#categoryFilter,
#countryFilter,
#qubitTypeFilter,
#entityTypeFilter {
    border-radius: 10px !important;
    padding: 12px 16px !important;
    transition: border-color 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.3s ease;
    cursor: pointer;
}

select:hover,
#categoryFilter:hover,
#countryFilter:hover,
#qubitTypeFilter:hover,
#entityTypeFilter:hover {
    border-color: var(--primary-cyan, #64ffda) !important;
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1);
}

select:focus,
select:focus-visible {
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.2) !important;
}

/* Active Filter Indicator */
select:not([value=""]):not([value="All Categories"]):not([value="All Countries"]) {
    border-color: var(--accent-orange, #ff8001) !important;
    background: rgba(255, 128, 1, 0.05);
}

/* Search Input Enhancement */
#searchInput,
.search-box input {
    border-radius: 12px !important;
    padding: 14px 20px !important;
    transition: border-color 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.3s ease;
}

#searchInput:focus,
.search-box input:focus {
    box-shadow: 0 0 0 4px rgba(100, 255, 218, 0.15) !important;
    border-color: var(--primary-cyan, #64ffda) !important;
}

/* Navigation Buttons - Enhanced Gradients */
nav a {
    transition: transform 0.2s ease,
                box-shadow 0.2s ease,
                opacity 0.2s ease !important;
    position: relative;
    overflow: hidden;
}

nav a::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

nav a:active::before {
    width: 300px;
    height: 300px;
}

nav a:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

nav a:active {
    transform: translateY(0);
}

/* Button Ripple Effect */
button,
.clear-filters-btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease,
                box-shadow 0.2s ease,
                background-color 0.3s ease;
}

button::after,
.clear-filters-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
    opacity: 0;
}

button:active::after,
.clear-filters-btn:active::after {
    width: 200px;
    height: 200px;
    opacity: 1;
    transition: width 0s, height 0s, opacity 0.3s;
}

/* Scroll to Top Button */
#scrollToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #64ffda, #4fd1c5);
    color: #0a0e27;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease,
                visibility 0.3s ease,
                transform 0.3s ease,
                box-shadow 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(100, 255, 218, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

#scrollToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scrollToTop:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(100, 255, 218, 0.6);
}

#scrollToTop:active {
    transform: translateY(-2px);
}

/* Spacing Improvements */
.search-container {
    margin-bottom: 32px !important; /* Increased from 24px */
}

.stats {
    margin-bottom: 40px !important; /* Increased from 32px */
}

.featured-companies-section {
    margin-bottom: 40px !important;
}

section {
    margin-bottom: 32px !important; /* More vertical breathing room */
}

/* Loading Skeleton for Cards */
.company-card.loading {
    pointer-events: none;
}

.company-card.loading .company-name,
.company-card.loading .company-category,
.company-card.loading .company-country {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    color: transparent !important;
    user-select: none;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Max-width Container for Ultra-wide Screens */
.container {
    max-width: 1600px !important; /* Prevent text stretching on ultra-wide */
    margin-left: auto;
    margin-right: auto;
}

/* Custom Scrollbar (Dark Theme) */
:root {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 255, 218, 0.3) rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.4), rgba(100, 180, 255, 0.4));
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, rgba(100, 255, 218, 0.6), rgba(100, 180, 255, 0.6));
    background-clip: padding-box;
}

/* Light Theme Scrollbar */
body.light-theme {
    scrollbar-color: rgba(0, 136, 204, 0.4) rgba(0, 0, 0, 0.1);
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, rgba(0, 136, 204, 0.4), rgba(100, 180, 255, 0.4));
    background-clip: padding-box;
}

/* ========================================
   MOBILE ENHANCEMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Ensure all touch targets meet WCAG 48x48px */
    a,
    button,
    select,
    input,
    .company-card,
    .category-badge,
    nav a {
        min-height: 48px;
        min-width: 48px;
    }

    /* Increase filter button touch targets */
    select,
    #categoryFilter,
    #countryFilter,
    #qubitTypeFilter,
    #entityTypeFilter {
        padding: 14px 18px !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    /* Search input mobile enhancement */
    #searchInput,
    .search-box input {
        padding: 16px 20px !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    /* Mobile header spacing optimization */
    header {
        padding-top: 20px !important;
        padding-bottom: 20px !important;
    }

    header h1 {
        font-size: 2rem !important; /* Slightly smaller on mobile */
        margin-bottom: 8px !important;
    }

    /* Stat cards mobile spacing */
    .stats {
        gap: 12px !important;
    }

    .stat-card {
        min-width: 120px;
        padding: 16px !important;
    }

    /* Card spacing on mobile */
    .company-card {
        padding: 18px !important;
        margin-bottom: 16px !important;
    }

    /* Scroll to top button mobile positioning */
    #scrollToTop {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }

    /* Navigation buttons stack better on mobile */
    nav > div {
        gap: 12px !important;
    }

    nav a {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
    }
}

/* ========================================
   TABLET ENHANCEMENTS
   ======================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 100% !important;
        padding-left: 32px;
        padding-right: 32px;
    }

    .company-card {
        padding: 18px !important;
    }
}

/* ========================================
   QUANTUM VISUAL EFFECTS (Subtle)
   ======================================== */

/* Subtle quantum circuit background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 100px,
            rgba(100, 180, 255, 0.015) 100px,
            rgba(100, 180, 255, 0.015) 101px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 100px,
            rgba(100, 180, 255, 0.015) 100px,
            rgba(100, 180, 255, 0.015) 101px
        );
    pointer-events: none;
    z-index: -1;
    opacity: 0.3;
}

/* Featured companies section enhancement */
.featured-companies-section {
    position: relative;
}

.featured-companies-section::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(100, 255, 218, 0.3) 50%,
        transparent
    );
}

/* Improved refresh button */
.refresh-featured-btn,
#refreshFeatured {
    transition: transform 0.3s ease,
                box-shadow 0.3s ease,
                background 0.3s ease !important;
}

.refresh-featured-btn:hover,
#refreshFeatured:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(100, 255, 218, 0.3);
}

.refresh-featured-btn:active,
#refreshFeatured:active {
    transform: scale(0.98);
}

/* Footer enhancement */
footer {
    margin-top: 64px !important; /* More separation */
}

/* Smooth animations for dynamic content */
.company-card.fade-in {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter active state badge */
.filter-active-badge {
    display: inline-block;
    background: var(--accent-orange, #ff8001);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 600;
}

/* Improved no results message */
.no-results {
    padding: 60px 30px !important;
    border-radius: 16px !important;
    background: linear-gradient(135deg, rgba(100, 180, 255, 0.05), rgba(100, 255, 218, 0.05));
    border: 2px dashed rgba(100, 180, 255, 0.3);
}

/* ========================================
   LIGHT THEME OVERRIDES
   ======================================== */

body.light-theme .company-card {
    background: rgba(255, 255, 255, 0.8);
}

body.light-theme .company-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1),
                0 0 0 1px rgba(0, 136, 204, 0.3);
}

body.light-theme .stat-card:not(:last-child)::after {
    background: linear-gradient(to bottom,
        transparent,
        rgba(0, 136, 204, 0.2),
        transparent
    );
}

body.light-theme #scrollToTop {
    background: linear-gradient(135deg, #0088cc, #0066aa);
    color: white;
}

/* Accessibility: Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #scrollToTop {
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }
}
