/* ============================================
   GOODTOOLS.ONLINE - Main Stylesheet v2
   Optimized for UX + SEO + Speed
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4F46E5;
    --primary-dark: #3730A3;
    --primary-light: #818CF8;
    --primary-glow: rgba(79, 70, 229, 0.15);
    --secondary: #10B981;
    --secondary-dark: #059669;
    --accent: #F59E0B;
    --danger: #EF4444;
    --bg: #F8FAFC;
    --bg-white: #FFFFFF;
    --text: #1E293B;
    --text-light: #64748B;
    --text-lighter: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --max-width: 1200px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* === HEADER === */
.site-header {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.logo span { color: var(--primary); }

.nav-links {
    display: flex;
    gap: 4px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.nav-links a:hover, .nav-links a.active {
    background: var(--primary);
    color: white;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
}

/* === HERO — COMPACT === */
.hero {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #2563EB 100%);
    padding: 50px 20px 40px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
    animation: heroGlow 8s ease-in-out infinite;
}

@keyframes heroGlow {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -20px); }
}

.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.2;
    position: relative;
    letter-spacing: -0.03em;
}

.hero p {
    font-size: 1.05rem;
    opacity: 0.9;
    max-width: 550px;
    margin: 0 auto 24px;
    position: relative;
}

.hero-search {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

.hero-search input {
    width: 100%;
    padding: 14px 22px;
    padding-right: 56px;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    box-shadow: var(--shadow-lg);
    outline: none;
    font-family: var(--font);
}

.hero-search button {
    position: absolute;
    right: 6px;
    top: 6px;
    bottom: 6px;
    width: 42px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--transition);
}

.hero-search button:hover { background: var(--primary-dark); }

/* Stats bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 24px;
    position: relative;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-num {
    font-size: 1.5rem;
    font-weight: 800;
    display: block;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* === SECTIONS === */
.section {
    padding: 50px 20px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.section-subtitle {
    color: var(--text-light);
    margin-bottom: 28px;
    font-size: 1rem;
}

/* === TOOL GRID === */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
}

.tool-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
    color: inherit;
}

.tool-card:hover::before { transform: scaleX(1); }

.tool-card-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 14px;
}

.tool-card-icon.ecom { background: #EEF2FF; color: var(--primary); }
.tool-card-icon.finance { background: #ECFDF5; color: var(--secondary); }
.tool-card-icon.health { background: #FEF3C7; color: var(--accent); }
.tool-card-icon.dev { background: #F0F9FF; color: #0EA5E9; }
.tool-card-icon.edu { background: #FDF4FF; color: #A855F7; }

.tool-card h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.tool-card p { color: var(--text-light); font-size: 0.85rem; line-height: 1.5; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    background: #EEF2FF;
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.hot { background: #FEF2F2; color: var(--danger); }
.badge.new { background: #ECFDF5; color: var(--secondary); }

/* === TOOL PAGE — FULL REDESIGN === */
.tool-page {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px 20px 40px;
}

.tool-breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tool-breadcrumb a { color: var(--primary); font-weight: 500; }
.tool-breadcrumb span { color: var(--text-lighter); }

.tool-header {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.tool-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.tool-header p {
    color: var(--text-light);
    font-size: 1rem;
    margin-top: 6px;
}

.tool-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-shrink: 0;
}

.tool-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 20px;
}

/* === CALCULATOR — ABOVE THE FOLD LAYOUT === */
.calc-container {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 30px;
}

.calc-top-bar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 16px 24px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calc-top-bar h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.calc-top-bar .live-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.calc-top-bar .live-dot {
    width: 8px;
    height: 8px;
    background: #4ADE80;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.calc-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 400px;
}

/* Input Side */
.calc-inputs {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid var(--border);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group .hint {
    font-size: 0.75rem;
    color: var(--text-lighter);
    font-weight: 400;
}

.input-group input,
.input-group select {
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all var(--transition);
    outline: none;
    font-family: var(--font);
    background: var(--bg);
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-group input[type="range"] {
    padding: 0;
    height: 6px;
    border: none;
    background: var(--border);
    border-radius: 3px;
    -webkit-appearance: none;
    cursor: pointer;
}

.input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79,70,229,0.3);
}

/* Results Side */
.calc-results {
    padding: 28px;
    background: linear-gradient(135deg, #FAFBFF 0%, #F0F4FF 100%);
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.results-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.results-header .update-indicator {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--secondary);
    background: #ECFDF5;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
}

.results-header .update-indicator.show { opacity: 1; }

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.result-item:hover { background: rgba(79,70,229,0.03); margin: 0 -12px; padding: 10px 12px; border-radius: 6px; }
.result-item:last-child { border-bottom: none; }

.result-label {
    color: var(--text-light);
    font-size: 0.88rem;
}

.result-value {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

.result-value.highlight {
    color: var(--primary);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.result-value.negative { color: var(--danger); }
.result-value.positive { color: var(--secondary); }

/* Big result card */
.result-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    color: white;
    margin-bottom: 16px;
}

.result-hero .result-hero-label {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.result-hero .result-hero-value {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 4px;
}

.result-hero .result-hero-sub {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 4px;
}

/* Animated number change */
.value-changed {
    animation: valueFlash 0.4s ease;
}

@keyframes valueFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); color: var(--primary); }
    100% { transform: scale(1); }
}

/* === AD SPACE === */
.ad-space {
    background: var(--bg-white);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    margin: 24px 0;
    color: var(--text-lighter);
    font-size: 0.8rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === CONTENT === */
.content-section {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 30px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.content-section h2 {
    font-size: 1.3rem;
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

.content-section h3 {
    font-size: 1.05rem;
    margin: 18px 0 8px;
}

.content-section p { color: var(--text-light); margin-bottom: 12px; line-height: 1.7; }
.content-section ul { margin: 8px 0 14px 18px; color: var(--text-light); }
.content-section ul li { margin-bottom: 6px; line-height: 1.6; font-size: 0.95rem; }

/* === FAQ === */
.faq-item {
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-question {
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    transition: color var(--transition);
}

.faq-question:hover { color: var(--primary); }
.faq-answer { color: var(--text-light); margin-top: 10px; line-height: 1.7; display: none; font-size: 0.92rem; }
.faq-item.open .faq-answer { display: block; }
.faq-toggle { font-size: 1.2rem; color: var(--primary); transition: transform var(--transition); }
.faq-item.open .faq-toggle { transform: rotate(45deg); }

/* === RELATED TOOLS === */
.related-tools { margin-top: 30px; }
.related-tools h2 { font-size: 1.2rem; margin-bottom: 16px; }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.related-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
    color: var(--text);
}

.related-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
    color: var(--text);
    transform: translateY(-2px);
}

.related-card .r-icon { font-size: 1.4rem; flex-shrink: 0; }
.related-card .r-text h4 { font-size: 0.9rem; font-weight: 600; }
.related-card .r-text p { font-size: 0.75rem; color: var(--text-light); margin-top: 2px; }

/* === FOOTER === */
.site-footer {
    background: var(--text);
    color: #CBD5E1;
    padding: 50px 20px 24px;
    margin-top: auto;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 30px;
}

.footer-brand p { margin-top: 10px; font-size: 0.85rem; line-height: 1.6; color: #94A3B8; }
.footer-col h4 { color: white; margin-bottom: 14px; font-size: 0.95rem; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col ul a { color: #94A3B8; font-size: 0.85rem; transition: color var(--transition); }
.footer-col ul a:hover { color: white; }

.footer-bottom {
    max-width: var(--max-width);
    margin: 30px auto 0;
    padding-top: 16px;
    border-top: 1px solid #334155;
    text-align: center;
    font-size: 0.8rem;
    color: #64748B;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-white);
        flex-direction: column;
        padding: 16px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .nav-links.open { display: flex; }
    .mobile-toggle { display: block; }

    .hero { padding: 36px 16px 30px; }
    .hero h1 { font-size: 1.6rem; }
    .stats-bar { gap: 20px; }
    .stat-num { font-size: 1.2rem; }

    .calc-body { grid-template-columns: 1fr; }
    .calc-inputs { border-right: none; border-bottom: 1px solid var(--border); padding: 20px; }
    .calc-results { padding: 20px; }

    .tool-header { flex-direction: column; }
    .tool-header h1 { font-size: 1.5rem; }

    .footer-inner { grid-template-columns: 1fr 1fr; gap: 24px; }
    .tool-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .footer-inner { grid-template-columns: 1fr; }
    .tool-meta { display: none; }
}

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

.tool-card { animation: fadeInUp 0.4s ease both; }
.tool-card:nth-child(2) { animation-delay: 0.05s; }
.tool-card:nth-child(3) { animation-delay: 0.1s; }
.tool-card:nth-child(4) { animation-delay: 0.15s; }
.tool-card:nth-child(5) { animation-delay: 0.2s; }
.tool-card:nth-child(6) { animation-delay: 0.25s; }

/* === COLLAPSIBLE ADVANCED OPTIONS === */
.advanced-toggle {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-light);
    transition: all var(--transition);
    width: 100%;
    user-select: none;
}

.advanced-toggle:hover {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: var(--primary-light);
}

.advanced-toggle .toggle-icon {
    transition: transform var(--transition);
    font-size: 0.7rem;
}

.advanced-toggle.open .toggle-icon {
    transform: rotate(180deg);
}

.advanced-toggle .toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.advanced-content {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 0;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.advanced-content.open {
    display: flex;
    margin-top: 4px;
}

.advanced-content .input-group {
    margin-bottom: 0;
}

/* Tab-like options */
.option-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.option-tab {
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-light);
    transition: all var(--transition);
}

.option-tab:hover { color: var(--primary); }
.option-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Stats pill badges */
.stats-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    margin-right: 6px;
    margin-bottom: 6px;
}

.stats-pill strong {
    color: var(--primary);
}

/* Error/Success status for JSON */
.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-badge.valid {
    background: #ECFDF5;
    color: #10B981;
}

.status-badge.invalid {
    background: #FEF2F2;
    color: #EF4444;
}

/* Copy feedback animation */
@keyframes copyFlash {
    0% { background: var(--secondary); transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { background: var(--secondary); transform: scale(1); }
}

.copy-flash { animation: copyFlash 0.4s ease; }
