/* ============================================================
   Convert Units HQ - Shared Stylesheet
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    --bg-light: #F8FAFC;
    --border-color: #E2E8F0;
    --card-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

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

/* ---- Base ---- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    color: var(--text-primary);
    background: #ffffff;
}

/* ---- Header ---- */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: #fff;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.5rem;
    font-weight: 800;
    text-decoration: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo svg { flex-shrink: 0; }
.logo .brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.logo .brand-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}
/* Light accent so “Units HQ” stays readable on purple, green, and other saturated header gradients */
.logo .brand-hq {
    color: #ecfdf5;
    font-weight: 800;
}
.nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 20px;
    opacity: 0.9;
    font-weight: 600;
}
.nav a:hover { opacity: 1; }

/* ---- Breadcrumb ---- */
.breadcrumb {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.breadcrumb a { color: var(--primary-color); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Container ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: 40px; }
.hero h1 { font-size: 2.5rem; margin-bottom: 15px; color: var(--text-primary); }
.hero p { font-size: 1.2rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto; }

/* ---- Converter Card ---- */
.converter-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 40px;
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 2;
}
.converter-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    margin-bottom: 30px;
}

/* ---- Input Group ---- */
.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}
.input-group input {
    width: 100%;
    padding: 16px;
    font-size: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    text-align: center;
    transition: border-color 0.3s;
    -moz-appearance: textfield;
    appearance: textfield;
}
.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.input-group input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(102,126,234,0.15); }

/* ---- Swap Button ---- */
.swap-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.3s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.swap-btn:hover { background: var(--primary-hover); transform: rotate(180deg); }
.swap-btn:focus { outline: 2px solid var(--primary-color); outline-offset: 3px; }

/* ---- Result Display ---- */
.result-display {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: #fff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
}
.result-display .label { font-size: 0.9rem; opacity: 0.9; margin-bottom: 5px; }
.result-display .value { font-size: 2.5rem; font-weight: 700; }

/* ---- Formula Box ---- */
.formula-box {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    border-left: 4px solid var(--primary-color);
}
.formula-box h2.formula-title { color: var(--primary-color); margin-bottom: 10px; font-size: 1.1rem; font-weight: 700; }
.formula-box code {
    background: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 1.1rem;
    display: inline-block;
}

/* ---- Quick Tip ---- */
.quick-tip {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    padding: 15px 20px;
    border-radius: 12px;
    margin: 20px 0;
}
.quick-tip strong { color: #b45309; }

/* ---- Section ---- */
.section { margin-bottom: 50px; }
.section h2 { font-size: 1.8rem; margin-bottom: 20px; color: var(--text-primary); }

/* ---- Conversion Table ---- */
.conversion-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.conversion-table th,
.conversion-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.conversion-table th { background: var(--primary-color); color: #fff; }
.conversion-table tr:hover { background: var(--bg-light); }
.conversion-table .description { color: var(--text-muted); font-size: 0.9rem; }

/* ---- FAQ ---- */
.faq-item { border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 15px; overflow: hidden; }
.faq-question {
    width: 100%;
    padding: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border: none;
    text-align: left;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
}
.faq-question:hover { background: var(--bg-light); }
.faq-question:focus { outline: 2px solid var(--primary-color); outline-offset: -2px; }
.faq-answer { padding: 0 20px 20px; color: var(--text-secondary); display: none; }
.faq-item.active .faq-answer { display: block; }
.faq-item.active .faq-icon { transform: rotate(180deg); }
.faq-icon { transition: transform 0.3s; flex-shrink: 0; }

/* ---- Ad Slot ---- */
.ad-slot {
    background: var(--bg-light);
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    margin: 30px 0;
    min-height: 100px;
    position: relative;
    z-index: 0;
    clear: both;
}

/* ---- Related Section ---- */
.related-section { background: var(--bg-light); padding: 30px; border-radius: 16px; margin-top: 40px; }
.related-section h3 { margin-bottom: 20px; font-size: 1.3rem; }
.related-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.related-link {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}
.related-link:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); }
.related-link strong { color: var(--primary-color); display: block; margin-bottom: 4px; }
.related-link small { color: var(--text-muted); }

/* ---- Footer ---- */
.footer {
    background: var(--text-primary);
    color: #fff;
    padding: 40px 20px;
    text-align: center;
    margin-top: 60px;
}
.footer a { color: rgba(255,255,255,0.8); text-decoration: none; }
.footer a:hover { color: #fff; }
.footer-container { max-width: 1200px; margin: 0 auto; }

/* Sleek shared footer (Tools menu pages: units-by-country, travel, cooking) */
.footer.footer--tools {
    background: linear-gradient(165deg, #0f172a 0%, #020617 55%, #0f172a 100%);
    color: rgba(255, 255, 255, 0.88);
    padding: 32px 20px 36px;
    margin-top: 60px;
    text-align: center;
    border-top: 1px solid rgba(102, 126, 234, 0.4);
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.35);
}
.footer.footer--tools .footer-tools-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.footer.footer--tools a.footer-tools-logo,
.footer.footer--tools a.footer-tools-logo:visited {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff !important;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    transition: opacity 0.2s ease;
}
.footer.footer--tools a.footer-tools-logo:hover {
    opacity: 0.92;
    color: #fff !important;
}
.footer.footer--tools .footer-tools-logo .brand-icon svg {
    width: 30px;
    height: 30px;
    display: block;
}
.footer.footer--tools .footer-tools-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 4px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.footer.footer--tools .footer-tools-nav a {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    transition: color 0.2s ease, background 0.2s ease;
}
.footer.footer--tools .footer-tools-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.footer.footer--tools .footer-tools-copy {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.04em;
}
.footer.footer--tools a.footer-tools-logo .brand-hq,
.footer.footer--tools .footer-tools-copy .brand-hq {
    color: #5eead4 !important;
}
html[data-theme="dark"] .footer.footer--tools,
body[data-theme="dark"] .footer.footer--tools {
    border-top-color: rgba(167, 139, 250, 0.35);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
}

/* ---- Error Message ---- */
.input-error { color: #dc2626; font-size: 0.85rem; margin-top: 6px; display: none; }
.input-error.visible { display: block; }

/* ---- Temp Indicator (F-to-C page) ---- */
.temp-indicator { display: flex; justify-content: center; gap: 20px; margin-top: 20px; }
.temp-badge { padding: 10px 20px; border-radius: 20px; font-weight: 600; font-size: 0.9rem; }
.temp-badge.cold { background: #dbeafe; color: #1d4ed8; }
.temp-badge.mild { background: #dcfce7; color: #15803d; }
.temp-badge.warm { background: #fef3c7; color: #b45309; }
.temp-badge.hot { background: #fee2e2; color: #dc2626; }

/* ---- Height Converter (cm-to-inches) ---- */
.height-converter { background: #fef3c7; border: 1px solid #f59e0b; padding: 20px; border-radius: 12px; margin: 20px 0; }
.height-converter h4 { color: #b45309; margin-bottom: 10px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.8rem; }
    .hero p { font-size: 1rem; }
    .header-content { flex-direction: column; text-align: center; gap: 8px; }
    .nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
    .nav a { margin-left: 10px; }
    .container { padding: 14px; }
    .converter-card { padding: 24px 16px; }
    .converter-grid { grid-template-columns: 1fr; }
    .input-group input { font-size: 1.2rem; padding: 14px; }
    .result-display { padding: 20px; }
    .result-display .value { font-size: 1.8rem; }
    .section h2 { font-size: 1.4rem; }
    .conversion-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .related-links { grid-template-columns: 1fr 1fr; gap: 10px; }
    .related-link { padding: 14px; }
    .related-section { padding: 20px 16px; }
    .breadcrumb { font-size: 0.8rem; }
    .footer { padding: 24px 16px; }
    .swap-btn { margin: 0 auto; }
}

/* ---- Site navbar (tool pages + dropdown; works with theme on body/html) ---- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}
html[data-theme="dark"] .navbar,
body[data-theme="dark"] .navbar {
    background: rgba(15, 23, 42, 0.9);
    border-bottom-color: rgba(129, 140, 248, 0.28);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}
.brand a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.85rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
html[data-theme="dark"] .brand a,
body[data-theme="dark"] .brand a {
    color: #e5e7eb;
}
.brand .brand-icon { width: 30px; height: 30px; display: inline-block; flex-shrink: 0; }
/* Match index.html: teal on “Units HQ”; green arrow segment stays #4ADE80 in SVG */
.brand-hq { color: #14B8A6; }
@media (max-width: 480px) {
    .brand a { font-size: 1.6rem; }
    .brand .brand-icon { width: 26px; height: 26px; }
}
.mobile-toggle {
    display: none;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    font-size: 0.95rem;
}
html[data-theme="dark"] .mobile-toggle,
body[data-theme="dark"] .mobile-toggle {
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.35);
}
.nav-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin: 0;
    padding: 0;
}
.nav-links > li > a {
    text-decoration: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    font-weight: 700;
    font-size: 1rem;
}
html[data-theme="dark"] .nav-links > li > a,
body[data-theme="dark"] .nav-links > li > a {
    color: #e5e7eb;
}
.nav-links > li > a:hover {
    background: rgba(102, 126, 234, 0.12);
    color: var(--primary-color);
}
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
}
html[data-theme="dark"] .nav-dropdown-toggle,
body[data-theme="dark"] .nav-dropdown-toggle {
    color: #e5e7eb;
}
.nav-dropdown-toggle:hover {
    background: rgba(102, 126, 234, 0.12);
    color: var(--primary-color);
}
.nav-dropdown-chevron {
    font-size: 0.65rem;
    opacity: 0.85;
    transition: transform 0.2s ease;
}
.nav-dropdown.is-open .nav-dropdown-chevron {
    transform: rotate(180deg);
}
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: max-content;
    min-width: 260px;
    max-width: min(100vw - 32px, 420px);
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 1002;
    box-sizing: border-box;
}
html[data-theme="dark"] .nav-dropdown-menu,
body[data-theme="dark"] .nav-dropdown-menu {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.25);
}
.nav-dropdown.is-open .nav-dropdown-menu {
    display: flex;
}
.nav-dropdown-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
}
html[data-theme="dark"] .nav-dropdown-menu a,
body[data-theme="dark"] .nav-dropdown-menu a {
    color: #e5e7eb;
}
.nav-dropdown-menu a:hover {
    background: rgba(102, 126, 234, 0.14);
    color: var(--primary-color);
}
.nav-controls { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-controls #site-lang-select {
    padding: 8px 12px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 8px;
    border: 2px solid rgba(102, 126, 234, 0.28);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    min-height: 40px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}
html[data-theme="dark"] .nav-controls #site-lang-select,
body[data-theme="dark"] .nav-controls #site-lang-select {
    background: rgba(30, 41, 59, 0.95);
    color: #e5e7eb;
    border-color: rgba(129, 140, 248, 0.35);
}

@media (max-width: 768px) {
    .mobile-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 100%;
        right: 16px;
        left: 16px;
        margin-top: 8px;
        background: rgba(255, 255, 255, 0.97);
        border: 2px solid var(--border-color);
        border-radius: 12px;
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        display: none;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    }
    html[data-theme="dark"] .nav-links,
    body[data-theme="dark"] .nav-links {
        background: rgba(30, 41, 59, 0.98);
        border-color: rgba(148, 163, 184, 0.22);
    }
    .nav-links.open,
    .nav-links.show {
        display: flex;
    }
    .nav-dropdown-menu {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        padding: 4px 0 4px 12px;
        margin-top: 2px;
        background: transparent;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-dropdown.is-open .nav-dropdown-menu {
        display: flex;
    }
}

/* ---- Performance: reduce layout shift for responsive media ---- */
img,
video,
canvas {
    max-width: 100%;
    height: auto;
}
