/* ============================================================
   ZaiXian Tools — Global Stylesheet
   A free, fast, privacy-first online toolkit
   ============================================================ */

/* --- CSS Variables & Theme --- */
:root {
    --brand: #4F46E5;
    --brand-light: #6366F1;
    --brand-glow: rgba(79, 70, 229, 0.3);
    --accent: #06B6D4;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --text: #0F172A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --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 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-hover: #334155;
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: #334155;
    --border-light: #1E293B;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-light); }

img { max-width: 100%; height: auto; display: block; }

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

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 { line-height: 1.3; font-weight: 700; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }

/* --- Header --- */
header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s ease;
}
[data-theme="dark"] header { background: rgba(15, 23, 42, 0.85); }

.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px; gap: 1.5rem;
}

.logo {
    display: flex; align-items: center; gap: 0.6rem;
    font-weight: 800; font-size: 1.35rem; color: var(--text);
    white-space: nowrap;
}
.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.1rem;
}

.nav-links { display: flex; align-items: center; gap: 0.3rem; list-style: none; }
.nav-links a {
    padding: 0.45rem 0.8rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 500; color: var(--text-secondary);
    transition: all var(--transition);
}
.nav-links a:hover, .nav-links a.active {
    color: var(--brand); background: var(--surface-hover);
}

.header-actions { display: flex; align-items: center; gap: 0.6rem; }

.theme-btn, .menu-btn {
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.theme-btn:hover, .menu-btn:hover { border-color: var(--brand); color: var(--brand); }
.menu-btn { display: none; }

/* --- Hero --- */
.hero {
    padding: 4rem 0 3rem; text-align: center;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--border);
}
.hero h1 { margin-bottom: 0.8rem; }
.hero h1 span { background: linear-gradient(135deg, var(--brand), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { color: var(--text-secondary); max-width: 640px; margin: 0 auto 1.5rem; font-size: 1.05rem; }

.search-box {
    max-width: 500px; margin: 0 auto; position: relative;
}
.search-box input {
    width: 100%; padding: 0.85rem 1.2rem 0.85rem 2.8rem;
    border: 2px solid var(--border); border-radius: 50px;
    background: var(--surface); color: var(--text);
    font-size: 1rem; outline: none; transition: all var(--transition);
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.search-box i {
    position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 1rem; pointer-events: none;
}

/* --- Category Pills --- */
.category-nav {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    justify-content: center; padding: 1.5rem 0;
}
.cat-pill {
    padding: 0.45rem 1.1rem; border-radius: 50px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
}
.cat-pill:hover, .cat-pill.active {
    background: var(--brand); color: #fff; border-color: var(--brand);
}

/* --- Tool Grid --- */
.tools-section { padding: 2rem 0 4rem; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem;
}
.section-header h2 { font-size: 1.5rem; display: flex; align-items: center; gap: 0.6rem; }
.section-header .count { color: var(--text-muted); font-size: 0.9rem; }

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
}

.tool-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.5rem;
    transition: all 0.25s ease; cursor: pointer;
    display: flex; flex-direction: column; gap: 0.7rem;
    position: relative; overflow: hidden;
}
.tool-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: linear-gradient(90deg, var(--brand), var(--accent));
    opacity: 0; transition: opacity 0.3s ease;
}
.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg); border-color: var(--brand);
}
.tool-card:hover::before { opacity: 1; }

.tool-card .tool-icon {
    width: 48px; height: 48px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--brand-light), var(--brand));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.tool-card:nth-child(2n) .tool-icon { background: linear-gradient(135deg, #06B6D4, #0891B2); }
.tool-card:nth-child(3n) .tool-icon { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
.tool-card:nth-child(4n) .tool-icon { background: linear-gradient(135deg, #F59E0B, #D97706); }
.tool-card:nth-child(5n) .tool-icon { background: linear-gradient(135deg, #10B981, #059669); }
.tool-card:nth-child(6n) .tool-icon { background: linear-gradient(135deg, #EF4444, #DC2626); }

.tool-card .tool-name { font-weight: 700; font-size: 1.05rem; }
.tool-card .tool-desc { color: var(--text-secondary); font-size: 0.875rem; line-height: 1.5; }
.tool-card .tool-meta {
    display: flex; align-items: center; gap: 0.5rem;
    margin-top: auto; padding-top: 0.5rem;
}
.tool-card .tool-tag {
    font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 50px;
    background: var(--surface-hover); color: var(--text-muted);
    font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;
}

/* --- Tool Page Layout --- */
.tool-page {
    max-width: 900px; margin: 0 auto; padding: 2rem 24px 4rem;
}
.tool-page .breadcrumb {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.tool-page .breadcrumb a { color: var(--text-secondary); }
.tool-page .breadcrumb a:hover { color: var(--brand); }
.tool-page .breadcrumb span { color: var(--text-muted); }

.tool-page h1 { margin-bottom: 0.5rem; }
.tool-page .tool-subtitle { color: var(--text-secondary); margin-bottom: 2rem; }

.tool-workspace {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 2rem; margin-bottom: 2rem;
}

/* Form elements for tools */
.tool-workspace label {
    display: block; font-weight: 600; font-size: 0.9rem;
    margin-bottom: 0.4rem; color: var(--text);
}
.tool-workspace textarea, .tool-workspace input[type="text"],
.tool-workspace input[type="url"], .tool-workspace select {
    width: 100%; padding: 0.75rem 1rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font-size: 0.95rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    outline: none; transition: border-color var(--transition);
    resize: vertical;
}
.tool-workspace textarea:focus, .tool-workspace input:focus, .tool-workspace select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow);
}

.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.7rem 1.5rem; border-radius: var(--radius);
    font-weight: 600; font-size: 0.9rem; cursor: pointer;
    border: none; transition: all var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: var(--brand); color: #fff;
}
.btn-primary:hover { background: var(--brand-light); box-shadow: 0 0 0 3px var(--brand-glow); }
.btn-secondary {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--brand); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; justify-content: center; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* --- Tool Info / Tutorial Section --- */
.tool-info {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 2rem;
    line-height: 1.8;
}
.tool-info h2 { font-size: 1.3rem; margin-bottom: 1rem; }
.tool-info h3 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; }
.tool-info p { margin-bottom: 1rem; color: var(--text-secondary); }
.tool-info ul, .tool-info ol { margin: 0.5rem 0 1rem 1.5rem; color: var(--text-secondary); }
.tool-info li { margin-bottom: 0.4rem; }
.tool-info code {
    background: var(--surface-hover); padding: 0.15rem 0.4rem;
    border-radius: 4px; font-size: 0.88em; font-family: 'JetBrains Mono', monospace;
}

/* --- FAQ --- */
.faq-section { margin-top: 2rem; }
.faq-item {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 0.6rem; overflow: hidden;
    background: var(--surface);
}
.faq-q {
    padding: 1rem 1.2rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    user-select: none; transition: background var(--transition);
}
.faq-q:hover { background: var(--surface-hover); }
.faq-q::after { content: '+'; font-size: 1.3rem; color: var(--text-muted); transition: transform 0.3s ease; }
.faq-item.open .faq-q::after { content: '−'; }
.faq-a {
    padding: 0 1.2rem 1rem; color: var(--text-secondary);
    display: none; line-height: 1.7;
}
.faq-item.open .faq-a { display: block; }

/* --- Blog / Content Pages --- */
.content-page {
    max-width: 800px; margin: 0 auto; padding: 3rem 24px 4rem;
}
.content-page h1 { margin-bottom: 1rem; }
.content-page .updated { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 2rem; }
.content-page h2 { margin: 2rem 0 0.8rem; }
.content-page p { margin-bottom: 1rem; color: var(--text-secondary); line-height: 1.8; }

/* --- Footer --- */
footer {
    margin-top: auto; border-top: 1px solid var(--border);
    background: var(--surface); padding: 3rem 0 2rem;
}
.footer-grid {
    display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem; margin-bottom: 2rem;
}
.footer-brand h3 { margin-bottom: 0.6rem; }
.footer-brand p { color: var(--text-secondary); font-size: 0.9rem; }
.footer-col h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0.8rem; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.5rem; }
.footer-col a { color: var(--text-secondary); font-size: 0.9rem; }
.footer-col a:hover { color: var(--brand); }

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

/* --- Toast / Copy feedback --- */
.toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    background: var(--text); color: var(--bg); padding: 0.75rem 1.2rem;
    border-radius: var(--radius); font-weight: 600; font-size: 0.9rem;
    box-shadow: var(--shadow-lg); display: none;
}
.toast.show { display: block; animation: toastIn 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Responsive --- */
@media (max-width: 768px) {
    .menu-btn { display: flex; }
    .nav-links {
        display: none; position: absolute; top: 64px; left: 0; right: 0;
        background: var(--surface); border-bottom: 2px solid var(--brand);
        flex-direction: column; padding: 1rem; gap: 0.3rem;
        box-shadow: var(--shadow-lg);
    }
    .nav-links.active { display: flex; }
    .nav-links a { width: 100%; padding: 0.7rem 1rem; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .hero { padding: 2.5rem 0 2rem; }
    .tools-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .tool-workspace { padding: 1.2rem; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
    .header-inner { gap: 0.5rem; }
    .logo { font-size: 1.1rem; }
}

/* --- AdSense Ad Units --- */
.ad-container {
    display: block; width: 100%; max-width: 100%;
    margin: 2rem auto; padding: 0.5rem 0;
    text-align: center; overflow: hidden;
    min-height: 90px;
}
.ad-container ins {
    display: block; margin: 0 auto;
}

/* --- Print --- */
@media print {
    header, footer, .btn-row, .breadcrumb { display: none; }
    .tool-page { padding: 0; }
    body { font-size: 12pt; }
}
