/* Rêve Mieux — Styles Globaux */
/* ============================== */

/* Base reset for mobile nav to work */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(15, 10, 30, 0.5); }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); }

/* ========== App Shell — proper fixed layout ========== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.3), 0 0 10px rgba(139, 92, 246, 0.1); }
  50% { box-shadow: 0 0 15px rgba(139, 92, 246, 0.5), 0 0 30px rgba(139, 92, 246, 0.2); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-float { animation: float 3s ease-in-out infinite; }
.animate-glow { animation: glow 2s ease-in-out infinite; }
.animate-slideUp { animation: slideUp 0.4s ease-out; }
.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-pulse-ring { animation: pulse-ring 1.5s ease-out infinite; }

/* Background stars effect */
.stars-bg {
  background-image: radial-gradient(2px 2px at 20px 30px, rgba(139, 92, 246, 0.3), transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(196, 181, 253, 0.2), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(139, 92, 246, 0.4), transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(167, 139, 250, 0.2), transparent),
    radial-gradient(2px 2px at 160px 30px, rgba(139, 92, 246, 0.15), transparent);
  background-size: 200px 100px;
}

/* Glass morphism cards */
.glass {
  background: rgba(15, 15, 40, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(139, 92, 246, 0.15);
}
.glass-light {
  background: rgba(25, 20, 55, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(139, 92, 246, 0.1);
}

/* Dream type badges */
.badge-lucid { background: linear-gradient(135deg, #10b981, #059669); }
.badge-nightmare { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.badge-recurring { background: linear-gradient(135deg, #f59e0b, #d97706); }
.badge-normal { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.badge-hypnagogic { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.badge-false_awakening { background: linear-gradient(135deg, #ec4899, #db2777); }

/* Graph nodes */
.graph-node { cursor: pointer; transition: all 0.2s; }
.graph-node:hover { filter: brightness(1.3); }

/* Emotion picker */
.emotion-btn {
  transition: all 0.2s;
  cursor: pointer;
}
.emotion-btn:hover { transform: scale(1.15); }
.emotion-btn.selected { transform: scale(1.2); box-shadow: 0 0 12px rgba(139, 92, 246, 0.5); }

/* Voice recording animation */
.recording-pulse {
  animation: pulse-ring 1s ease-out infinite;
  background: rgba(239, 68, 68, 0.3);
  border-radius: 50%;
}

/* Tab navigation */
.nav-tab {
  transition: all 0.2s;
  position: relative;
}
.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: linear-gradient(90deg, #8b5cf6, #6366f1);
  border-radius: 2px;
}

/* Tooltip */
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.tooltip:hover::after { opacity: 1; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-content {
  background: linear-gradient(145deg, rgba(20, 15, 45, 0.95), rgba(10, 8, 25, 0.98));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 1rem;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  max-width: 600px;
}
/* On mobile, reduce modal height to account for the fixed bottom nav (~60px + safe area) */
@media (max-width: 639px) {
  .modal-overlay {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }
  .modal-content {
    max-height: calc(90vh - 4.5rem);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
  }
}

/* Incubation mode */
.incubation-bg {
  background: linear-gradient(180deg, #0a0520 0%, #1a0a3a 30%, #0f0a1e 100%);
}

/* Heatmap */
.heatmap-cell { border-radius: 2px; transition: all 0.15s; }
.heatmap-cell:hover { stroke: rgba(139, 92, 246, 0.6); stroke-width: 1px; }

/* ========== Mobile Bottom Nav ========== */
/* Main styles are now inline on the element for max specificity.
   This class is kept as a safety net only. */
#main-nav-mobile {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 9999 !important;
}

/* ========== Dream Map Container — square aspect ratio ========== */
.graph-map-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 80vh;
  max-width: 80vh; /* ensure square even if width > height */
  margin: 0 auto; /* center the square */
}
@media (max-width: 639px) {
  .graph-map-container {
    /* On mobile, use full width as the square side */
    max-width: 100%;
    max-height: 90vw;
  }
}

/* ========== Dream type picker buttons ========== */
.dream-type-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.dream-type-btn:active { transform: scale(0.95); }

/* ========== Tag chip styles ========== */
.tag-chip { -webkit-tap-highlight-color: transparent; }
.tag-chip i:active { transform: scale(1.3); }

/* ========== Existing tags picker ========== */
.existing-tag-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.existing-tag-btn:active { transform: scale(0.92); }

/* ========== Series dream checkbox list ========== */
.series-dream-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  cursor: pointer;
}

/* ========== Phase editor items ========== */
.phase-item {
  -webkit-tap-highlight-color: transparent;
}

/* ========== Auth error shake animation ========== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}
.animate-shake { animation: shake 0.5s ease-in-out; }
