/* ─── Base Styles — Mobile-First App Shell ─── */

/* ── App Shell Layout ── */
#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom));
}

/* ── Header ── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.app-title {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-container {
  padding: var(--space-4);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  height: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom));
  padding-bottom: var(--safe-area-inset-bottom);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface-primary);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -1px 4px rgba(0,0,0,0.04);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: var(--touch-comfortable);
  min-height: var(--touch-comfortable);
  padding: var(--space-1) var(--space-2);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: color 0.15s;
  border-radius: var(--radius-md);
}
.nav-item.active { color: var(--color-primary-500); }
.nav-item:active { background: var(--color-primary-50); }

.nav-label { font-size: 10px; line-height: 1; }

/* ── FAB (Floating Action Button) ── */
.fab {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: -12px;
}
.fab:active {
  transform: scale(0.92);
  box-shadow: var(--shadow-sm);
}
.fab:focus-visible {
  outline: 3px solid var(--color-primary-300);
  outline-offset: 3px;
}

/* ── Network Banner ── */
.network-banner {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  z-index: calc(var(--z-sticky) - 1);
  padding: 6px var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-align: center;
  transition: transform 0.2s;
}
.network-banner.offline { background: #FEE2E2; color: #991B1B; }
.network-banner.slow { background: var(--status-pending-bg); color: var(--status-pending-text); }
.network-banner.syncing { background: #DBEAFE; color: #1E40AF; }
.network-banner[hidden] { display: none; }

/* ── Status Dot ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}
.status-dot.online { background: #10B981; }
.status-dot.offline { background: #EF4444; }

/* ── Sync Badge ── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  cursor: pointer;
}
.sync-badge[hidden] { display: none; }

/* ── Spinner Animation ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom) + var(--space-4));
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 420px;
  margin: 0 auto;
}

.toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}
.toast.success { background: var(--color-primary-500); color: var(--text-inverse); }
.toast.error { background: #DC2626; color: var(--text-inverse); }
.toast.warning { background: var(--status-pending-bg); color: var(--status-pending-text); border: 1px solid var(--status-pending-border); }
.toast.info { background: #DBEAFE; color: #1E40AF; border: 1px solid #93C5FD; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Utility classes ── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-min);
  height: var(--touch-min);
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}