/**
 * Redesigned logged-in shell: footer, topbar, Home/Activity segments.
 * Mobile-first (Android Chrome + iOS Safari): always-visible chrome, safe areas, 44px targets.
 */

:root {
  --shell-footer-height: 64px;
  --shell-footer-height-compact: 48px;
  --shell-topbar-height: 60px;
  --shell-topbar-height-compact: 56px;
  --shell-touch-min: 44px;
}

body.shell-redesign {
  --topbar-height: var(--shell-topbar-height);
}

/* ----- Footer: five-item primary nav ----- */
.footer.footer--redesign {
  transform: none !important;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: calc(var(--shell-footer-height) + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  visibility: visible !important;
  display: block !important;
}

.footer.footer--redesign.footer--hidden {
  transform: none !important;
}

.footer.footer--redesign .footer-row {
  align-items: stretch;
  min-height: var(--shell-footer-height);
  height: auto;
  padding-top: 2px;
  padding-bottom: 2px;
}

.footer.footer--redesign .footer-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  height: auto;
}

.footer.footer--redesign .footer-btn {
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  min-height: var(--shell-touch-min);
  min-width: 0;
  height: auto !important;
  padding: 6px 2px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* base.css uses overflow:hidden which clips icon+label column */
  overflow: visible !important;
}

.footer.footer--redesign .footer-btn-label {
  display: block;
  font-size: 0.625rem;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: 0.01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}

.footer.footer--redesign .footer-btn-center {
  position: relative;
  color: var(--footer-fg) !important;
}

/* Kill legacy center-button ::before disc (base.css) — we style the icon itself */
.footer.footer--redesign .footer-btn-center:before {
  content: none !important;
  display: none !important;
  animation: none !important;
}

.footer.footer--redesign .footer-btn-center i {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-on-accent);
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.28);
  flex-shrink: 0;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .footer.footer--redesign .footer-btn-center i {
    box-shadow: 0 1px 4px rgba(var(--accent-rgb), 0.2);
  }
}

html[data-theme="light"] .footer.footer--redesign .footer-btn-center i {
  box-shadow: 0 1px 4px rgba(var(--accent-rgb), 0.2);
}

.footer.footer--redesign .footer-btn-center .footer-btn-label {
  color: var(--footer-fg);
}

body.shell-redesign {
  padding-bottom: calc(var(--shell-footer-height) + env(safe-area-inset-bottom, 0px));
}

/* Landscape phones: keep chrome, drop labels (icon-only compact) */
@media screen and (orientation: landscape) and (max-width: 991px) {
  .footer.footer--redesign {
    transform: none !important;
    min-height: calc(var(--shell-footer-height-compact) + env(safe-area-inset-bottom, 0px));
  }

  .footer.footer--redesign .footer-row {
    min-height: var(--shell-footer-height-compact);
  }

  .footer.footer--redesign .footer-btn-label {
    display: none;
  }

  .footer.footer--redesign .footer-btn-center i {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  body.shell-redesign {
    padding-bottom: calc(var(--shell-footer-height-compact) + env(safe-area-inset-bottom, 0px));
  }

  .topbar.topbar--redesign {
    transform: none !important;
    padding-bottom: 4px;
  }

  .topbar.topbar--redesign.topbar--hidden {
    transform: none !important;
  }

  body.shell-redesign {
    --topbar-height: var(--shell-topbar-height-compact);
    padding-top: var(--dynamic-topbar-height, var(--shell-topbar-height-compact));
  }
}

/* Never hide redesign chrome via legacy landscape media rules */
@media screen and (orientation: landscape) and (max-width: 991px) {
  .footer.footer--redesign,
  .topbar.topbar--redesign {
    transform: none !important;
  }
}

/* ----- Topbar redesign ----- */
.topbar.topbar--redesign {
  transform: none !important;
  padding-top: env(safe-area-inset-top, 0px);
  max-height: 72px;
  padding-bottom: 6px;
}

.topbar.topbar--redesign .topbar-create-btn {
  min-height: var(--shell-touch-min);
  min-width: var(--shell-touch-min);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Do not reuse .search-container here — base.css sets min-height:100vh for the /search/ page */
.topbar.topbar--redesign .topbar-search {
  position: relative;
  margin-right: 0.75rem;
  width: 220px;
  flex: 0 0 auto;
}

.topbar.topbar--redesign .topbar-search .search-input {
  min-height: 40px;
  height: 40px;
  padding-left: 2rem;
  width: 100%;
  min-width: 0 !important;
}

.topbar.topbar--redesign .topbar-search .search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.65;
}

/* ----- Segment tabs + filter chips ----- */
.shell-segment-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  margin-bottom: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.shell-segment-tabs::-webkit-scrollbar {
  display: none;
}

.shell-segment-tab {
  flex: 1 1 0;
  text-align: center;
  min-height: var(--shell-touch-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  color: var(--text-tertiary, rgba(255, 255, 255, 0.55));
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.shell-segment-tab.active {
  color: var(--text-primary, #fff);
  border-bottom-color: var(--accent);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .shell-segment-tabs {
    border-bottom-color: rgba(15, 23, 42, 0.08);
  }

  :root:not([data-theme]) .community-chip {
    border-color: rgba(15, 23, 42, 0.1);
    background: rgba(255, 255, 255, 0.6);
  }

  :root:not([data-theme]) .community-chip.active {
    background: rgba(var(--accent-rgb), 0.1);
  }
}

html[data-theme="light"] .shell-segment-tabs {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .community-chip {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.6);
}

html[data-theme="light"] .community-chip.active {
  background: rgba(var(--accent-rgb), 0.1);
}

.community-filter-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0 0.75rem;
  scrollbar-width: none;
}

.community-filter-chips::-webkit-scrollbar {
  display: none;
}

.community-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--text-secondary, rgba(255, 255, 255, 0.75));
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.community-chip.active {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

/* ----- Due today / create hub / activity ----- */
.due-today-section {
  display: block;
  text-decoration: none;
  color: inherit;
}

.due-today-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--shell-touch-min);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
}

.due-today-status {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-tertiary, rgba(255, 255, 255, 0.4));
  flex-shrink: 0;
}

.due-today-status.is-done {
  border-color: var(--success, #22c55e);
  background: var(--success, #22c55e);
  position: relative;
}

.due-today-status.is-done::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.create-hub-list .create-hub-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: var(--shell-touch-min);
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
}

button.create-hub-row {
  font: inherit;
  text-align: left;
}

.create-hub-list .create-hub-row:active {
  background: var(--footer-hover-bg, rgba(255, 255, 255, 0.06));
}

.create-hub-group-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0.75rem 1rem 0.25rem;
  margin: 0;
}

.today-dashboard-card {
  margin-bottom: 1rem;
}

.today-dashboard-card .card-body {
  padding: 1rem;
}

/* ----- Hub shells: Home, Activity, Create ----- */
.home-shell,
.activity-hub,
.create-hub {
  max-width: 640px;
  padding-top: 0.5rem !important;
  padding-bottom: 1rem !important;
}

.hub-panel {
  background: var(--card-bg, var(--surface-elevated));
  border: 1px solid var(--border);
  border-radius: var(--border-radius, 8px);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.hub-panel--primary {
  box-shadow: var(--shadow-sm);
}

.hub-panel__body {
  padding: 1rem;
}

.hub-panel__section-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.hub-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--shell-touch-min);
  padding: 0.65rem 0;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  text-decoration: none;
  color: inherit;
}

.hub-link-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.hub-link-row__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.hub-link-row__hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.15rem;
}

.hub-link-row__action {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.due-today-section.hub-panel {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.due-today-section.hub-panel:hover {
  border-color: color-mix(in oklch, var(--accent) 25%, var(--border));
  box-shadow: var(--shadow-md);
}

.today-dashboard .hub-insights {
  margin-bottom: 0.75rem;
}

.today-dashboard .hub-insights .insight-card {
  margin-bottom: 0 !important;
}

.today-dashboard .hub-insights .insight-card .card {
  border: 1px solid var(--border);
  box-shadow: none;
  background: var(--card-bg);
}

.today-dashboard .hub-insights .insight-card .card:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}

.activity-hub .hub-panel .h5,
.activity-hub > .h3 {
  margin-bottom: 0.75rem;
}

.activity-hub .activity-empty-state {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
}

.create-hub-list.hub-panel {
  box-shadow: var(--shadow-sm);
}

.create-hub-list .create-hub-row:hover {
  background: var(--footer-hover-bg, rgba(255, 255, 255, 0.06));
}

.create-hub-list .create-hub-row:last-child {
  border-bottom: none;
}

.create-hub-list .create-hub-row i {
  width: 1.25rem;
  text-align: center;
  color: var(--accent);
  opacity: 0.9;
}

@media (max-width: 575.98px) {
  .home-shell,
  .activity-hub,
  .create-hub {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
