/* ============ Shell ============ */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

/* Il brand è ora un <a>: neutralizziamo lo stile di default del link
   (colore/sottolineatura) così il logo resta identico a prima. */
a.app-brand {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.app-brand .icon {
  color: var(--brand);
  width: 20px;
  height: 20px;
}

.app-brand-logo {
  height: 72px;
  width: auto;
  display: block;
}

@media (max-width: 640px) {
  .app-brand-logo { height: 60px; }
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

@media (max-width: 640px) {
  .app-header { padding: var(--space-3) var(--space-4); }
  .app-main { padding: var(--space-5) var(--space-4) var(--space-7); }
}

/* ============ Button ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-4);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--canvas); border-color: var(--ink-faint); }

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--brand-wash); color: var(--ink); }

.btn-icon {
  width: 72px;
  height: 72px;
  padding: 0;
}

.btn-icon .icon {
  width: 34px;
  height: 34px;
}

.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }

.btn .spinner { display: none; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn-label { opacity: 0.7; }

/* ============ Card ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

a.card:hover, .card.is-interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ============ Badge ============ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-neutral { background: var(--canvas); color: var(--ink-muted); border: 1px solid var(--border); }
.badge-brand { background: var(--brand-wash); color: var(--brand); }
.badge-signal { background: var(--signal-wash); color: var(--signal); }
.badge-success { background: var(--success-wash); color: var(--success); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }

/* ============ Stage rail — elemento firma ============ */
/* Visualizza la pipeline reale del progetto (setup -> piano ->
   sviluppo), non è decorativo: ogni pallino è uno stato vero. */

.stage-rail {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-rail-step {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: background-color var(--duration-base) var(--ease-out);
}

.stage-rail-step.is-done .stage-dot { background: var(--brand); }
.stage-rail-step.is-current .stage-dot {
  background: var(--signal);
  animation: pulse-dot 1.8s var(--ease-out) infinite;
}

.stage-line {
  height: 2px;
  flex: 1;
  background: var(--border);
  border-radius: var(--radius-full);
}
.stage-rail-step.is-done .stage-line { background: var(--brand); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============ Avatar ============ */

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-wash);
  border: 1px solid var(--border);
}

/* ============ Skeleton ============ */

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--canvas) 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

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

/* ============ Empty / Error state ============ */

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-5);
  color: var(--ink-muted);
}

.state-block-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--brand-wash);
  color: var(--brand);
}
.state-block-icon.is-danger { background: var(--danger-wash); color: var(--danger); }

.state-block h3 {
  font-size: 16px;
  color: var(--ink);
}

.state-block p {
  font-size: 14px;
  max-width: 36ch;
}

/* ============ Toast ============ */

.toast-region {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
}

@media (max-width: 640px) {
  .toast-region { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in var(--duration-slow) var(--ease-out);
}

.toast.is-leaving {
  animation: toast-out var(--duration-base) var(--ease-out) forwards;
}

.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(4px) scale(0.98); }
}

/* ============ Spinner ============ */

.spinner {
  width: 16px;
  height: 16px;
  animation: spin 0.7s linear infinite;
}

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

/* ============ Rain loader ============ */

.rain-loader {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  max-width: 60vw;
  height: 100vh;
  pointer-events: none;
  z-index: 500;
  overflow: hidden;
}

.rain-drop {
  position: absolute;
  top: -24px;
  opacity: 0;
  animation-name: rain-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

.rain-drop--dot {
  /* rapporto reale dal path: w=2.75 h=2.71, praticamente 1:1 */
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.rain-drop--dash {
  /* rapporto reale dal path: w=2.83 h=4.43 → 1:1.57, un ovale allungato,
     non un trattino sottile come nella prima versione */
  width: 8px;
  height: 12px;
  border-radius: 4px;
}

@keyframes rain-fall {
  0% { transform: translateY(0); opacity: 0; }
  8% { opacity: 0.9; }
  85% { opacity: 0.9; }
  100% { transform: translateY(100vh); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .rain-drop { display: none; }
}

/* ============ Boot splash ============ */

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  transition: opacity 0.25s ease;
}

.boot-splash-logo {
  width: 264px;
  height: 264px;
  animation: boot-pulse 1.6s ease-in-out infinite;
}

@keyframes boot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.92); opacity: 0.7; }
}

.boot-splash.is-hidden {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .boot-splash-logo { animation: none; }
}

/* ============ Language switch ============ */

.lang-switch {
  position: relative;
}

.lang-switch-trigger {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
  line-height: 1;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}
.lang-switch-trigger:hover { background: var(--brand-wash); }

.lang-switch-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 50;
  min-width: 200px;
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.lang-switch.is-open .lang-switch-panel { display: flex; }

.lang-switch-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.lang-switch-item:hover:not(:disabled) { background: var(--brand-wash); }
.lang-switch-item.is-current { font-weight: 700; color: var(--brand); }
.lang-switch-item:disabled { color: var(--ink-faint); cursor: not-allowed; }

.lang-switch-flag { font-size: 18px; }
.lang-switch-label { flex: 1; }
.lang-switch-soon {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

/* ============ Notification bell ============ */

.notification-bell {
  position: relative;
}

.notification-bell-trigger {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}
.notification-bell-trigger:hover { background: var(--brand-wash); }
.notification-bell-trigger .icon { width: 26px; height: 26px; }

.notification-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.notification-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 50;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  gap: 2px;
}
.notification-bell.is-open .notification-panel { display: flex; }

.notification-empty {
  padding: var(--space-4);
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
}

.notification-mark-all {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-2);
}

.notification-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.notification-item:hover { background: var(--brand-wash); }
.notification-item.is-unread { background: var(--brand-wash); }
.notification-item.is-unread .notification-message { font-weight: 600; }

.notification-message {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}
.notification-time {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
}

/* ============ Theme toggle ============ */

.theme-toggle {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}
.theme-toggle .icon { width: 34px; height: 34px; }
.theme-toggle:hover { background: var(--brand-wash); color: var(--ink); }
.theme-toggle .icon-moon { display: none; }
[data-theme='dark'] .theme-toggle .icon-sun { display: none; }
[data-theme='dark'] .theme-toggle .icon-moon { display: block; }

/* ============ Fade transition per il router ============ */

.page-fade-enter {
  animation: page-fade-in var(--duration-slow) var(--ease-out);
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
