/**
 * Premium SaaS shell helpers — server-rendered Razor friendly.
 * Loaded after design-system.css; uses existing CSS variables for theme parity.
 * (Display font loaded in design-system.css — use --tv-font-display.)
 */

.tw-shell-page-title {
  font-family: var(--tv-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--tv-text);
}

@media (min-width: 768px) {
  .tw-shell-page-title {
    font-size: 1.875rem;
  }
}

.tw-shell-page-sub {
  margin-top: 0.25rem;
  max-width: 48rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--tv-text-muted);
}

.tw-shell-card {
  overflow: hidden;
  border-radius: var(--tv-radius-xl, 12px);
  border: 1px solid var(--tv-border-subtle);
  background: var(--tv-surface);
  box-shadow: var(--tv-card-shadow);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tw-shell-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--tv-shadow-md);
  border-color: rgba(var(--tv-primary-rgb), 0.15);
}

.tw-shell-card-header {
  border-bottom: 1px solid var(--tv-border-subtle);
  background: var(--tv-surface);
  padding: 1.25rem 1.25rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--tv-text);
  letter-spacing: -0.01em;
}

.tw-shell-card-body {
  padding: 1.25rem;
}

.tw-shell-card.tw-shell-card-fill {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tw-shell-card.tw-shell-card-fill .tw-shell-card-body {
  flex: 1 1 auto;
}

.tw-shell-kpi-strip {
  margin-bottom: 1.5rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .tw-shell-kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .tw-shell-kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .tw-shell-kpi-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.tw-shell-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (min-width: 576px) {
  .tw-shell-quick-actions.tw-shell-quick-actions--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.5rem 0.75rem;
    align-items: stretch;
  }

  .tw-shell-quick-actions.tw-shell-quick-actions--grid .btn {
    justify-content: center;
    width: 100%;
    cursor: pointer;
    transition:
      transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
      box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1),
      border-color 0.18s ease;
  }

  .tw-shell-quick-actions.tw-shell-quick-actions--grid .btn:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tw-shell-quick-actions.tw-shell-quick-actions--grid .btn {
    transition: none;
  }

  .tw-shell-quick-actions.tw-shell-quick-actions--grid .btn:hover {
    transform: none;
  }

  .tw-shell-card:hover {
    transform: none;
  }
}

/* Shell card variant: no outer lift (dense interactive children handle their own hover). */
.tw-shell-card.tw-shell-card--flat-hover:hover {
  transform: none;
  box-shadow: var(--tv-card-shadow);
  border-color: var(--tv-border);
}

/* Dashboard fast-create shortcut tiles (icon + label). */
.tv-dash-shortcuts {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(7.75rem, 1fr));
}

@media (min-width: 480px) {
  .tv-dash-shortcuts {
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  }
}

@media (min-width: 1200px) {
  .tv-dash-shortcuts {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  }
}

.tv-dash-shortcut {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.625rem;
  padding: 1rem 0.625rem;
  min-height: 6.75rem;
  text-align: center;
  text-decoration: none;
  color: var(--tv-text);
  border-radius: var(--tv-radius-md, 10px);
  border: 1px solid var(--tv-border);
  background: var(--tv-bg-muted);
  transition:
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.tv-dash-shortcut:hover {
  color: var(--tv-text);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--tv-shadow-sm);
  border-color: rgba(var(--tv-primary-rgb), 0.22);
  background: var(--tv-surface);
}

.tv-dash-shortcut:focus-visible {
  outline: 2px solid rgba(var(--tv-primary-rgb), 0.35);
  outline-offset: 2px;
}

.tv-dash-shortcut__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(var(--tv-primary-rgb), 0.1);
  color: rgb(var(--tv-primary-rgb));
}

.tv-dash-shortcut__icon svg {
  display: block;
}

.tv-dash-shortcut__label {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
  hyphens: auto;
}

.tv-dash-shortcut--tone-info .tv-dash-shortcut__icon {
  background: rgba(var(--tv-info-rgb), 0.12);
  color: rgb(var(--tv-info-rgb));
}

.tv-dash-shortcut--tone-success .tv-dash-shortcut__icon {
  background: rgba(var(--tv-success-rgb), 0.12);
  color: rgb(var(--tv-success-rgb));
}

.tv-dash-shortcut--tone-warn .tv-dash-shortcut__icon {
  background: rgba(var(--tv-warning-rgb), 0.14);
  color: var(--tv-warning);
}

.tv-dash-shortcut--tone-muted .tv-dash-shortcut__icon {
  background: rgba(var(--tv-primary-rgb), 0.06);
  color: var(--tv-text-secondary);
}

@media (prefers-reduced-motion: reduce) {
  .tv-dash-shortcut {
    transition: none;
  }

  .tv-dash-shortcut:hover {
    transform: none;
  }
}

/* Dashboard top panel: welcome + date + status strip */
.tv-dash-top-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tv-dash-top-panel__head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: 640px) {
  .tv-dash-top-panel__head {
    flex-direction: row;
    align-items: flex-start;
  }
}

.tv-dash-top-panel__lead {
  min-width: 0;
  flex: 1 1 auto;
}

.tv-dash-top-panel__eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tv-text-muted);
}

.tv-dash-top-panel__welcome {
  margin: 0 0 0.5rem;
  font-family: var(--tv-font-display, system-ui, sans-serif);
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--tv-text);
}

.tv-dash-top-panel__sub {
  margin: 0;
  max-width: 40rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--tv-text-secondary);
}

.tv-dash-top-panel__meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
  align-self: flex-start;
}

@media (min-width: 640px) {
  .tv-dash-top-panel__meta {
    align-self: center;
    margin-inline-start: auto;
  }
}

.tv-dash-top-panel__date {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tv-text-secondary);
  white-space: nowrap;
}

.tv-dash-top-panel__cal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: var(--tv-bg-muted);
  color: var(--tv-text);
  border: 1px solid var(--tv-border);
}

.tv-dash-top-panel__divider {
  height: 1px;
  margin: 1.25rem 0 1rem;
  background: var(--tv-border);
  opacity: 0.85;
}

.tv-dash-status-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-md, 10px);
  overflow: hidden;
  background: var(--tv-bg-muted);
}

@media (min-width: 640px) {
  .tv-dash-status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.tv-dash-status-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
  text-decoration: none;
  color: var(--tv-text);
  border-bottom: 1px solid var(--tv-border);
  transition:
    background-color 0.15s ease,
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 640px) {
  .tv-dash-status-card {
    border-bottom: none;
    border-inline-end: 1px solid var(--tv-border);
  }

  .tv-dash-status-card:last-child {
    border-inline-end: none;
  }
}

.tv-dash-status-card:last-child {
  border-bottom: none;
}

.tv-dash-status-card:hover {
  color: var(--tv-text);
  text-decoration: none;
  background: var(--tv-surface);
}

.tv-dash-status-card:focus-visible {
  outline: 2px solid rgba(var(--tv-primary-rgb), 0.35);
  outline-offset: -2px;
  z-index: 1;
}

.tv-dash-status-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  background: rgba(var(--tv-primary-rgb), 0.08);
  color: rgb(var(--tv-primary-rgb));
}

.tv-dash-status-card__icon--warn {
  background: rgba(var(--tv-warning-rgb), 0.12);
  color: var(--tv-warning);
}

.tv-dash-status-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  flex: 1;
}

.tv-dash-status-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tv-text-secondary);
  line-height: 1.3;
}

.tv-dash-status-card__metric {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tv-dash-status-card__value {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tv-text);
  line-height: 1.2;
}

.tv-dash-status-card__delta {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.tv-dash-status-card__delta-ico {
  flex-shrink: 0;
}

.tv-dash-status-card__delta--more {
  color: var(--tv-warning);
}

.tv-dash-status-card__delta--less {
  color: rgb(var(--tv-success-rgb));
}

.tv-dash-status-card__delta--flat,
.tv-dash-status-card__delta-neutral {
  color: var(--tv-text-muted);
  font-weight: 500;
}

.tv-dash-status-card__hint {
  font-size: 0.6875rem;
  color: var(--tv-text-muted);
  margin-top: 0.125rem;
}

.tv-dash-top-panel__art {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--tv-border-subtle, var(--tv-border));
}

.tv-dash-top-panel__art .tv-dashboard-banner__art {
  width: min(100%, 280px);
}

@media (prefers-reduced-motion: reduce) {
  .tv-dash-status-card {
    transition: none;
  }
}

.tw-animate-fade-in {
  animation: tvUiFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.tw-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--tv-radius-md);
  background: linear-gradient(
    90deg,
    var(--tv-bg-muted) 0%,
    rgba(var(--tv-primary-rgb), 0.06) 50%,
    var(--tv-bg-muted) 100%
  );
  background-size: 200% 100%;
  animation: tvUiShimmer 1.2s ease-in-out infinite;
}

@keyframes tvUiFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tvUiShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.tv-theme .form-control,
.tv-theme .form-select {
  border-radius: var(--tv-radius-md);
  border: 1px solid var(--tv-border-strong);
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: var(--tv-surface);
  color: var(--tv-text);
  box-shadow: var(--tv-shadow-inset-input, none);
}

.tv-theme .form-control:focus,
.tv-theme .form-select:focus {
  border-color: var(--tv-primary);
  box-shadow: 0 0 0 3px var(--tv-primary-soft);
  outline: none;
}

.tv-theme .form-label {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--tv-text-secondary);
  margin-bottom: 0.375rem;
}

.tv-theme .btn:focus,
.tv-theme .btn:active:focus,
.tv-theme .btn-link.nav-link:focus {
  box-shadow: 0 0 0 0.1rem var(--tv-surface), 0 0 0 0.25rem var(--tv-primary-soft);
}
