/* ========================================================
   CSS Variables & Theming
   ======================================================== */
:root {
    /* Colors - Light Theme (Default) */
    --primary: #3b82f6;       /* SaaS Blue */
    --primary-hover: #2563eb;
    --bg: #f8fafc;            /* Light Grey */
    --text-main: #1e293b;     /* Dark Slate */
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --nav-bg: rgba(255, 255, 255, 0.85);
    
    /* Subtle Icon Backgrounds */
    --icon-blue: #eff6ff;
    --icon-blue-text: #3b82f6;
    --icon-purple: #faf5ff;
    --icon-purple-text: #a855f7;
    --icon-green: #f0fdf4;
    --icon-green-text: #22c55e;
    --icon-orange: #fff7ed;
    --icon-orange-text: #f97316;
    --icon-red: #fef2f2;
    --icon-red-text: #ef4444;
    --icon-cyan: #ecfeff;
    --icon-cyan-text: #06b6d4;

    /* Shadows & Radii */
    --radius: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --bg: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --border: #334155;
    --nav-bg: rgba(15, 23, 42, 0.85);

    --icon-blue: rgba(59, 130, 246, 0.15);
    --icon-purple: rgba(168, 85, 247, 0.15);
    --icon-green: rgba(34, 197, 94, 0.15);
    --icon-orange: rgba(249, 115, 22, 0.15);
    --icon-red: rgba(239, 68, 68, 0.15);
    --icon-cyan: rgba(6, 182, 212, 0.15);
    
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ========================================================
   Navigation (Glassmorphism Sticky Bar)
   ======================================================== */
#navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

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

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

/* Navbar Dropdown */
.nav-links { display: flex; align-items: center; }
.dropdown { position: relative; display: inline-block; }
.dropdown-btn { background: transparent; border: none; color: var(--text-main); font-size: 0.95rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; padding: 0.5rem 1rem; border-radius: 8px; transition: background 0.2s; font-family: inherit; outline: none; }
.dropdown-btn:hover { background: var(--bg); color: var(--primary); }
.dropdown-content { display: none; position: absolute; left: 0; top: 100%; background-color: var(--card-bg); min-width: 180px; box-shadow: var(--shadow-md); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; z-index: 10; margin-top: 0.5rem; }
.dropdown-content a { color: var(--text-main); padding: 0.8rem 1rem; text-decoration: none; display: block; font-size: 0.9rem; font-weight: 500; transition: background 0.2s, color 0.2s, padding-left 0.2s; }
.dropdown-content a:hover { background-color: var(--bg); color: var(--primary); padding-left: 1.25rem; }
.dropdown:hover .dropdown-content { display: block; animation: popup 0.2s ease forwards; }
@keyframes popup { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 900px) { .nav-links { display: none; } } 

.search-bar {
    flex: 1;
    max-width: 450px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar i {
    position: absolute;
    left: 1.2rem;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-bar input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    border-radius: 99px;
    border: 1px solid var(--border);
    background-color: var(--card-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

#themeToggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    background-color: var(--card-bg);
    transition: all 0.2s;
}

#themeToggle:hover {
    background: var(--border);
    transform: rotate(15deg);
}

/* ========================================================
   Hero Section
   ======================================================== */
.hero {
    padding: 6rem 0 4rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-content {
    max-width: 750px;
}

.badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    background-color: var(--icon-blue);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 99px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 1.2rem;
    line-height: 1.15;
    color: var(--text-main);
}

.hero p {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.2s;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.cta-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(59, 130, 246, 0.39);
}

/* ========================================================
   Main Tools Grid
   ======================================================== */
main {
    padding-bottom: 6rem;
}

.section-header {
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

/* Category Filters UI */
.category-filters { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 3rem; }
.filter-btn { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.6rem 1.25rem; border-radius: 99px; font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s ease; outline: none; }
.filter-btn:hover { background: var(--bg); color: var(--text-main); border-color: var(--text-muted); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); transform: translateY(-1px); }

/* Card Animations mapping JS filtration */
.tool-card.fade-in { animation: cardFadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes cardFadeIn { from { opacity: 0; transform: translateY(15px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

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

.tool-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    box-shadow: var(--shadow-md);
}

.tool-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 16px 32px rgba(0,0,0,0.25);
    border-color: var(--primary);
}

.icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Icon Specfic Colors */
.bg-blue { background-color: var(--icon-blue); color: var(--icon-blue-text); }
.bg-purple { background-color: var(--icon-purple); color: var(--icon-purple-text); }
.bg-green { background-color: var(--icon-green); color: var(--icon-green-text); }
.bg-orange { background-color: var(--icon-orange); color: var(--icon-orange-text); }
.bg-red { background-color: var(--icon-red); color: var(--icon-red-text); }
.bg-cyan { background-color: var(--icon-cyan); color: var(--icon-cyan-text); }

.tool-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.tool-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    flex-grow: 1;
    line-height: 1.5;
}

/* ========================================================
   Footer
   ======================================================== */
footer {
    border-top: 1px solid var(--border);
    padding: 2.5rem 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    background-color: var(--card-bg);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    transition: color 0.2s;
}

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

/* ========================================================
   Responsive Design
   ======================================================== */
@media (max-width: 768px) {
    .nav-content {
        flex-wrap: wrap;
    }
    .search-bar {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 0.5rem;
    }
    .hero h1 {
        font-size: 2.5rem;
    }
    .hero {
        padding: 4rem 0 3rem;
    }
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* ========================================================
   Unified Tool Base Layout
   ======================================================== */

.tool-main { padding-top: 4rem; padding-bottom: 6rem; max-width: 900px; }
.tool-header { display: flex; align-items: center; gap: 1.5rem; margin-bottom: 2rem; }
.tool-header h1 { font-size: 2.5rem; font-weight: 800; color: var(--text-main); line-height: 1.2; margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.tool-header p { font-size: 1.1rem; color: var(--text-muted); }
.tool-header .icon-wrapper { width: 64px; height: 64px; border-radius: 16px; flex-shrink: 0; }
.tool-header .icon-wrapper i { width: 28px; height: 28px; }

.tool-layout {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

/* Common Form/Action Layout elements */
.textarea-wrapper { margin-bottom: 2rem; }
.tool-actions { display: flex; gap: 1rem; justify-content: flex-end; }
.action-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem; padding: 0.85rem 1.75rem; border-radius: 8px; font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease; font-family: inherit; }
.action-btn i { width: 18px; height: 18px; }

/* Global Theming Overrides ensuring individual instances look consistent */
.primary-btn { border: none; color: white; background-color: var(--primary); }
.primary-btn:hover:not(:disabled) { background-color: var(--primary-hover); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4); }
.primary-btn:active:not(:disabled) { transform: scale(0.96) translateY(0); box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3); }

.secondary-btn { background-color: transparent; color: var(--text-main); border: 1px solid var(--border); }
.secondary-btn:hover:not(:disabled) { background-color: var(--bg); border-color: var(--text-muted); transform: translateY(-2px); }
.secondary-btn:active:not(:disabled) { transform: scale(0.96) translateY(0); }

.filter-btn:active { transform: scale(0.92); }

.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 500px) {
    .tool-actions { flex-direction: column; }
    .action-btn { width: 100%; }
    .tool-layout { padding: 1.5rem; }
    .tool-header h1 { font-size: 2.1rem; }
}

/* Back Link Injection for interior pages */
.back-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2rem;
    transition: color 0.2s, transform 0.2s;
}

.back-home-btn:hover {
    color: var(--primary);
    transform: translateX(-3px);
}

/* ========================================================
   Phase 4 Expansions
   ======================================================== */

/* Favorite Button */
.fav-btn { position: absolute; top: 1rem; right: 1rem; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; transition: all 0.2s; z-index: 2; }
.fav-btn:hover { transform: scale(1.1); color: #eab308; border-color: #eab308; }
.fav-btn.active { color: #eab308; border-color: #eab308; background: rgba(234, 179, 8, 0.1); }
.fav-btn.active i { fill: #eab308; }

/* Empty State */
.empty-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; text-align: center; background: var(--card-bg); border-radius: 12px; border: 1px dashed var(--border); }
.empty-state i { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.5rem; color: var(--text-main); margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-muted); font-size: 1rem; line-height: 1.5; }

/* Global Toast Notifications */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 0.75rem; z-index: 9999; pointer-events: none; }
.toast { background: var(--card-bg); color: var(--text-main); padding: 1rem 1.5rem; border-radius: 8px; border-left: 4px solid var(--primary); box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 0.75rem; font-weight: 500; font-family: inherit; animation: toastSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; pointer-events: auto; }
.toast.toast-fade-out { animation: toastFadeOut 0.3s ease forwards; }
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast i { width: 20px; height: 20px; }
@keyframes toastSlideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastFadeOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* Tool Documentation Articles */
.tool-article { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 3rem; }
.tool-article section { margin-bottom: 2.5rem; }
.tool-article h2 { font-size: 1.5rem; color: var(--text-main); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.tool-article h2 i { color: var(--primary); width: 24px; height: 24px; }
.tool-article p { color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; font-size: 1.05rem; }
.faq-block { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; }
.faq-block h4 { color: var(--text-main); font-size: 1.1rem; margin-bottom: 0.5rem; }
.faq-block p { color: var(--text-muted); margin-bottom: 0; font-size: 0.95rem; }

@view-transition {
    navigation: auto;
}

/* Legal Pages & Complex Footers */
.legal-container { max-width: 800px; margin: 4rem auto; padding: 2rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; }
.legal-container h1 { font-size: 2.5rem; color: var(--text-main); margin-bottom: 1rem; }
.legal-container h2 { font-size: 1.5rem; color: var(--text-main); margin-top: 2rem; margin-bottom: 0.75rem; }
.legal-container p, .legal-container li { color: var(--text-muted); line-height: 1.7; margin-bottom: 1rem; font-size: 1.05rem; }
.legal-container ul { margin-left: 1.5rem; margin-bottom: 1.5rem; }

.site-footer { border-top: 1px solid var(--border); padding: 4rem 0 2rem; margin-top: 4rem; background: var(--bg); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; margin-bottom: 3rem; }
.footer-brand p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; max-width: 300px; }
.footer-links h4 { color: var(--text-main); font-size: 1.1rem; margin-bottom: 1.25rem; font-weight: 600; }
.footer-links a { display: block; color: var(--text-muted); text-decoration: none; margin-bottom: 0.75rem; transition: color 0.2s; }
.footer-links a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 2rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 768px) {
    .footer-grid { grid-template-columns: 1fr; gap: 2.5rem; }
    .desktop-only, .desktop-only-flex { display: none !important; }
}

@media (min-width: 769px) {
    .desktop-only { display: inline-block !important; }
    .desktop-only-flex { display: flex !important; }
}

/* Skeleton Loading Animation */
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--border) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
    border-radius: 8px;
    height: 100%;
    width: 100%;
    pointer-events: none;
    color: transparent !important;
}
.skeleton * { visibility: hidden; }
@keyframes skeletonLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Global Command Palette (Ctrl+K) */
#cmdPaletteWrapper { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 100000; display: none; align-items: flex-start; justify-content: center; padding-top: 15vh; opacity: 0; transition: opacity 0.2s; }
#cmdPaletteWrapper.active { display: flex; opacity: 1; }
.cmd-palette { width: 100%; max-width: 600px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); overflow: hidden; transform: scale(0.95); transition: transform 0.2s; }
#cmdPaletteWrapper.active .cmd-palette { transform: scale(1); }
.cmd-input-wrap { display: flex; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.cmd-input-wrap i { color: var(--text-muted); width: 20px; height: 20px; margin-right: 1rem; }
.cmd-input-wrap input { flex: 1; background: transparent; border: none; color: var(--text-main); font-size: 1.1rem; outline: none; font-family: inherit; }
.cmd-results { max-height: 400px; overflow-y: auto; padding: 0.5rem; }
.cmd-item { display: flex; align-items: center; padding: 1rem; border-radius: 8px; color: var(--text-main); text-decoration: none; transition: background 0.1s; cursor: pointer; }
.cmd-item:hover, .cmd-item.selected { background: var(--card-bg); border-color: var(--primary); outline: 1px solid var(--primary); }
.cmd-item i { width: 18px; margin-right: 1rem; color: var(--text-muted); }
.cmd-item .cmd-text h4 { margin: 0 0 0.25rem 0; font-size: 1rem; color: var(--text-main); font-weight: 500; }
.cmd-item .cmd-text p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
