/* =========================================
   Global Variables & Reset
========================================= */
:root {
    --primary-color: #4361EE;
    --primary-dark: #2F3FBD;
    --secondary-color: #F72585;
    --accent-color: #FFB703;
    --accent-green: #06D6A0;
    --danger-color: #ef476f;
    --danger-dark: #d13054;

    --bg-color: #F4F7FE;
    --card-bg: #FFFFFF;
    --panel-bg: #EAF0FE;
    --text-main: #2B2D42;
    --text-muted: #6B7492;

    --border-radius: 20px;
    --border-radius-sm: 14px;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0 15px 32px rgba(67, 97, 238, 0.16);

    /* Optimized for speed: Only Nunito */
    --font-body: 'Nunito', sans-serif;
}

body.dark-mode {
    --bg-color: #0F172A;
    --card-bg: #1E293B;
    --panel-bg: #16213A;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --hover-shadow: 0 15px 32px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

h1, h2, h3, h4, .logo {
    font-weight: 800;
}

:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.hidden { display: none !important; }

/* =========================================
   Navbar (Mobile Responsive)
========================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    background: var(--card-bg);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap; /* Helps with mobile */
}

.logo { font-size: 20px; font-weight: 900; }
.logo a { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 24px; }
.highlight { color: var(--primary-color); }

.nav-links { list-style: none; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.nav-links a { font-weight: 700; color: var(--text-muted); transition: color 0.3s; }
.nav-links a:hover { color: var(--primary-color); }

.theme-btn {
    background: var(--panel-bg);
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: flex; align-items: center; justify-content: center;
}
.theme-btn:hover { transform: scale(1.15) rotate(15deg); }

/* =========================================
   Breadcrumb
========================================= */
.breadcrumb-nav { padding: 18px 5% 0; }
.breadcrumb { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 800px; margin: 0 auto; font-size: 0.9rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); font-weight: 700; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--primary-color); }
.breadcrumb [aria-current="page"] { color: var(--text-main); font-weight: 800; }
.crumb-sep { opacity: 0.6; }

/* =========================================
   Main Tool Layout
========================================= */
.tool-container { display: flex; flex-direction: column; align-items: center; padding: 24px 5% 40px; }
.tool-card { background: var(--card-bg); width: 100%; max-width: 800px; padding: 40px; border-radius: var(--border-radius); box-shadow: var(--box-shadow); text-align: center; }
.card-header { margin-bottom: 24px; }
.tool-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.card-header h1 { font-size: 2.1rem; font-weight: 900; margin-bottom: 12px; color: var(--text-main); }
.subtitle { color: var(--text-muted); margin: 0 auto 24px; font-size: 1.05rem; max-width: 600px; }

.trust-badges { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.trust-badges li { display: flex; align-items: center; gap: 6px; background: var(--panel-bg); padding: 8px 16px; border-radius: 30px; font-weight: 800; font-size: 0.85rem; color: var(--text-main); }

/* =========================================
   Tool Specific: Base64 Controls
========================================= */
.controls-wrapper { background: var(--panel-bg); border-radius: var(--border-radius-sm); padding: 24px; text-align: left; margin-top: 24px; }

/* Input Area */
.input-area { animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.input-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.input-header label { font-weight: 800; color: var(--text-main); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.05em; }

textarea {
    width: 100%;
    height: 180px;
    padding: 18px;
    border-radius: 12px;
    border: 2px solid rgba(141, 153, 174, 0.3);
    background: var(--card-bg);
    color: var(--text-main);
    font-family: monospace; /* Important for code */
    font-size: 0.95rem;
    resize: vertical;
    word-break: break-all;
    transition: border-color 0.3s ease;
    margin-bottom: 15px;
}
textarea:focus { outline: none; border-color: var(--primary-color); }
textarea::-webkit-scrollbar { width: 8px; }
textarea::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* Buttons */
.action-btn { width: 100%; padding: 16px; font-size: 1.1rem; font-weight: 800; background-color: var(--primary-color); color: white; border: none; border-radius: 14px; cursor: pointer; box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3); transition: transform 0.2s, background 0.3s; min-height: 52px; }
.action-btn:hover:not(:disabled) { background-color: var(--primary-dark); transform: translateY(-3px); }
.action-btn:disabled { background-color: var(--text-muted); cursor: not-allowed; transform: none; box-shadow: none; }

.secondary-btn { background-color: var(--card-bg); color: var(--text-main); border: 2px solid var(--text-muted); font-weight: 800; cursor: pointer; transition: all 0.3s ease; }
.secondary-btn:hover { background-color: var(--text-muted); color: white; }
.small-btn { padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; }

.clear-btn { background: var(--danger-color); color: white; border: none; padding: 10px 18px; border-radius: 10px; font-weight: 800; cursor: pointer; transition: background 0.3s; flex-shrink: 0; }
.clear-btn:hover { background: var(--danger-dark); }

/* Image Output Area */
.image-controls { margin-top: 24px; animation: fadeIn 0.5s ease; }
.preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid rgba(141, 153, 174, 0.2); }
.preview-header h3 { font-size: 1.2rem; color: var(--text-main); word-break: break-all; text-align: left; }

.workspace-area { margin-bottom: 24px; }
.image-preview-container { 
    max-height: 450px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    background: repeating-conic-gradient(#e0e0e0 0% 25%, transparent 0% 50%) 50% / 20px 20px; 
    border-radius: 12px; 
    padding: 15px; 
    overflow: hidden; 
    border: 2px solid rgba(141, 153, 174, 0.2);
}
body.dark-mode .image-preview-container { background: repeating-conic-gradient(#334155 0% 25%, transparent 0% 50%) 50% / 20px 20px; }

#image-preview { max-width: 100%; max-height: 400px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); border-radius: 6px; }
.status-message { margin-top: 15px; font-weight: 800; text-align: center; font-size: 1.05rem; }

/* =========================================
   Ad Placeholder & Sections
========================================= */
.ad-placeholder { margin: 10px auto 30px; max-width: 800px; min-height: 90px; display: flex; justify-content: center; width: 100%; }
.content-section { max-width: 800px; margin: 0 auto 30px; padding: 36px 40px; background: var(--card-bg); border-radius: var(--border-radius); box-shadow: var(--box-shadow); }
.content-section h2 { color: var(--primary-color); margin-bottom: 18px; font-size: 1.4rem; font-weight: 900; }
.content-section p, .content-section ol, .content-section ul { margin-bottom: 16px; color: var(--text-muted); font-size: 0.98rem; }
.content-section ol, .content-section ul { padding-left: 22px; }
.content-section li { margin-bottom: 8px; }
.content-section strong { color: var(--text-main); font-weight: 800; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.info-item { background: var(--panel-bg); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.info-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 800; }
.info-value { font-weight: 800; font-size: 1rem; color: var(--text-main); }
.about-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; }
.about-grid p { margin-bottom: 10px; }

/* FAQ & Related */
.faq-accordion { display: flex; flex-direction: column; gap: 12px; }
.faq-item { background: var(--panel-bg); border-radius: 12px; overflow: hidden; }
.faq-trigger { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: none; border: none; cursor: pointer; padding: 18px 20px; text-align: left; font-weight: 800; color: var(--text-main); font-size: 1.05rem; }
.acc-chevron { transition: transform 0.3s ease; color: var(--text-muted); font-size: 1.2rem; }
.faq-trigger[aria-expanded="true"] .acc-chevron { transform: rotate(180deg); color: var(--primary-color); }
.faq-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; padding: 0 20px; }
.faq-item.open .faq-panel { padding: 0 20px 18px; }
.faq-panel p { margin-bottom: 0; font-size: 0.95rem; }

.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.related-card { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--panel-bg); padding: 20px 16px; border-radius: 14px; font-weight: 800; text-align: center; transition: transform 0.25s, box-shadow 0.25s; }
.related-card:hover { transform: translateY(-4px); box-shadow: var(--hover-shadow); }
.related-icon { font-size: 1.8rem; display: block; margin-bottom: 4px; }

/* =========================================
   Rich Footer & Cookie
========================================= */
footer { background: #1A1A2E; color: #E2E8F0; padding: 60px 5% 20px; margin-top: 60px; }
.footer-grid { max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 30px; }
.footer-brand p { color: #9AA5C4; font-size: 0.95rem; margin-top: 14px; max-width: 280px; text-align: left; line-height: 1.6; }
.footer-logo { color: #fff; font-size: 1.5rem; font-weight: 900; display: flex; align-items: center; gap: 6px; }
.footer-col h4 { font-size: 1.1rem; font-weight: 900; margin-bottom: 18px; color: #fff; text-align: left; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 12px; padding: 0; align-items: flex-start; }
.footer-col ul a { color: #9AA5C4; font-size: 0.92rem; font-weight: 700; transition: color 0.3s ease, transform 0.3s ease; text-decoration: none; display: inline-block; }
.footer-col ul a:hover { color: var(--secondary-color); transform: translateX(4px); }
.footer-bottom { max-width: 1200px; margin: 50px auto 0; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.08); text-align: center; color: #8D99AE; font-size: 0.9rem; font-weight: 700; }

.cookie-banner { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 800px; background: var(--card-bg); border-radius: var(--border-radius); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); padding: 20px 30px; display: flex; justify-content: space-between; align-items: center; z-index: 9999; border: 2px solid var(--primary-color); transition: transform 0.5s ease, opacity 0.5s ease; }
.cookie-banner.hidden { transform: translate(-50%, 150px); opacity: 0; pointer-events: none; }
.cookie-content { display: flex; align-items: center; gap: 15px; }
.cookie-icon { font-size: 35px; }
.cookie-content p { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--text-main); line-height: 1.5; }
.cookie-content a { color: var(--primary-color); font-weight: 800; text-decoration: underline; }
.cookie-btn { padding: 12px 25px; font-size: 1.05rem; width: auto; white-space: nowrap; margin-left: 20px; min-height: 44px; background: var(--primary-color); border: none; border-radius: 30px; color: white; font-weight: 800; cursor: pointer; }

/* =========================================
   Responsive (Mobile & Tablet)
========================================= */
@media (max-width: 1024px) {
    .footer-grid { grid-template-columns: repeat(3, 1fr); gap: 40px 20px; }
    .footer-brand { grid-column: 1 / -1; }
    .footer-brand p { max-width: 500px; }
}

@media (max-width: 768px) {
    .navbar { flex-direction: column; gap: 15px; padding: 20px 5%; }
    .nav-links { gap: 12px; }
    
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .about-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 600px) {
    /* Tool UI Mobile Fixes */
    .tool-card { padding: 30px 20px; }
    .controls-wrapper { padding: 20px 15px; }
    .content-section { padding: 30px 20px; }
    .card-header h1 { font-size: 1.6rem; }
    .trust-badges li { font-size: 0.78rem; padding: 7px 12px; }
    
    .input-header { flex-direction: column; align-items: stretch; gap: 10px; }
    .input-header label { text-align: left; }
    
    .preview-header { flex-direction: column; gap: 15px; align-items: stretch; text-align: center; }
    .preview-header h3 { text-align: center; }
    .clear-btn { margin-left: 0; }
    
    /* Footer Mobile Fix */
    footer { padding: 50px 6% 20px; }
    .footer-grid { grid-template-columns: 1fr; text-align: center; gap: 36px; }
    .footer-logo { justify-content: center; }
    .footer-brand p { margin: 14px auto 0; text-align: center; }
    .footer-col h4 { text-align: center; }
    .footer-col ul { align-items: center; }
    .footer-col ul a:hover { transform: translateY(-2px); }

    /* Cookie Banner Mobile Fix */
    .cookie-banner { flex-direction: column; gap: 6px; padding: 12px 16px; bottom: 0; border-radius: 16px 16px 0 0; border-bottom: none; width: 100%; }
    .cookie-content { flex-direction: row; align-items: flex-start; text-align: left; gap: 8px; }
    .cookie-icon { font-size: 18px; margin-top: 2px; }
    .cookie-content p { font-size: 0.8rem; }
    .cookie-btn { width: 100%; margin-left: 0; padding: 10px; font-size: 0.9rem; border-radius: 8px; }
}