/* ---------- Page load progress bar ---------- */

.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--gradient-primary);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}
.page-progress.active {
  animation: pageProgress 0.5s var(--ease-out);
}

/* ---------- Login screen ---------- */

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
  transition: opacity 0.4s var(--ease-out);
}
.login-screen.fade-out { opacity: 0; pointer-events: none; }

.login-bg {
  position: absolute;
  inset: 0;
  background: var(--gradient-mesh), var(--bg);
  z-index: -1;
}

.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem 2rem;
  width: min(400px, 100%);
  text-align: center;
  animation: cardIn 0.5s var(--ease-out) both;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.login-brand .brand-mark {
  font-size: 2.5rem;
  filter: drop-shadow(0 6px 14px rgba(91, 91, 246, 0.35));
}
.login-brand h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-tagline {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.login-checking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0;
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  text-align: left;
  margin-bottom: 1.1rem;
}
.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.setup-step code {
  background: var(--bg-hover);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.setup-num {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.unauthorized-icon {
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
}
.unauthorized-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.login-note {
  margin-top: 1.1rem;
  font-size: 0.78rem;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ---------- App shell layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
}
.app-shell.shown { opacity: 1; }
.app-shell[hidden] { display: none; }

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.75rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.main-topbar h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.main-topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* Quick-access link to the live client demo — always reachable while pitching. */
.icon-btn-gelato {
  background: linear-gradient(135deg, #ec4899 0%, #f97316 45%, #10b981 100%);
  border-color: transparent;
  text-decoration: none;
  box-shadow: 0 4px 14px -2px rgba(236, 72, 153, 0.5);
  animation: gelatoGlow 2.8s ease-in-out infinite;
}
.icon-btn-gelato:hover {
  background: linear-gradient(135deg, #ec4899 0%, #f97316 45%, #10b981 100%);
  transform: scale(1.08) rotate(0deg);
  box-shadow: 0 6px 18px -2px rgba(236, 72, 153, 0.65);
}

.sync-badge {
  font-size: 0.76rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.sync-badge.sync-cloud { color: var(--info); border-color: var(--info); background: var(--info-soft); }

.view-root {
  flex: 1;
  padding: 1.5rem 1.75rem 3rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Topbar global search ---------- */

.topbar-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 440px;
}
.topbar-search .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  font-size: 0.85rem;
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  padding: 0.55rem 0.8rem 0.55rem 2.3rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.topbar-search input:focus {
  background: var(--bg-input);
}

.global-search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 25;
  animation: dropIn 0.18s var(--ease-out);
}

.search-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 0.5rem 0.6rem 0.25rem;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.search-result-meta {
  font-size: 0.76rem;
  color: var(--text-faint);
  font-weight: 500;
  flex-shrink: 0;
}
.search-empty { padding: 0.75rem 0.6rem; color: var(--text-faint); font-size: 0.85rem; }

/* ---------- Global "+ Add" menu ---------- */

.add-menu { position: relative; }
.add-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.4rem;
  min-width: 190px;
  z-index: 25;
  animation: dropIn 0.18s var(--ease-out);
}
.add-menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.add-menu-dropdown button:hover { background: var(--bg-hover); }
.add-menu-dropdown button span { font-size: 1.05rem; }

.add-icon { font-size: 1.05rem; line-height: 1; }
#addMenuBtn.open { box-shadow: var(--shadow-glow); }

/* ---------- FAB (mobile quick-add) ---------- */

.fab {
  display: none;
  position: fixed;
  right: 1.1rem;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 999px;
  border: none;
  background: var(--gradient-primary);
  color: white;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 10px 28px rgba(91, 91, 246, 0.4);
  z-index: 35;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}
.fab:active { transform: scale(0.92); }
.fab.open { transform: rotate(45deg); }

/* ---------- Sidebar (desktop) ---------- */

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem 1.4rem;
}
.sidebar-brand .brand-mark {
  font-size: 1.6rem;
  filter: drop-shadow(0 4px 10px rgba(91, 91, 246, 0.35));
}
.brand-name {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { font-size: 0.72rem; color: var(--text-faint); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
  transition: background 0.25s var(--ease-out), color 0.25s var(--ease-out), transform 0.15s var(--ease-spring);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); transform: translateX(2px); }
.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 6px 16px rgba(91, 91, 246, 0.32);
}
.nav-icon { font-size: 1.1rem; }
.nav-label { line-height: 1.2; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem;
}
.user-avatar {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  background: var(--gradient-primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { min-width: 0; }
.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Bottom nav (mobile) ---------- */

.bottom-nav {
  display: none;
}
