/* =========================================
   1. VARIABLES & THEME
   ========================================= */
:root {
    --bg: #f3f4f6; 
    --side: #ffffff;
    --text: #111827;
    --text-muted: #4b5563;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e5e7eb;
    --card: #ffffff;
    --radius: 12px;
}

[data-theme="dark"] {
    --bg: #030712;
    --side: #111827;
    --text: #f9fafb;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --border: #1f2937;
    --card: #111827;
}

/* =========================================
   2. GLOBAL BASE & TYPOGRAPHY
   ========================================= */
body {
    margin: 0; 
    font-family: 'Fustat', sans-serif;
    display: flex; 
    height: 100vh; 
    background: var(--bg); 
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .logo, .mobile-logo, .modal-title, .answer-value { 
    font-family: "Darumadrop One", sans-serif;
    font-weight: 400;
    font-style: normal;
}

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

/* Ensure the footer layout handles both the button and the link */
a:has(.logo) {
    text-decoration: none;
    color: inherit;
}

/* =========================================
   3. LAYOUT (Sidebar, Header, Main)
   ========================================= */

/* --- SIDEBAR --- */
#sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--side);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    height: 100vh;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo { 
    font-weight: 400; 
    font-size: 1.5rem; 
    margin: 0 0 2rem 1rem;
    text-decoration: none;
    color: var(--text); 
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Sidebar Menu & Scrollbar */
#menu { 
    flex: 1; 
    overflow-y: auto; 
    list-style: none; 
    padding: 0; 
    margin-right: -8px;
    padding-right: 8px;
    scrollbar-width: thin; 
    scrollbar-color: var(--border) transparent; 
}
#menu::-webkit-scrollbar { width: 4px; }
#menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#menu::-webkit-scrollbar-track { background: transparent; }

.nav-category {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1.8rem 0 0.8rem 1rem;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

.nav-item {
    display: block;
    padding: 10px 16px; 
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer; 
    color: var(--text-muted); 
    text-decoration: none;
    transition: all 0.2s ease; 
    font-size: 0.95rem; 
    font-weight: 500;
}

.nav-item:hover { 
    background: var(--bg); 
    color: var(--text); 
    transform: translateX(3px);
}

.nav-item.active { 
    background: var(--accent); 
    color: white; 
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); 
}
.nav-item.active:hover {
    transform: none;
}

/* Sidebar Footer (Theme, Lang, Cookie Buttons) */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.footer-icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 42px; 
    height: 42px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.footer-icon-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* --- MAIN CONTENT AREA --- */
#content { 
    flex: 1; padding: 4rem; overflow-y: auto; 
    display: flex; flex-direction: column; align-items: center; 
}

header { width: 100%; max-width: 850px; margin-bottom: 2.5rem; }
#tool-title { font-size: 2.5rem; margin: 0; letter-spacing: -0.03em; }
#tool-desc { font-size: 1.1rem; color: var(--text-muted); margin-top: 0.5rem; }

/* --- MOBILE SPECIFIC LAYOUT --- */
#mobile-nav {
    display: none; /* Hidden on desktop */
    position: fixed; 
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--side);
    border-bottom: 1px solid var(--border);
    z-index: 1100;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
    box-sizing: border-box;
}

.mobile-logo { font-size: 1.4rem; }

.mobile-actions { 
    display: flex; gap: 4px; flex-shrink: 0; align-items: center;
}

.mobile-icon-btn {
    background: transparent; border: none; font-size: 1.3rem; cursor: pointer;
}

/* =========================================
   4. COMPONENTS
   ========================================= */

/* --- TOOL CARDS (Home Page) --- */
.home-grid { width: 100%; max-width: 1000px; margin-top: 2rem; }
.cat-section h2 { 
    font-size: 1.2rem; text-transform: uppercase; letter-spacing: 0.1em; 
    color: var(--text-muted); margin: 3rem 0 1.5rem 0; 
}
.card-row { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; 
}

.tool-card {
    background: var(--card); border: 1px solid var(--border); 
    padding: 1.5rem; border-radius: 12px;
    text-decoration: none; color: inherit; 
    transition: 0.3s; display: block;
}
.tool-card:hover { 
    transform: translateY(-5px); 
    border-color: var(--accent); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.05); 
}
.tool-card h3 { margin: 0 0 0.5rem 0; font-size: 1.2rem; color: var(--text); }
.tool-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.4; margin-bottom: 1rem; }
.cat-badge { 
    font-size: 0.7rem; background: var(--bg); padding: 4px 8px; 
    border-radius: 4px; font-weight: 600; text-transform: uppercase; 
}

/* --- INPUTS & BUTTONS --- */
input, textarea, select {
    width: 100%; padding: 14px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--bg); color: var(--text);
    margin: 0.4rem 0 1.2rem 0; font-size: 1rem; box-sizing: border-box;
    font-family: inherit; transition: border-color 0.2s;
}
input:focus, textarea:focus { 
    outline: none; border-color: var(--accent); 
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); 
}

.btn-primary {
    background: var(--accent); color: white; border: none;
    padding: 12px 24px; border-radius: 10px; cursor: pointer; 
    font-weight: 600; font-family: 'Outfit', sans-serif;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}
.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.tool-controls { display: flex; gap: 10px; margin-bottom: 1rem; }
.icon-btn { display: none; } /* Legacy cleanup safety? or just remove? I'll leave it hidden just in case */

/* --- CARD CONTAINER (Tool Interface) --- */
.card-container {
    background: var(--card); border: 1px solid var(--border);
    padding: 3rem; border-radius: 16px; 
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.04);
    width: 100%; max-width: 850px; box-sizing: border-box;
}

/* --- RELATED LINKS BOX --- */
.related-box {
    margin-top: 2rem; padding: 1.5rem; 
    background: var(--bg); border-radius: 10px; 
    border-left: 4px solid var(--accent);
}
.related-box h4 { margin-top: 0; margin-bottom: 0.5rem; font-size: 0.9rem; text-transform: uppercase; color: var(--text-muted); }
.related-links { font-size: 0.9rem; margin-top: 0.5rem; }
.related-link, .related-box a { 
    color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.95rem; 
}
.related-link:hover, .related-box a:hover { text-decoration: underline; }

/* --- GLOBAL FOOTER --- */
#global-footer {
    width: 100%; max-width: 850px; margin-top: auto;
    padding: 4rem 0 2rem 0; border-top: 1px solid var(--border);
}
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; margin-bottom: 3rem; }
.footer-col h4 { margin-bottom: 1.2rem; font-size: 1rem; }
.footer-col a { 
    display: block; color: var(--text-muted); text-decoration: none; 
    margin-bottom: 0.6rem; font-size: 0.9rem; transition: 0.2s;
}
.footer-col a:hover { color: var(--accent); }
.copyright { font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* Language Variations in Footer */
.lang-variations a {
    display: block; font-size: 0.9rem; margin-bottom: 8px; opacity: 0.8;
}
.lang-variations a:hover { opacity: 1; text-decoration: underline; }

/* --- MODALS & OVERLAYS --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal-box {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 300px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    text-align: center;
    position: relative;
}

.modal-overlay.open .modal-box { transform: translateY(0); }

.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0; }
.modal-close {
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--text-muted); padding: 0; line-height: 1;
}

.lang-list {
    display: flex; flex-direction: column; gap: 8px;
    max-height: 60vh; overflow-y: auto;
}
.lang-option {
    display: flex; align-items: center; padding: 12px 16px;
    border: 1px solid var(--border); border-radius: 8px;
    text-decoration: none; color: var(--text);
    font-weight: 500; transition: 0.2s;
}
.lang-option:hover {
    background: var(--bg); border-color: var(--accent);
    transform: translateX(4px); margin-right: 4px;
}
.lang-option.active {
    background: var(--accent); color: white; border-color: var(--accent);
}

.cookie-modal-actions {
    display: flex; gap: 1rem; margin-top: 1.5rem; justify-content: center;
}

/* --- COOKIE BANNER (Legacy/Floating) --- */
.cookie-banner {
    position: fixed;
    bottom: 2rem; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 600px;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 9999;
}
.cookie-content {
    display: flex; flex-direction: column; gap: 1rem;
    align-items: center; text-align: center;
}
.cookie-content p { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.cookie-actions { display: flex; gap: 12px; }

/* =========================================
   5. SPECIAL FEATURE STYLES
   ========================================= */

/* --- FEATURED TOOL GLOW --- */
.featured-tool {
    border-color: #fbbf24 !important;
    box-shadow: 0 0 15px rgba(252, 211, 77, 0.4);
    animation: subtleShake 5s ease-in-out infinite;
}
[data-theme="dark"] .featured-tool { box-shadow: 0 0 20px rgba(252, 211, 77, 0.2); }

@keyframes subtleShake {
    0%, 90%, 100% { transform: translate(0, 0) rotate(0); }
    92% { transform: translate(-1px, 0) rotate(-0.5deg); }
    94% { transform: translate(1px, 0) rotate(0.5deg); }
    96% { transform: translate(-1px, 0) rotate(-0.5deg); }
    98% { transform: translate(1px, 0) rotate(0.5deg); }
}

/* --- BLOG STYLES --- */
.blog-listing {
    max-width: 850px; width: 100%; margin-top: 3rem;
}

.blog-card {
    background: var(--card); border: 1px solid var(--border);
    padding: 2rem; border-radius: 12px; margin-bottom: 2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.blog-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); }
.blog-card h2 { margin: 0 0 0.5rem 0; font-size: 1.8rem; }
.blog-card h2 a { color: var(--text); text-decoration: none; }
.blog-card h2 a:hover { color: var(--accent); }
.blog-card-meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.blog-card p { line-height: 1.6; color: var(--text-muted); margin-bottom: 1rem; }

.read-more {
    color: var(--accent); font-weight: 600; text-decoration: none; font-size: 0.95rem;
}
.read-more:hover { text-decoration: underline; }

/* Single Blog Post */
.blog-post { max-width: 750px; width: 100%; }

.blog-meta {
    font-size: 0.9rem; color: var(--text-muted);
    margin-top: 0.5rem; display: flex; gap: 0.5rem;
}

.blog-content { margin-top: 3rem; line-height: 1.8; }
.blog-content h1, .blog-content h2, .blog-content h3 {
    margin-top: 2rem; margin-bottom: 1rem; color: var(--text);
}
.blog-content h2 {
    font-size: 1.8rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
}
.blog-content h3 { font-size: 1.4rem; }
.blog-content p { margin-bottom: 1.5rem; color: var(--text-muted); }
.blog-content a { color: var(--accent); text-decoration: none; font-weight: 500; }
.blog-content a:hover { text-decoration: underline; }
.blog-content ul { margin-left: 2rem; margin-bottom: 1.5rem; }
.blog-content li { margin-bottom: 0.5rem; color: var(--text-muted); }

.related-tools-blog {
    margin-top: 4rem; padding: 2rem;
    background: var(--bg); border-radius: 12px;
    border-left: 4px solid var(--accent);
}
.related-tools-blog h3 { margin-bottom: 1rem; font-size: 1.1rem; }
.related-tools-blog .related-link {
    color: var(--accent); text-decoration: none; font-weight: 600; font-size: 1rem;
}
.related-tools-blog .related-link:hover { text-decoration: underline; }

/* --- INSTANT ANSWER BOX --- */
.instant-answer-box {
    background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
    border-radius: 16px; padding: 2rem; margin: 2rem 0;
    text-align: center; box-shadow: 0 10px 40px rgba(37, 99, 235, 0.3);
}

.answer-label {
    font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.8); margin-bottom: 1rem;
}

.answer-value {
    font-size: 2rem; font-weight: 800; color: white;
    font-family: 'Outfit', sans-serif; line-height: 1.2;
    display: flex; align-items: center; justify-content: center;
    gap: 1rem; flex-wrap: wrap;
}

.answer-from { color: white; }
.answer-equals { color: rgba(255, 255, 255, 0.7); font-size: 1.5rem; }
.answer-to { color: #fbbf24; text-shadow: 0 2px 10px rgba(251, 191, 36, 0.3); }

/* --- SEO SECTION --- */
.seo-hr { margin: 4rem 0 2rem 0; border: 0; border-top: 1px solid var(--border); }
.seo-text { max-width: 700px; line-height: 1.6; color: var(--text-muted); margin-bottom: 3rem; }
.seo-text h2 { color: var(--text); margin-bottom: 1rem; }

/* =========================================
   6. UTILITIES & ANIMATIONS
   ========================================= */

.animate-tick { animation: tick-bump 0.2s ease-out; }
@keyframes tick-bump {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.animate-pop { animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes pop-in {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.animate-fade-in { animation: fadeIn 0.6s ease-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.active-glow {
    box-shadow: 0 0 15px var(--accent);
    animation: glow-pulse 2s infinite;
}
@keyframes glow-pulse {
    0% { box-shadow: 0 0 5px var(--accent); }
    50% { box-shadow: 0 0 20px var(--accent); }
    100% { box-shadow: 0 0 5px var(--accent); }
}

.font-numeric { font-variant-numeric: tabular-nums; letter-spacing: -2px; }

/* Fullscreen API Styles */
:fullscreen {
    width: 100vw; height: 100vh;
    background: var(--bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem; overflow-y: auto;
}
:fullscreen .fs-hide { display: none !important; }
:fullscreen .fs-huge { font-size: min(25vw, 40vh) !important; line-height: 1; }

/* =========================================
   7. MEDIA QUERIES (Mobile)
   ========================================= */

@media (max-width: 768px) {
    /* Sidebar converts to off-canvas menu */
    #sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.1);
        padding-top: 4rem; /* Shift content so logo doesn't overlap header */
    }
    #sidebar.active { transform: translateX(0); }
    
    #content { padding: 5rem 1.5rem 2rem 1.5rem; }
    
    #mobile-nav { display: flex; }
    
    /* Hide floating toggle since it's in the header */
    #mobile-toggle { 
        display: block; position: static; 
        background: transparent; color: var(--text); 
        font-size: 1.5rem; padding: 5px; border: none;
    }
    
    .footer-grid { grid-template-columns: 1fr 1fr; }
    
    .answer-value { font-size: 1.5rem; flex-direction: column; gap: 0.5rem; }
    .answer-equals { font-size: 1.2rem; }
}

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