/* 
   BASE64 ENCODER DECODER - EXPERT WEB TOOLS
   Theme: 2026 Glassmorphism (Mobile Anti-Scroll)
*/

@font-face { font-family: 'Inter'; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Roboto Mono'; src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    --bg-dark: #0a0a0f;
    --primary-accent: #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --card-bg: rgba(25, 25, 35, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(0, 0, 0, 0.3);
    
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-code: 'Roboto Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* CRITICAL MOBILE FIX: Lock overflow to prevent horizontal stretching */
html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.background-glow {
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.08) 0%, rgba(10, 10, 15, 0) 50%);
    z-index: -1; pointer-events: none;
}

/* --- Header --- */
.tool-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%; }
.back-btn { color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 8px; transition: color 0.3s; }
.back-btn:hover { color: var(--primary-accent); }
.logo { font-family: var(--font-heading); font-size: 1.2rem; }
.logo span { color: var(--primary-accent); }

/* --- Main Layout --- */
.main-content { flex-grow: 1; padding: 2rem 5%; max-width: 1200px; margin: 0 auto; width: 100%; }

.tool-intro { text-align: center; margin-bottom: 2rem; }
.tool-intro h1 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 0.5rem; }
.tool-intro p { color: var(--text-muted); }

.card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 1.5rem; backdrop-filter: blur(10px); width: 100%;
}

/* --- Tabs --- */
.tabs-nav { display: flex; gap: 10px; margin-bottom: 1.5rem; border-bottom: 1px solid var(--card-border); padding-bottom: 1rem; overflow-x: auto; }
.tab-btn { background: transparent; border: none; color: var(--text-muted); padding: 10px 20px; font-family: var(--font-heading); font-size: 0.9rem; cursor: pointer; border-radius: 8px; transition: all 0.2s; white-space: nowrap; }
.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-btn.active { background: var(--primary-accent); color: #fff; }

.tool-pane { display: none; animation: fadeIn 0.3s ease; }
.tool-pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Text Mode (Grid) --- */
.io-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: stretch; }
.io-column { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.action-column { display: flex; flex-direction: column; justify-content: center; gap: 1rem; }

.pane-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pane-header label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

textarea {
    flex-grow: 1; background: var(--input-bg); border: 1px solid var(--card-border);
    color: #fff; padding: 1rem; border-radius: 8px; font-family: var(--font-code);
    font-size: 0.95rem; resize: none; min-height: 400px; outline: none; line-height: 1.5;
}
textarea:focus { border-color: var(--primary-accent); }

/* --- File Mode --- */
.file-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 2rem; align-items: start; }
.upload-section { display: flex; flex-direction: column; gap: 1rem; }
.output-section { display: flex; flex-direction: column; height: 100%; }

.drop-area {
    border: 2px dashed var(--card-border); border-radius: 12px; padding: 3rem 1rem; text-align: center;
    cursor: pointer; transition: all 0.2s; background: rgba(255,255,255,0.02);
}
.drop-area:hover, .drop-area.dragover { border-color: var(--primary-accent); background: rgba(59, 130, 246, 0.05); }
.upload-icon { font-size: 3rem; color: var(--secondary-accent); margin-bottom: 1rem; }
.drop-area h3 { font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 5px; }

.file-info {
    display: flex; justify-content: space-between; align-items: center; background: var(--input-bg);
    border: 1px solid var(--card-border); padding: 12px 15px; border-radius: 8px;
}
.file-details { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.text-green { color: #10b981; }
#fileNameDisplay { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: rgba(255,255,255,0.1); font-size: 0.75rem; padding: 2px 6px; border-radius: 4px; color: var(--text-muted); }

.settings-box { background: rgba(0,0,0,0.2); border: 1px solid var(--card-border); padding: 1rem; border-radius: 8px; }
.toggle-checkbox { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 0.95rem; cursor: pointer; user-select: none; }
.toggle-checkbox input { accent-color: var(--primary-accent); cursor: pointer; width: 16px; height: 16px; }

/* Buttons */
.primary-btn { background: var(--primary-accent); color: #fff; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: background 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.primary-btn:hover { background: #2563eb; }
.secondary-btn { background: transparent; color: #fff; border: 1px solid var(--card-border); padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.secondary-btn:hover { background: rgba(255,255,255,0.05); border-color: #fff; }

.icon-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; transition: color 0.2s; padding: 5px; }
.icon-btn:hover { color: #fff; }
.icon-btn.danger:hover { color: #ef4444; }
.action-group { display: flex; gap: 10px; }

/* Utilities */
.hidden { display: none !important; opacity: 0; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
.mt-1 { margin-top: 1rem; }
.hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e1e24; border: 1px solid var(--primary-accent); color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 2000; box-shadow: 0 4px 12px rgba(0,0,0,0.5); transition: opacity 0.3s; font-size: 0.9rem; }
.toast.error { border-color: #ef4444; color: #fca5a5; }

/* Info Section */
.info-section { margin-top: 4rem; padding: 0 1rem; }
.info-section h2 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 2rem; font-size: 1.5rem; text-align: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.info-grid h3 { color: var(--primary-accent); font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 0.5rem; }
.info-grid i { margin-right: 8px; }
.info-grid p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }
.faq-container { margin-top: 2rem; }
.faq-container h3 { font-family: var(--font-heading); color: var(--text-main); margin: 1.5rem 0 1rem; }
.faq-container h4 { color: var(--secondary-accent); font-size: 1rem; margin-bottom: 0.5rem; margin-top: 1.5rem; }
.faq-container p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; line-height: 1.6; }
footer { text-align: center; padding: 3rem 0; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--card-border); margin-top: 3rem; }
footer a { color: #fff; text-decoration: none; }

/* Responsive */
@media (max-width: 900px) {
    .io-grid { grid-template-columns: 1fr; gap: 1rem; }
    .action-column { flex-direction: row; }
    .action-column button { flex: 1; }
    textarea { min-height: 250px; }
    
    .file-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .tool-header, .main-content { padding: 1.5rem 1rem; }
    .card { padding: 1.25rem; }
    .info-grid { grid-template-columns: 1fr; }
}