/* Home Tab Dashboard Styles
 * Responsive card grid for Home tab tiles
 *
 * styles/components/tabs-home.css
 */

/* Main container for home dashboard */
.home-dashboard {
  padding: var(--spacing-4);
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
}

/* Header section */
.home-dashboard__header {
  margin-bottom: var(--spacing-4);
}

.home-dashboard__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--spacing-2) 0;
}

.home-dashboard__subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin: 0;
}

/* Tile grid - responsive */
.home-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--spacing-4);
  margin-top: var(--spacing-4);
}

/* Individual tile (using Shoelace card wrapper) */
.home-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 120px; /* Fixed height for visual consistency */
  padding: 0;
  background: var(--surface-default);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}

/* Clickable tiles get hover effect */
.home-tile--clickable:hover {
  border-color: var(--interactive-primary);
  box-shadow: 0 2px 8px var(--shadow-medium);
  transform: translateY(-2px);
}

.home-tile--clickable:focus {
  outline: 2px solid var(--interactive-primary);
  outline-offset: 2px;
}

/* Non-clickable metric tiles */
.home-tile--metric {
  cursor: default;
  background-color: var(--background-subtle);
}

/* Tile content wrapper */
.home-tile__content {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-4);
  flex: 1;
  gap: var(--spacing-2);
}

/* Tile header with icon */
.home-tile__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--spacing-2);
}

.home-tile__icon {
  font-size: 24px;
  color: var(--interactive-primary);
  flex-shrink: 0;
}

.home-tile--metric .home-tile__icon {
  font-size: 24px;
  color: var(--text-secondary);
}

/* Tile title */
.home-tile__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  line-height: var(--line-height-normal);
}

/* Tile description */
.home-tile__description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: var(--line-height-relaxed);
}

/* Inline metric value (appears in description) */
.home-tile__metric-value--inline {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-lg);
  margin-right: 4px;
}

/* Metric status colors for inline values */
.home-tile__metric-value--inline.status-low {
  color: var(--status-success);
}

.home-tile__metric-value--inline.status-medium {
  color: var(--status-warning);
}

.home-tile__metric-value--inline.status-high {
  color: var(--status-error);
}

/* Loading state */
.home-tile--loading {
  pointer-events: none;
}

.home-tile__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
}

.home-tile__loading-spinner {
  font-size: 24px;
  animation: spin 1s linear infinite;
}

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

.home-tile__loading-text {
  margin-left: var(--spacing-2);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Error state */
.home-tile--error {
  border-color: var(--status-error);
  background: rgba(220, 53, 69, 0.05);
}

.home-tile__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--spacing-4);
  text-align: center;
}

.home-tile__error-icon {
  font-size: 32px;
  color: var(--status-error);
  margin-bottom: var(--spacing-2);
}

.home-tile__error-message {
  font-size: var(--font-size-sm);
  color: var(--status-error);
  margin: 0 0 var(--spacing-2) 0;
}

.home-tile__error-retry {
  font-size: var(--font-size-xs);
  color: var(--interactive-primary);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.home-tile__error-retry:hover {
  color: var(--interactive-primary-hover);
}


/* Keyboard navigation support */
.home-tile:focus-visible {
  outline: 2px solid var(--interactive-primary);
  outline-offset: 2px;
}

/* Responsive breakpoints */

/* Tablet (768px - 1200px) */
@media (max-width: 1200px) {
  .home-dashboard__grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
  }

  .home-tile {
    min-height: 120px;
  }

  .home-tile__icon {
    font-size: 28px;
  }

  .home-tile__metric-value {
    font-size: 40px;
  }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  .home-dashboard {
    padding: var(--spacing-2);
  }

  .home-dashboard__grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .home-tile {
    min-height: 100px;
  }

  .home-tile__header {
    gap: 8px;
  }

  .home-tile__icon {
    font-size: 24px;
  }

  .home-tile__title {
    font-size: var(--font-size-sm);
  }

  .home-tile__description {
    font-size: var(--font-size-xs);
  }

  .home-tile__metric-value {
    font-size: 36px;
  }
}

/* Utility: Pulse animation for metric updates */
@keyframes pulse-update {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.home-tile__metric-value--updating {
  animation: pulse-update 0.6s ease-in-out;
}
