/* ---------- Native smooth cross-page transitions (macOS-like) ---------- */
@view-transition {
  navigation: auto;
}

/* Sidebar + topbar persist visually across page navigations instead of flashing */
[data-persist="sidebar"] {
  view-transition-name: app-sidebar;
}
[data-persist="topbar"] {
  view-transition-name: app-topbar;
}
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar),
::view-transition-old(app-topbar),
::view-transition-new(app-topbar) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  animation: theme-fade-out 0.18s cubic-bezier(0.4, 0, 1, 1) both;
}
::view-transition-new(root) {
  animation: theme-fade-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes theme-fade-out {
  to { opacity: 0; }
}
@keyframes theme-fade-in {
  from { opacity: 0; transform: translateY(4px); }
}

/* ---------- Base polish ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: #c7c4d8 transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7c4d8; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #a5a2ba; }

a, button, input, select, textarea {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}
button:active, a:active {
  transform: scale(0.97);
}

/* ---------- macOS-style sidebar ---------- */
.macos-sidebar {
  background: rgba(244, 244, 248, 0.78);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-right: 1px solid rgba(20, 27, 43, 0.08);
}
.sidebar-brand-icon {
  background: linear-gradient(155deg, #4d44e3 0%, #3525cd 60%, #2a1cb0 100%);
  box-shadow: 0 2px 6px rgba(53, 37, 205, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #45445a;
}
.nav-link .material-symbols-outlined {
  font-size: 19px;
  color: #6b6a80;
  transition: color 0.15s ease;
}
.nav-link:hover:not(.active) {
  background: rgba(20, 27, 43, 0.055);
}
.nav-link.active {
  background: #3525cd;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(53, 37, 205, 0.4);
  animation: nav-pop 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.nav-link.active .material-symbols-outlined {
  color: #ffffff;
}
.nav-link.disabled {
  color: #a9a8ba;
  cursor: not-allowed;
}
.nav-link.disabled .material-symbols-outlined {
  color: #c2c1d1;
}
@keyframes nav-pop {
  from { transform: scale(0.96); opacity: 0.5; }
}

/* ---------- Topbar ---------- */
.app-topbar {
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid rgba(20, 27, 43, 0.08);
}
.topbar-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #5c5f60;
}
.topbar-action:hover {
  background: rgba(20, 27, 43, 0.055);
  color: #141b2b;
}
.topbar-action.danger:hover {
  background: rgba(186, 26, 26, 0.08);
  color: #ba1a1a;
}

/* ---------- Card entrance + hover lift ---------- */
.card-lift {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(20, 27, 43, 0.08);
}
.stagger-in > * {
  animation: theme-fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.02s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.14s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.18s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.22s; }

/* ---------- Glass surfaces (macOS vibrancy feel) ---------- */
.glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
}
.glass-strong {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
}

/* ---------- Modal system (shared by confirm/toast/custom modals) ---------- */
.ui-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 27, 43, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: theme-fade-in 0.18s ease both;
}
.ui-modal-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid rgba(199, 196, 216, 0.6);
  border-radius: 1rem;
  box-shadow: 0 24px 64px rgba(20, 27, 43, 0.22);
  animation: ui-pop-in 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.ui-modal-card.leaving {
  animation: ui-pop-out 0.16s cubic-bezier(0.4, 0, 1, 1) both;
}
@keyframes ui-pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
}
@keyframes ui-pop-out {
  to { opacity: 0; transform: scale(0.96) translateY(4px); }
}

/* ---------- Toast stack ---------- */
#ui-toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ui-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(199, 196, 216, 0.6);
  box-shadow: 0 12px 32px rgba(20, 27, 43, 0.18);
  font-size: 0.85rem;
  color: #141b2b;
  animation: ui-toast-in 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.ui-toast.leaving {
  animation: ui-toast-out 0.18s cubic-bezier(0.4, 0, 1, 1) both;
}
@keyframes ui-toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
}
@keyframes ui-toast-out {
  to { opacity: 0; transform: translateX(12px); }
}
.ui-toast-icon { flex-shrink: 0; margin-top: 1px; }
.ui-toast.success .ui-toast-icon { color: #10B981; }
.ui-toast.error .ui-toast-icon { color: #EF4444; }
.ui-toast.info .ui-toast-icon { color: #3525cd; }

/* ---------- Searchable select (Select2-like) ---------- */
.uisel {
  position: relative;
}
.uisel-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.uisel-panel {
  position: absolute;
  z-index: 100;
  margin-top: 6px;
  min-width: 100%;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid rgba(199, 196, 216, 0.7);
  border-radius: 0.75rem;
  box-shadow: 0 16px 40px rgba(20, 27, 43, 0.16);
  overflow: hidden;
  animation: ui-pop-in 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.uisel-search {
  padding: 8px;
  border-bottom: 1px solid rgba(199, 196, 216, 0.5);
}
.uisel-search input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.85rem;
  padding: 4px 6px;
}
.uisel-options {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.uisel-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: #141b2b;
}
.uisel-option:hover,
.uisel-option.highlighted {
  background: rgba(53, 37, 205, 0.08);
}
.uisel-option.selected {
  background: rgba(53, 37, 205, 0.12);
  color: #3525cd;
  font-weight: 600;
}
.uisel-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: 0.8rem;
  color: #5c5f60;
}
