/* ===== CSS Variables & Theme ===== */
:root {
  --bg: #06080d;
  --surface: #0d1117;
  --card: #131921;
  --card-hover: #1a2233;
  --primary: #a78bfa;
  --primary-dim: rgba(167, 139, 250, 0.15);
  --secondary: #38bdf8;
  --encode: #22c55e;
  --encode-dim: rgba(34, 197, 94, 0.15);
  --decode: #f59e0b;
  --decode-dim: rgba(245, 158, 11, 0.15);
  --hash: #ef4444;
  --hash-dim: rgba(239, 68, 68, 0.15);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-code: #4ade80;
  --border: #1e293b;
  --border-light: #2d3b4f;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #c4b5fd;
}

/* ===== Top Bar ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.top-bar__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo__icon {
  color: var(--primary);
}

.logo__text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo__tagline {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 300;
}

.top-bar__center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.current-cipher {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--primary);
  background: var(--primary-dim);
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: 500;
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--primary);
  color: #0f0f1a;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn--primary:hover {
  background: #c4b5fd;
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.4);
}

.btn--outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn--outline:hover, .btn--outline.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-dim);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 0.75rem;
}

.btn--ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn--sm { padding: 6px 14px; font-size: 0.8rem; }
.btn--xs { padding: 4px 8px; font-size: 0.75rem; }

.btn--process {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 1rem;
  border-radius: var(--radius);
}

/* ===== Layout ===== */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 50;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar__toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  display: flex;
  align-items: center;
}

.sidebar__toggle:hover {
  color: var(--text);
}

.sidebar__nav {
  padding: 0 8px 16px;
}

.sidebar__group {
  margin-bottom: 8px;
}

.sidebar__group-title {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 6px;
}

.cipher-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.cipher-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.cipher-item.active {
  border-left-color: var(--primary);
  background: var(--primary-dim);
  color: var(--primary);
}

.cipher-item__icon {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
}

.cipher-item__name {
  font-weight: 400;
}

/* ===== Mobile Cipher Bar ===== */
.mobile-cipher-bar {
  display: none;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mobile-cipher-bar::-webkit-scrollbar {
  display: none;
}

.cipher-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.cipher-pill:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.cipher-pill.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  transition: margin-left 0.3s ease;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar.collapsed ~ .main,
.layout:has(.sidebar.collapsed) .main {
  margin-left: 0;
}

/* ===== Toast System ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease forwards;
  max-width: 360px;
}

.toast--success { border-left: 3px solid var(--encode); }
.toast--error { border-left: 3px solid var(--hash); }
.toast--info { border-left: 3px solid var(--secondary); }

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

/* ===== Keyboard Shortcuts Hint ===== */
.shortcuts-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
  z-index: 50;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.shortcuts-hint:hover {
  opacity: 1;
}

.shortcuts-hint span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ===== Hidden ===== */
.hidden {
  display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
  }

  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-cipher-bar {
    display: flex;
  }

  .main {
    margin-left: 0;
  }

  .logo__tagline {
    display: none;
  }

  .shortcuts-hint {
    display: none;
  }
}

@media (max-width: 768px) {
  .top-bar {
    padding: 0 12px;
  }

  .top-bar__center {
    display: none;
  }

  .main {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 12px;
  }

  .top-bar__right span {
    display: none;
  }
}
