/* ===== Base64 Encoder/Decoder - Modern Styles ===== */

/* Layout */
.b64-layout { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }
.b64-main { min-width: 0; }
.b64-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 18px;
  padding: 32px; box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}
.b64-sidebar { display: flex; flex-direction: column; gap: 20px; }

/* Settings bar */
.b64-settings { margin-bottom: 20px; background: var(--bg-soft); border-radius: 14px; padding: 16px 20px; border: 1px solid var(--border-light); }
.b64-mode-row { display: flex; gap: 10px; margin-bottom: 14px; }
.b64-mode-btn {
  padding: 10px 22px; border: 2px solid var(--border-light); border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; background: var(--bg);
  color: var(--text-secondary); transition: all 0.2s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
}
.b64-mode-btn:hover { border-color: var(--primary); color: var(--primary); }
.b64-mode-btn.active { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(79,70,229,0.25); }
.b64-mode-btn i { font-size: 13px; }
.b64-options-row { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.b64-opt-group { display: flex; flex-direction: column; gap: 6px; }
.b64-opt-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.b64-select {
  padding: 8px 12px; border: 2px solid var(--border-light); border-radius: 10px;
  font-size: 13px; background: var(--bg); color: var(--text); outline: none;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.b64-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.b64-file-btn {
  padding: 8px 16px; border: 2px dashed var(--primary); border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer; background: var(--primary-50);
  color: var(--primary); transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.b64-file-btn:hover { background: var(--primary); color: #fff; }

/* Section */
.b64-section { margin-bottom: 16px; }
.b64-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--text-secondary);
}
.b64-section-actions { display: flex; gap: 6px; }
.b64-action-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-light);
  background: var(--bg); color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-size: 12px;
}
.b64-action-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Textareas */
.b64-textarea {
  width: 100%; min-height: 140px; padding: 14px 16px;
  border: 2px solid var(--border-light); border-radius: 12px;
  font-size: 14px; font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: var(--bg); color: var(--text); outline: none;
  resize: vertical; transition: border-color 0.2s; line-height: 1.6;
  box-sizing: border-box;
}
.b64-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.b64-textarea[readonly] { background: var(--bg-soft); cursor: default; }
.b64-textarea[readonly]:focus { border-color: var(--border-light); box-shadow: none; }
body[data-theme="dark"] .b64-textarea { background: var(--bg-muted); border-color: var(--border); }
body[data-theme="dark"] .b64-textarea[readonly] { background: var(--bg-muted); }

/* Info bars */
.b64-input-info, .b64-output-info {
  margin-top: 6px; font-size: 12px; color: var(--text-muted);
  display: flex; gap: 16px;
}

/* Auto-toggle */
.b64-auto-row { margin-top: 8px; display: flex; align-items: center; }
.b64-toggle-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-secondary); font-weight: 500; user-select: none; }
.b64-toggle-switch {
  width: 36px; height: 20px; background: var(--border); border-radius: 12px;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.b64-toggle-switch::after {
  content: ''; width: 16px; height: 16px; background: #fff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.b64-toggle-label input:checked + .b64-toggle-switch { background: var(--primary); }
.b64-toggle-label input:checked + .b64-toggle-switch::after { transform: translateX(16px); }
.b64-toggle-label input { display: none; }

/* Error */
.b64-error { margin-top: 12px; padding: 12px 16px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; color: #dc2626; font-size: 13px; font-weight: 500; display: none; }
body[data-theme="dark"] .b64-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #fca5a5; }

/* How-to list */
.b64-howto-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.b64-howto-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.b64-howto-num {
  width: 24px; height: 24px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* Sidebar (shared patterns) */
.sidebar-section { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 16px; padding: 20px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }
.sidebar-header { text-align: center; padding: 28px 20px !important; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; border-color: transparent !important; }
.sidebar-header h1 { font-size: 1.35rem; font-weight: 800; color: #fff; margin-bottom: 6px; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.sidebar-header p { font-size: 0.82rem; color: rgba(255,255,255,0.85); }
body[data-theme="dark"] .sidebar-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; }
.sidebar-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.sidebar-title i { color: var(--primary); font-size: 0.9rem; }
.sidebar-tools { display: flex; flex-direction: column; gap: 8px; }
.sidebar-tool { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; transition: all 0.2s ease; text-decoration: none; background: var(--bg-soft); }
.sidebar-tool:hover { background: var(--primary-50); transform: translateX(3px); }
.sidebar-tool-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 16px; flex-shrink: 0; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.sidebar-tool-info { flex: 1; min-width: 0; }
.sidebar-tool-name { font-size: 0.9rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.sidebar-tool-desc { font-size: 0.78rem; color: var(--text-muted); }
.ad-placeholder { width: 300px; height: 250px; flex-shrink: 0; margin: 0 auto; background: var(--bg-card); border: 2px dashed var(--border); border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--text-muted); font-size: 0.82rem; line-height: 1.5; }
.ad-placeholder .ad-icon { font-size: 1.8rem; color: var(--text-muted); margin-bottom: 10px; opacity: 0.4; }
.ad-placeholder .ad-label { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.ad-placeholder .ad-size { font-size: 0.75rem; color: var(--text-muted); opacity: 0.6; }

/* Dark mode */
body[data-theme="dark"] .b64-card { background: var(--bg-card); border-color: var(--border); }
body[data-theme="dark"] .sidebar-section { background: var(--bg-card); border-color: var(--border); }
body[data-theme="dark"] .sidebar-tool { background: var(--bg-muted); }
body[data-theme="dark"] .sidebar-tool:hover { background: var(--primary-50); }
body[data-theme="dark"] .ad-placeholder { background: var(--bg-card); border-color: var(--border); }
body[data-theme="dark"] .b64-settings { background: var(--bg-muted); border-color: var(--border); }
body[data-theme="dark"] .b64-select { background: var(--bg-muted); border-color: var(--border); }
body[data-theme="dark"] .b64-mode-btn { background: var(--bg-muted); }
body[data-theme="dark"] .b64-mode-btn:hover { background: var(--primary-50); }
body[data-theme="dark"] .b64-action-btn { background: var(--bg-muted); border-color: var(--border); }
body[data-theme="dark"] .b64-action-btn:hover { background: var(--primary); border-color: var(--primary); }
body[data-theme="dark"] .b64-file-btn { background: rgba(79,70,229,0.15); }

/* Responsive */
@media (max-width: 1024px) { .b64-layout { grid-template-columns: 1fr 280px; gap: 20px; } }
@media (max-width: 860px) { .b64-layout { grid-template-columns: 1fr; } .b64-sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } }
@media (max-width: 768px) {
  .b64-card { padding: 20px; }
  .b64-options-row { flex-direction: column; }
  .b64-textarea { min-height: 100px; }
}
@media (max-width: 640px) { .b64-sidebar { grid-template-columns: 1fr; } }