@import './themes.css';

/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  font-family: 'M PLUS Rounded 1c', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ============================================================
   AMBIENT ATMOSPHERE
   ============================================================ */
.ambient-mist {
  position: fixed; inset: -50%; pointer-events: none; z-index: -3;
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, var(--mist-color), transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 70%, var(--mist-color-2), transparent 45%),
    radial-gradient(ellipse 90% 70% at 50% 50%, var(--mist-color), transparent 55%);
  filter: blur(40px);
  animation: mistDrift 20s ease-in-out infinite;
}

.ambient-bloom {
  position: fixed; inset: 0; pointer-events: none; z-index: -2;
  background: radial-gradient(circle at 50% 50%, var(--bloom-color) 0%, transparent 50%);
  animation: bloomPulse 30s ease-in-out infinite;
}

.ambient-grain {
  position: fixed; inset: -100%; pointer-events: none; z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  opacity: var(--grain-opacity);
  animation: grainShift 8s steps(10) infinite;
}

@keyframes mistDrift {
  0%, 100% { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%       { transform: translate3d(1%, 0.5%, 0) scale(1.02); }
}
@keyframes bloomPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.05); }
}
@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  10%  { transform: translate(-1%, -1%); }
  20%  { transform: translate(1%, 1%); }
  30%  { transform: translate(-0.5%, 0.5%); }
  40%  { transform: translate(0.5%, -0.5%); }
  50%  { transform: translate(-1%, 1%); }
  60%  { transform: translate(1%, -1%); }
  70%  { transform: translate(0%, 1%); }
  80%  { transform: translate(-1%, 0%); }
  90%  { transform: translate(1%, 0.5%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .ambient-mist, .ambient-bloom, .ambient-grain { display: none !important; }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.glass {
  background: var(--bg-glass, rgba(13,31,26,0.7));
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.glass-sm {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.625rem 1.25rem;
  border-radius: var(--radius-pill); font-size: 0.875rem; font-weight: 600;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--brand); color: #000;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-color: var(--brand);
}

.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 600;
  background: var(--brand); color: #000;
}
.badge-premium { background: linear-gradient(135deg, #a855f7, #ec4899); color: #fff; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   TOP NAV BAR
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-logo {
  font-size: 1.125rem; font-weight: 600;
  display: flex; align-items: center; gap: 0.5rem;
}

.topbar-logo .leaf { color: var(--brand); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem;
}

.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 360px;
}

.toast.toast-success { border-color: #4ade80; }
.toast.toast-error   { border-color: #f87171; }
.toast.toast-info    { border-color: var(--brand); }

.toast-out { animation: toastOut 0.2s ease forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px); } }

/* ============================================================
   MODAL BASE
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  width: 90%; max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96);
  transition: transform 0.15s ease;
}

.modal-backdrop.open .modal { transform: scale(1); }

.modal-title {
  font-size: 1.125rem; font-weight: 600;
  margin-bottom: 1.25rem;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.form-label { font-size: 0.875rem; font-weight: 600; color: var(--text-dim); }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.625rem 0.875rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.875rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
}

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

.form-actions {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
