/* ========================================
   NeonMail - Cyberpunk Design System
   ======================================== */

:root {
  /* Backgrounds */
  --bg-primary: #0a0a0f;
  --bg-panel: #101018;
  --bg-card: #16161f;
  --bg-hover: #1c1c28;
  --bg-active: #22222f;
  --bg-input: #12121a;

  /* Neon accents */
  --neon-cyan: #00f0ff;
  --neon-purple: #b44dff;
  --neon-green: #39ff14;
  --neon-magenta: #ff2d7b;
  --neon-yellow: #ffe600;
  --neon-orange: #ff6b2b;

  /* Glow variants (lower opacity for glows) */
  --glow-cyan: rgba(0, 240, 255, 0.3);
  --glow-purple: rgba(180, 77, 255, 0.3);
  --glow-green: rgba(57, 255, 20, 0.3);
  --glow-magenta: rgba(255, 45, 123, 0.3);

  /* Text */
  --text-primary: #e8e8f0;
  --text-secondary: #9898aa;
  --text-muted: #5a5a6e;
  --text-inverse: #0a0a0f;

  /* Borders */
  --border-color: #2a2a3a;
  --border-active: #3a3a4f;

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Sizing */
  --sidebar-width: 260px;
  --toolbar-height: 52px;
  --header-height: 56px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* ---- Reset & Base ---- */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--neon-cyan);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #66f7ff;
  text-shadow: 0 0 8px var(--glow-cyan);
}

::selection {
  background: rgba(0, 240, 255, 0.2);
  color: var(--text-primary);
}

.hidden { display: none !important; }

#app {
  height: 100vh;
  overflow: hidden;
}

/* ---- Custom Scrollbars ---- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--neon-cyan);
  border-radius: 3px;
  opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
  background: #66f7ff;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--neon-cyan) transparent;
}

/* ---- Loading Overlay ---- */

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  gap: 32px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.hex-spinner {
  position: relative;
  width: 80px;
  height: 80px;
}

.hex-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: 50%;
}

.hex-ring:nth-child(1) {
  border-top-color: var(--neon-cyan);
  animation: hex-spin 1.2s linear infinite;
}

.hex-ring:nth-child(2) {
  inset: 8px;
  border-right-color: var(--neon-purple);
  animation: hex-spin 1.6s linear infinite reverse;
}

.hex-ring:nth-child(3) {
  inset: 16px;
  border-bottom-color: var(--neon-magenta);
  animation: hex-spin 2s linear infinite;
}

@keyframes hex-spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--neon-cyan);
  text-shadow: 0 0 20px var(--glow-cyan), 0 0 40px var(--glow-cyan);
  animation: neon-flicker 3s ease-in-out infinite;
}

@keyframes neon-flicker {
  0%, 100% { opacity: 1; text-shadow: 0 0 20px var(--glow-cyan), 0 0 40px var(--glow-cyan); }
  5% { opacity: 0.8; text-shadow: 0 0 10px var(--glow-cyan); }
  5.5% { opacity: 1; text-shadow: 0 0 20px var(--glow-cyan), 0 0 40px var(--glow-cyan); }
  50% { opacity: 1; text-shadow: 0 0 25px var(--glow-cyan), 0 0 50px var(--glow-cyan); }
  55% { opacity: 0.85; text-shadow: 0 0 15px var(--glow-cyan); }
  55.5% { opacity: 1; text-shadow: 0 0 20px var(--glow-cyan), 0 0 40px var(--glow-cyan); }
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-active);
  background: var(--bg-hover);
}

.btn:active {
  transform: translateY(0);
}

/* Ripple effect */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0);
  animation: ripple-expand 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-expand {
  to { transform: scale(4); opacity: 0; }
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan), #00c4d4);
  color: var(--text-inverse);
  border-color: var(--neon-cyan);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #33f5ff, var(--neon-cyan));
  box-shadow: 0 0 20px var(--glow-cyan), 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: #66f7ff;
}

.btn-danger {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
}

.btn-danger:hover {
  background: rgba(255, 45, 123, 0.15);
  box-shadow: 0 0 12px var(--glow-magenta);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
  justify-content: center;
}

.btn .btn-loading {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: hex-spin 0.6s linear infinite;
}

/* Send button special animation */
.btn-send.sent .btn-label {
  animation: send-morph 0.6s ease forwards;
}

@keyframes send-morph {
  0% { transform: scale(1); }
  30% { transform: scale(0.8); opacity: 0.5; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.btn-send.sent::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--glow-cyan) 0%, transparent 70%);
  animation: send-burst 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes send-burst {
  0% { opacity: 1; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(2.5); }
}

/* ---- Form Inputs ---- */

.input, .textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all var(--transition-normal);
  outline: none;
}

.input:focus, .textarea:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px var(--glow-cyan), 0 0 15px var(--glow-cyan);
  animation: focus-pulse 2s ease-in-out infinite;
}

@keyframes focus-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--glow-cyan), 0 0 15px var(--glow-cyan); }
  50% { box-shadow: 0 0 0 4px rgba(0, 240, 255, 0.15), 0 0 20px var(--glow-cyan); }
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}

.textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-sans);
  transition: min-height var(--transition-smooth);
}

.textarea:focus {
  min-height: 200px;
}

/* ---- Labels ---- */

.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

/* ---- Badge ---- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.badge-unread {
  background: var(--neon-cyan);
  color: var(--text-inverse);
  animation: badge-glow 2s ease-in-out infinite;
}

@keyframes badge-glow {
  0%, 100% { box-shadow: 0 0 4px var(--glow-cyan); }
  50% { box-shadow: 0 0 10px var(--glow-cyan), 0 0 20px rgba(0, 240, 255, 0.15); }
}

/* ---- Checkbox ---- */

.checkbox-wrap {
  position: relative;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-wrap input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.checkbox-visual {
  position: absolute;
  inset: 0;
  border: 2px solid var(--border-active);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  transition: all var(--transition-normal);
}

.checkbox-visual::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid var(--text-inverse);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--transition-normal);
}

.checkbox-wrap input:checked + .checkbox-visual {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px var(--glow-cyan);
}

.checkbox-wrap input:checked + .checkbox-visual::after {
  transform: rotate(45deg) scale(1);
}

/* ---- Toast Notifications ---- */

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
  overflow: hidden;
}

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

@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

.toast-success { border-left: 3px solid var(--neon-green); }
.toast-error { border-left: 3px solid var(--neon-magenta); }
.toast-info { border-left: 3px solid var(--neon-cyan); }
.toast-warning { border-left: 3px solid var(--neon-yellow); }

.toast-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-message {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--neon-cyan);
  animation: toast-progress-shrink var(--toast-duration, 4s) linear forwards;
}

.toast-success .toast-progress { background: var(--neon-green); }
.toast-error .toast-progress { background: var(--neon-magenta); }
.toast-warning .toast-progress { background: var(--neon-yellow); }

@keyframes toast-progress-shrink {
  from { width: 100%; }
  to { width: 0%; }
}

/* ---- Skeleton Loading ---- */

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 90%; }

/* ---- View Transitions ---- */

.view-enter {
  animation: view-fade-in 0.15s ease forwards;
}

@keyframes view-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-item {
  opacity: 0;
  animation: stagger-in 0.25s ease forwards;
}

@keyframes stagger-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Empty State ---- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: var(--text-muted);
  gap: 16px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  animation: empty-pulse 3s ease-in-out infinite;
}

@keyframes empty-pulse {
  0%, 100% {
    border-color: var(--border-color);
    box-shadow: none;
  }
  50% {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 20px var(--glow-cyan);
  }
}

.empty-state-text {
  font-size: 15px;
  font-weight: 500;
}

.empty-state-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Utility ---- */

.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }
.text-sm { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* ---- Mobile backdrop ---- */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 768px) {
  .sidebar-backdrop.active {
    display: block;
  }
}
