/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* CSS Variables for Theme Management */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --border-light: #e2e8f0;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-card: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);

    /* Layout */
    --container-max-width: 1200px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-primary: #60a5fa;
    --accent-secondary: #22d3ee;
    --border-light: #334155;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-card: linear-gradient(145deg, #1e293b 0%, #334155 100%);
}

/* Auto Dark Mode Detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --accent-primary: #60a5fa;
        --accent-secondary: #22d3ee;
        --border-light: #334155;
        --shadow-light: rgba(0, 0, 0, 0.3);
        --shadow-medium: rgba(0, 0, 0, 0.5);
        --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        --gradient-card: linear-gradient(145deg, #1e293b 0%, #334155 100%);
    }
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Header Styles */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    gap: var(--spacing-lg);
}

/* Mobile menu toggle positioning */
.mobile-menu-toggle {
    order: -1; /* Ensure it appears first in flex layout */
}

.nav-brand {
    flex: 1; /* Allow brand to take available space */
    display: flex;
    justify-content: center; /* Center the logo when mobile menu is visible */
}

.nav-brand .logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    display: flex;
    gap: 6px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: var(--spacing-sm) 8px;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-link:hover {
    color: var(--accent-primary);
    background: var(--bg-secondary);
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-text {
    font-size: 0.875rem;
}

.nav-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.action-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-light);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1001;
}

.mobile-menu-toggle:hover {
    background: var(--bg-secondary);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-line:not(:last-child) {
    margin-bottom: 4px;
}

/* Hamburger Animation States */
.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scale(0);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Menu */
.mobile-nav-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-menu.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* 70% transparency */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.mobile-nav-content {
    position: absolute;
    top: 0;
    right: 0;
    width: min(280px, 75vw); /* Reduced width for better mobile experience */
    height: 100%;
    background: var(--bg-primary);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-nav-menu.active .mobile-nav-content {
    transform: translateX(0);
}

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.mobile-nav-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-nav-close {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-nav-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-nav-close svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-links {
    flex: 1;
    padding: var(--spacing-md) 0;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.mobile-nav-link:hover,
.mobile-nav-link:active {
    background: var(--bg-secondary);
    border-left-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mobile-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-menu {
        display: none;
    }
    
    .mobile-nav-menu {
        display: block;
    }
    
    .nav-brand {
        justify-content: flex-start; /* Left align logo on mobile when hamburger is present */
        margin-left: var(--spacing-sm); /* Add some spacing from hamburger menu */
    }
    
    .nav-actions {
        gap: var(--spacing-xs);
    }
    
    .action-btn {
        width: 36px;
        height: 36px;
    }
    
    .action-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .navbar {
        padding: var(--spacing-sm) 0;
    }
    
    .logo-text {
        font-size: 1.125rem;
    }
    
    .logo-icon {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .mobile-nav-content {
        width: min(260px, 80vw); /* Further reduced for small screens */
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .mobile-nav-header {
        padding: var(--spacing-md);
    }
    
    .mobile-nav-link {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.9rem;
    }
}

/* Theme Toggle Styles */
.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Main Content */
.main {
    min-height: calc(100vh - 200px);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: var(--spacing-2xl) 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-xl);
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Search Container */
.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    background: white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.search-input {
    flex: 1;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    outline: none;
    color: var(--text-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* Dark theme input text and placeholder override */
[data-theme="dark"] .search-input {
    color: #000000;
}

[data-theme="dark"] .search-input::placeholder {
    color: #000000;
}

/* Auto dark mode input text and placeholder override */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .search-input {
        color: #000000;
    }
    
    :root:not([data-theme]) .search-input::placeholder {
        color: #000000;
    }
}

.search-engine-select {
    border: none;
    padding: 0 var(--spacing-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    font-size: 1rem;
    min-height: 44px; /* Ensure minimum touch target size */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px; /* Make room for the dropdown arrow */
}

.search-btn {
    width: 50px;
    border: none;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-btn:hover {
    background: var(--accent-secondary);
}

.search-btn svg {
    width: 20px;
    height: 20px;
}

/* Sections */
.section-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--spacing-xl);
    color: var(--text-primary);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

.search-engines {
    padding: var(--spacing-2xl) 0 8px 0;
}

.email-services {
    padding: 8px 0 16px 0;
}

.ecommerce-platforms {
    padding: 16px 0 5px 0;
    background: var(--bg-secondary);
}

.b2b-platforms {
    padding: 32px 0 var(--spacing-2xl) 0;
}

.logistics-companies {
    padding: 32px 0 var(--spacing-2xl) 0;
}

/* Engines Grid */
.engines-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.engine-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.engine-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.engine-card:hover::before {
    left: 100%;
}

.engine-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px var(--shadow-medium);
    border-color: var(--accent-primary);
}

.engine-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.engine-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.engine-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.engine-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.engine-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.engine-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-top: var(--spacing-sm);
}

/* Tools Section */
.tools {
    padding: 16px 0;
    background: var(--bg-secondary);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.tool-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px var(--shadow-light);
}

.tool-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

.tool-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.tool-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    padding: var(--spacing-2xl) 0 var(--spacing-lg);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.footer-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-primary);
}

.footer-bottom {
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-light);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Scroll Buttons */
.scroll-buttons {
    position: fixed;
    right: var(--spacing-lg);
    bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 1000;
}

.scroll-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow-light);
    opacity: 0.9;
}

.scroll-btn:hover {
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.scroll-btn svg {
    width: 20px;
    height: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .engines-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-sm);
    }

    .engines-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }

    .navbar {
        flex-wrap: wrap;
        gap: var(--spacing-md);
    }

    .nav-menu {
        order: 3;
        width: 100%;
        justify-content: center;
        padding-top: var(--spacing-md);
        border-top: 1px solid var(--border-light);
    }

    .nav-link {
        font-size: 0.875rem;
        padding: var(--spacing-xs) var(--spacing-sm);
        flex-direction: column;
        gap: 2px;
    }

    .nav-icon {
        width: 14px;
        height: 14px;
    }

    .nav-text {
        font-size: 0.75rem;
    }

    .hero {
        padding: var(--spacing-xl) 0;
    }

    .hero-title {
        font-size: 2rem;
    }

    .search-box {
        flex-direction: column;
        border-radius: var(--border-radius);
    }

    .search-input {
        border-bottom: 1px solid var(--border-light);
    }

    .search-engine-select {
        padding: var(--spacing-md);
        border-bottom: 1px solid var(--border-light);
        min-height: 48px; /* Larger touch target for mobile */
        font-size: 1.1rem; /* Slightly larger font for mobile */
    }

    .search-btn {
        height: 48px;
        width: 100%;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }

    .footer-content {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }

    .footer-section h3 {
        font-size: 1rem;
        margin-bottom: var(--spacing-sm);
    }

    .footer-links a {
        font-size: 0.875rem;
    }

    .scroll-buttons {
        right: var(--spacing-md);
        bottom: var(--spacing-md);
    }

    .scroll-btn {
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .engines-grid {
        grid-template-columns: repeat(2, 1fr); /* Keep 2 columns on mobile */
        gap: var(--spacing-sm); /* Reduce gap for better fit */
    }

    .engine-card {
        padding: var(--spacing-sm); /* Reduce padding for smaller cards */
    }
    
    .engine-header {
        gap: var(--spacing-xs); /* Reduce gap between icon and text */
        margin-bottom: var(--spacing-xs);
    }
    
    .engine-icon {
        width: 36px; /* Smaller icon for mobile */
        height: 36px;
    }
    
    .engine-name {
        font-size: 0.95rem; /* Slightly smaller text */
    }
    
    .engine-desc {
        font-size: 0.8rem; /* Smaller description text */
        line-height: 1.4;
    }

    .search-engine-select {
        min-height: 50px; /* Even larger touch target for small screens */
        font-size: 1.2rem; /* Larger font for better readability */
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .tool-card {
        padding: var(--spacing-md);
    }

    .tool-icon {
        font-size: 1.5rem;
        margin-bottom: var(--spacing-sm);
    }

    .tool-card h3 {
        font-size: 1rem;
        margin-bottom: var(--spacing-xs);
    }

    .tool-card p {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .footer-content {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-sm);
    }

    .footer-section h3 {
        font-size: 0.875rem;
        margin-bottom: var(--spacing-xs);
    }

    .footer-links {
        gap: var(--spacing-xs);
    }

    .footer-links a {
        font-size: 0.75rem;
    }
}

/* Selection styles */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* Focus styles */
button:focus,
input:focus,
select:focus,
a:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}