/* ============================================================
   NotesVault — "Aurora" Redesign
   Lighter dark theme with warm amber / cool teal accents.
   Improved readability & contrast.
   No JS changes required.
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
  --bg-deep: #1a1a2e;
  --bg-surface: #22223a;
  --bg-elevated: #2a2a45;
  --accent-1: #f59e0b;          /* warm amber */
  --accent-2: #14b8a6;          /* teal */
  --accent-3: #8b5cf6;          /* violet highlight */
  --text-primary: #f0eff5;
  --text-secondary: #c4c1d4;
  --text-muted: #8e8aaa;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-blur: blur(20px);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --primary-gradient: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-3) 50%, var(--accent-2) 100%);
  --card-gradient: linear-gradient(160deg, rgba(245, 158, 11, 0.08) 0%, rgba(139, 92, 246, 0.06) 50%, rgba(20, 184, 166, 0.08) 100%);
}

/* ---- Base & Typography ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245, 158, 11, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 50% 50% at 0% 80%, rgba(20, 184, 166, 0.07) 0%, transparent 50%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-3);
}

/* ---- Utility: Glass Panel ---- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---- Utility: Text Gradient ---- */
.text-gradient {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
nav {
  transition: background 0.3s ease;
}

.nav-pill {
  display: flex;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#nav-upload,
#nav-view {
  border-radius: 8px;
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: none;
  position: relative;
}

#nav-upload.nav-active,
#nav-view.nav-active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.20), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--accent-1);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.10);
}

#nav-upload:focus,
#nav-view:focus,
#nav-upload:active,
#nav-view:active,
.nav-pill:focus-within {
  outline: none !important;
  box-shadow: none !important;
}

button {
  -webkit-appearance: none;
  appearance: none;
}

/* ============================================================
   FORM — Custom Inputs
   ============================================================ */
.custom-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.10);
  transition: all 0.3s ease;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

.custom-input:focus {
  border-color: var(--accent-1);
  box-shadow:
    0 0 0 3px rgba(245, 158, 11, 0.10),
    0 0 20px rgba(245, 158, 11, 0.08);
  background: rgba(0, 0, 0, 0.35);
}

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

/* ============================================================
   GLOW BUTTON (Save to Vault)
   ============================================================ */
.glow-btn {
  position: relative;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-3));
  z-index: 1;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.3s ease;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.glow-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--accent-3), var(--accent-2));
  z-index: -1;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.glow-btn:hover::before {
  opacity: 1;
}

.glow-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 25px -5px rgba(245, 158, 11, 0.40),
    0 0 40px rgba(139, 92, 246, 0.12);
}

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

/* Button States — Loading / Success / Error */
.glow-btn:disabled {
  cursor: not-allowed;
  opacity: 0.85;
  transform: none !important;
}

.glow-btn.btn-saving {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.6), rgba(20, 184, 166, 0.5));
  pointer-events: none;
}

.glow-btn.btn-success {
  background: linear-gradient(135deg, #10b981, #14b8a6) !important;
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.25);
  pointer-events: none;
}

.glow-btn.btn-error {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.25);
  pointer-events: none;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

.btn-check {
  display: inline-block;
  animation: popIn 0.3s ease;
  vertical-align: middle;
  margin-right: 2px;
}

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

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   NOTE CARDS
   ============================================================ */
.note-card {
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  min-height: 220px;
  padding: 1.25rem;
  position: relative;
  background: var(--card-gradient);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md) !important;

  /* Stagger animation for loading feel */
  animation: cardSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

/* Stagger each card — makes loading feel smooth & intentional */
.note-card:nth-child(1) { animation-delay: 0ms; }
.note-card:nth-child(2) { animation-delay: 60ms; }
.note-card:nth-child(3) { animation-delay: 120ms; }
.note-card:nth-child(4) { animation-delay: 180ms; }
.note-card:nth-child(5) { animation-delay: 240ms; }
.note-card:nth-child(6) { animation-delay: 300ms; }
.note-card:nth-child(7) { animation-delay: 360ms; }
.note-card:nth-child(8) { animation-delay: 420ms; }
.note-card:nth-child(9) { animation-delay: 480ms; }
.note-card:nth-child(10) { animation-delay: 540ms; }
.note-card:nth-child(11) { animation-delay: 600ms; }
.note-card:nth-child(12) { animation-delay: 660ms; }

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Ambient glow on top of each card */
.note-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(245, 158, 11, 0.4) 30%,
    rgba(139, 92, 246, 0.4) 70%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.note-card:hover::before {
  opacity: 1;
}

.note-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: rgba(245, 158, 11, 0.20);
  box-shadow:
    0 20px 40px -15px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(245, 158, 11, 0.06);
}

/* Skeleton shimmer effect on empty notesList (before notes load) */
#notesList:empty {
  position: relative;
  min-height: 300px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

#notesList:empty::before,
#notesList:empty::after {
  content: '';
  display: block;
  min-height: 220px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(110deg,
      rgba(255, 255, 255, 0.03) 30%,
      rgba(255, 255, 255, 0.07) 50%,
      rgba(255, 255, 255, 0.03) 70%
    );
  background-size: 200% 100%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: shimmer 1.8s ease-in-out infinite;
}

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

/* ============================================================
   ENTRY ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-entry {
  animation: fadeIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(20, 20, 40, 0.85);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.10);
  width: 90%;
  max-width: 50rem;
  height: 85vh;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow:
    0 25px 60px -15px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(139, 92, 246, 0.06);
  position: relative;
  transform: scale(0.93) translateY(10px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay:not(.hidden) .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  white-space: nowrap;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.window-dots {
  display: flex;
  gap: 7px;
  margin-right: 1rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: filter 0.2s ease;
}

.dot:hover {
  filter: brightness(1.3);
}

.dot-red {
  background: #ff5f57;
}

.dot-yellow {
  background: #febc2e;
}

.dot-green {
  background: #28c840;
}

.modal-title {
  min-width: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#modal-pre {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
  margin: 0;
  color: #d4dced;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
}

#modal-code {
  white-space: pre;
}

/* Copy Button */
.copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  color: white;
  border-color: rgba(255, 255, 255, 0.15);
}

#modal-x-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

/* ============================================================
   RESPONSIVE TWEAKS
   ============================================================ */
@media (max-width: 640px) {
  .note-card {
    min-height: 190px;
  }
}

@media (max-width: 420px) {
  .copy-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
}

/* ============================================================
   BONUS MICRO-INTERACTIONS
   ============================================================ */

/* Subtle pulse on the brand name gradient */
@keyframes gradientShift {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(15deg); }
}

.text-gradient {
  animation: gradientShift 6s ease-in-out infinite;
}

/* View-btn subtle glow on hover within card */
.view-btn {
  transition: all 0.25s ease !important;
}

.note-card:hover .view-btn {
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
}

/* Upload section top-line glow animation */
@keyframes lineGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

#upload-section .glass-panel > div:first-child {
  animation: lineGlow 3s ease-in-out infinite;
}
