/* Optimized CSS - Performance & Layout Stability Focus */

/* CSS Variables for consistency */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --transition: all 0.2s ease-in-out;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --secondary-color: #94a3b8;
    --background: #0f0f0f;
    --surface: #1a1a1a;
    --surface-hover: #262626;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border: #333333;
    --border-hover: #404040;
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    --shadow: 0 1px 3px 0 rgb(255 255 255 / 0.1), 0 1px 2px -1px rgb(255 255 255 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(255 255 255 / 0.1), 0 4px 6px -4px rgb(255 255 255 / 0.1);
}

/* Theme transition for smooth switching */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px; /* Prevent iOS zoom */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    overflow-x: hidden;
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 100vh;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    #adblock-overlay {
        padding: 10px;
    }
    
    #adblock-overlay h2 {
        font-size: 2rem;
    }
    
    #adblock-overlay p {
        font-size: 1rem;
    }
    
    #adblock-overlay button {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #adblock-overlay h2 {
        font-size: 1.5rem;
    }
    
    #adblock-overlay p {
        font-size: 0.9rem;
    }
    
    #adblock-overlay button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header - Fixed dimensions to prevent CLS */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px; /* Fixed height to prevent CLS */
    background: rgba(var(--background-rgb, 255, 255, 255), 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: var(--transition);
}

/* Dark mode header background */
[data-theme="dark"] .header {
    background: rgba(15, 15, 15, 0.95);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 20px;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-svg {
    width: 40px;
    height: 40px;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    min-height: 44px; /* Touch target */
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Hero Section - Fixed dimensions */
.hero {
    padding: 120px 0 80px; /* Account for fixed header */
    text-align: center;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    min-height: 400px; /* Prevent CLS */
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.hero p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: white;
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    min-height: 44px; /* Touch target */
    white-space: nowrap;
}

.cta-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Tools Section */
.tools-section {
    padding: 80px 0;
    background: var(--background);
}

.tools-section h2 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.search-container {
    max-width: 500px;
    margin: 0 auto 3rem;
}

.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--text-primary);
    transition: var(--transition);
    min-height: 44px; /* Touch target */
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Tools Grid - Fixed dimensions to prevent CLS */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* FAQ Section */
.faq-section {
    padding: 80px 0;
    background: var(--surface);
}

.faq-section h2 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.faq-question {
    padding: 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-question:hover {
    background: var(--surface);
}

.faq-answer {
    padding: 0 1.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-answer.open {
    padding: 0 1.5rem 1.5rem;
    max-height: 1000px;
}

.faq-toggle {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.faq-toggle.open {
    transform: rotate(45deg);
}

/* Cookie Consent */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 2px solid var(--primary-color);
    padding: 1rem;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.cookie-content p {
    flex: 1;
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}

.cookie-buttons {
    display: flex;
    gap: 0.5rem;
}

.cookie-accept, .cookie-decline {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 36px;
}

.cookie-accept {
    background: var(--primary-color);
    color: white;
}

.cookie-accept:hover {
    background: var(--primary-hover);
}

.cookie-decline {
    background: var(--border);
    color: var(--text-primary);
}

.cookie-decline:hover {
    background: var(--border-hover);
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
    min-height: 400px; /* Fixed height to prevent CLS */
    display: flex;
    flex-direction: column;
}

.tool-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.tool-header {
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.tool-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.tool-category {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.tool-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tool-inputs {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.tool-buttons {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.tool-buttons button {
    min-height: 44px; /* Touch target */
    font-size: 16px;
    padding: 12px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.tool-results {
    flex: 1;
    min-height: 100px; /* Prevent CLS */
}

/* Blog Section */
.blog-section {
    padding: 80px 0;
    background: var(--surface);
}

.blog-section h2 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.blog-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    min-height: 300px; /* Fixed height to prevent CLS */
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.blog-image {
    height: 120px; /* Fixed height */
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.blog-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.blog-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.blog-excerpt {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 1rem;
    flex: 1;
}

.blog-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    padding: 60px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 1rem;
    color: white;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #334155;
    color: #cbd5e1;
    font-size: 14px;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .hero {
        padding: 100px 0 60px;
        min-height: 300px;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .tool-card {
        min-height: 350px;
    }
    
    .blog-card {
        min-height: 280px;
    }
    
    .faq-section h2 {
        font-size: 2rem;
    }
}

/* Loading States - Prevent CLS */
.loading-skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Performance Optimizations */
.tool-card,
.blog-card {
    contain: layout style paint;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-secondary: #000000;
    }
}