/*
 * This file is part of the UX SDC Bundle
 *
 * (c) Jozef Môstka <https://github.com/tito10047/ux-sdc>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/* Styles for MainDashboard component */
@layer components {
  .main-dashboard {
    --accent: #00ff00;
    --border: rgba(255, 255, 255, 0.08);
    --text-muted: #888888;
    --text-bright: #ededed;
    --bg-card: #0a0a0a;

    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.25rem;
    color: var(--text-bright);
    font-family: var(--font-sans, system-ui, -apple-system, sans-serif);

    /* Header */
    & .main-dashboard__header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 1rem;
      flex-wrap: wrap;
    }

    & .main-dashboard__title {
      font-size: 1.75rem;
      font-weight: 600;
      letter-spacing: -0.02em;
      margin: 0;
    }

    & .main-dashboard__status {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-top: 0.25rem;
    }

    & .main-dashboard__status-dot {
      width: 8px;
      height: 8px;
      background: var(--accent);
      border-radius: 50%;
      box-shadow: 0 0 8px var(--accent);
      animation: pulse-health 2s infinite ease-in-out;
    }

    & .main-dashboard__btn {
      padding: 0.6rem 1.25rem;
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 6px;
      color: var(--text-bright);
      font-size: 0.875rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

      &:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
      }

      &:active:not(:disabled) {
        transform: translateY(0);
      }

      &:disabled {
        opacity: 0.4;
        cursor: not-allowed;
      }
    }

    /* KPI Grid */
    & .main-dashboard__kpi-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 1rem;
    }

    @media (max-width: 1024px) {
      & .main-dashboard__kpi-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    @media (max-width: 640px) {
      & .main-dashboard__kpi-grid {
        grid-template-columns: 1fr;
      }
    }

    & .main-dashboard__kpi-card {
      padding: 1rem;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      min-height: 100px;
      transition: border-color 0.2s;

      &:hover {
        border-color: rgba(255, 255, 255, 0.15);
      }
    }

    & .main-dashboard__kpi-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      font-weight: 600;
    }

    & .main-dashboard__kpi-value {
      font-size: 1.75rem;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      letter-spacing: -0.01em;
    }

    & .main-dashboard__kpi-trend {
      font-size: 0.75rem;
      font-weight: 500;
      padding: 0.1rem 0.4rem;
      border-radius: 4px;
      background: rgba(255, 255, 255, 0.03);

      &.is-positive { color: #00ff00; background: rgba(0, 255, 0, 0.05); }
      &.is-negative { color: #ff4444; background: rgba(255, 68, 68, 0.05); }
    }

    /* Skeleton */
    & .main-dashboard__skeleton {
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
      
      & .skeleton-line {
        height: 1rem;
        background: rgba(255,255,255,0.03);
        border-radius: 4px;
        position: relative;
        overflow: hidden;

        &::after {
          content: "";
          position: absolute;
          inset: 0;
          background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
          animation: skeleton-shimmer 1.5s infinite;
        }

        &--label { width: 40%; }
        &--value { height: 2.25rem; width: 70%; }
        &--trend { width: 25%; }
      }
    }

    /* Heatmap */
    & .main-dashboard__section {
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }

    & .main-dashboard__section-header {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    & .main-dashboard__section-title {
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.1em;
      margin: 0;
    }

    & .main-dashboard__section-subtitle {
        font-size: 0.7rem;
        color: rgba(255,255,255,0.3);
    }

    & .main-dashboard__heatmap {
      display: grid;
      grid-template-columns: repeat(28, 1fr);
      gap: 4px;
      width: 100%;
      padding: 1rem;
      background: #050505;
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    & .main-dashboard__heat-cell {
      width: 100%;
      aspect-ratio: 1;
      min-height: 12px;
      border-radius: 2px;
      background: rgba(255,255,255,0.02);
      border: 1px solid rgba(255,255,255,0.04);
      transition: all 0.2s;

      &.heat-0 { background: transparent; }
      &.heat-1 { background: #1e1b4b; } 
      &.heat-2 { background: #312e81; }
      &.heat-3 { background: #4338ca; }
      &.heat-4 { 
          background: #6366f1; 
          box-shadow: 0 0 10px rgba(99, 102, 241, 0.3); 
          border-color: rgba(255,255,255,0.2);
      }

      &:hover {
          transform: scale(1.1);
          z-index: 1;
      }
    }

    & .main-dashboard__heatmap-legend {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.65rem;
      color: var(--text-muted);
      margin-top: 0.5rem;

      & div {
        width: 10px;
        height: 10px;
        border-radius: 2px;
      }
    }

    /* Events */
    & .main-dashboard__events {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }

    & .main-dashboard__event {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 0.75rem 1rem;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      transition: all 0.2s;

      &:hover {
        border-color: rgba(255,255,255,0.15);
        background: rgba(255, 255, 255, 0.01);
      }
    }

    & .main-dashboard__event-icon {
      font-size: 1.25rem;
      filter: grayscale(0.5);
    }

    & .main-dashboard__event-content {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
    }

    & .main-dashboard__event-text {
      font-size: 0.85rem;
      font-weight: 500;
    }

    & .main-dashboard__event-time {
      font-size: 0.75rem;
      color: var(--text-muted);
    }
  }
}

@keyframes pulse-health {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.95); }
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}