@import '../admin-shared.scss';

// ===== DASHBOARD - Compact & Mobile-First =====

.dashboard {
  min-height: calc(100vh - 72px);
  padding: $admin-space-lg;
  background: $gradient-bg;
  animation: pageEnter 0.4s ease-out;

  @media (max-width: $admin-container-md) {
    padding: $admin-space-md;
  }
}

.dashboard-container {
  max-width: $admin-container-2xl;
  margin: 0 auto;
}

// ===== HEADER =====
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: $admin-space-md;
  padding: $admin-space-lg;
  background: $glass-bg;
  backdrop-filter: blur(20px);
  border: 1px solid $glass-border;
  border-radius: $radius-lg;
  box-shadow: $shadow-glass;
  margin-bottom: $admin-space-lg;
  animation: slideInLeft 0.4s ease-out;

  @media (max-width: $admin-container-sm) {
    flex-direction: column;
    align-items: flex-start;
    padding: $admin-space-md;
  }
}

.greeting {
  h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    font-weight: 800;
    background: $gradient-primary;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;

    @media (max-width: $admin-container-sm) {
      font-size: 1.25rem;
    }
  }
}

.date-time {
  color: $color-text-secondary;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;

  .separator { opacity: 0.5; }
  .time { font-weight: 500; }
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: white;
  border: 1px solid $glass-border;
  border-radius: $radius-md;
  color: $color-text-primary;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover:not(:disabled) {
    background: rgba($color-brand-primary, 0.06);
    border-color: rgba($color-brand-primary, 0.3);
    color: $color-brand-primary;
  }

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

  app-icon.spin {
    animation: spin 1s linear infinite;
  }

  @media (max-width: $admin-container-sm) {
    width: 100%;
    justify-content: center;
  }
}

// ===== LOADING & ERROR =====
.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $admin-space-2xl $admin-space-lg;
  text-align: center;
  background: $glass-bg;
  backdrop-filter: blur(20px);
  border: 1px solid $glass-border;
  border-radius: $radius-lg;
  animation: scaleIn 0.3s ease-out;

  p {
    color: $color-text-secondary;
    margin-top: $admin-space-md;
  }
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid $glass-border;
  border-top-color: $color-brand-primary;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-state {
  app-icon { color: $color-error; }

  h3 {
    margin: $admin-space-md 0 $admin-space-sm;
    color: $color-text-primary;
  }

  .btn { margin-top: $admin-space-md; }
}

// ===== STATS CARDS =====
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: $admin-space-md;
  margin-bottom: $admin-space-lg;

  @media (max-width: 1200px) {
    grid-template-columns: repeat(2, 1fr);
  }

  @media (max-width: $admin-container-sm) {
    grid-template-columns: 1fr;
    gap: $admin-space-sm;
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: $admin-space-md;
  padding: $admin-space-md;
  background: $glass-bg;
  backdrop-filter: blur(20px);
  border: 1px solid $glass-border;
  border-radius: $radius-lg;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  animation: staggerFade 0.3s ease-out both;

  @for $i from 1 through 4 {
    &:nth-child(#{$i}) {
      animation-delay: #{$i * 0.05}s;
    }
  }

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: $color-brand-primary;
    transition: width 0.2s ease;
  }

  &:hover {
    transform: translateY(-2px);
    box-shadow: $shadow-glass-hover;
    border-color: rgba($color-brand-primary, 0.2);

    &::before { width: 5px; }

    .stat-card__arrow {
      transform: translateX(4px);
      opacity: 1;
    }
  }

  // Color variants
  &--success::before { background: $color-success; }
  &--warning::before { background: $color-warning; }
  &--danger::before { background: $color-error; }
  &--info::before { background: $color-brand-primary; }
  &--primary::before { background: $color-brand-primary; }

  &__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba($color-brand-primary, 0.1);
    border-radius: $radius-md;
    color: $color-brand-primary;
    flex-shrink: 0;
  }

  &--success &__icon { background: rgba($color-success, 0.1); color: $color-success; }
  &--warning &__icon { background: rgba($color-warning, 0.1); color: $color-warning; }
  &--danger &__icon { background: rgba($color-error, 0.1); color: $color-error; }

  &__content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
  }

  &__value {
    font-size: 1.5rem;
    font-weight: 800;
    color: $color-text-primary;
    line-height: 1.2;
  }

  &__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: $color-text-primary;
  }

  &__subtitle {
    font-size: 0.6875rem;
    color: $color-text-secondary;
  }

  &__arrow {
    color: $color-text-tertiary;
    opacity: 0;
    transition: all 0.2s ease;
  }
}

// ===== DASHBOARD GRID =====
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: $admin-space-lg;

  @media (max-width: $admin-container-lg) {
    grid-template-columns: 1fr;
  }
}

.dashboard-section {
  background: $glass-bg;
  backdrop-filter: blur(20px);
  border: 1px solid $glass-border;
  border-radius: $radius-lg;
  padding: $admin-space-lg;
  box-shadow: $shadow-glass;
  animation: scaleIn 0.4s ease-out both;

  &:nth-child(1) { animation-delay: 0.1s; }
  &:nth-child(2) { animation-delay: 0.15s; }
}

.section-header {
  margin-bottom: $admin-space-md;

  h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: $color-text-primary;

    app-icon { color: $color-brand-primary; }
  }
}

// ===== QUICK ACTIONS =====
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: $admin-space-sm;

  @media (max-width: $admin-container-sm) {
    grid-template-columns: 1fr;
  }
}

.quick-action {
  display: flex;
  align-items: center;
  gap: $admin-space-sm;
  padding: $admin-space-sm $admin-space-md;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid transparent;
  border-radius: $radius-md;
  text-decoration: none;
  transition: all 0.2s ease;
  animation: staggerFade 0.25s ease-out both;

  @for $i from 1 through 8 {
    &:nth-child(#{$i}) {
      animation-delay: #{0.2 + $i * 0.03}s;
    }
  }

  &:hover {
    background: rgba($color-brand-primary, 0.06);
    border-color: rgba($color-brand-primary, 0.15);
    transform: translateX(4px);

    .quick-action__arrow {
      opacity: 1;
      transform: translateX(2px);
    }
  }

  &__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba($color-brand-primary, 0.1);
    border-radius: $radius-sm;
    color: $color-brand-primary;
    flex-shrink: 0;
    transition: background 0.2s ease;
  }

  &__content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
  }

  &__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: $color-text-primary;
  }

  &__desc {
    font-size: 0.6875rem;
    color: $color-text-secondary;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__arrow {
    color: $color-text-tertiary;
    opacity: 0;
    transition: all 0.2s ease;
  }
}

// ===== ACTIVITY =====
.activity-group {
  &:not(:last-child) {
    margin-bottom: $admin-space-lg;
    padding-bottom: $admin-space-lg;
    border-bottom: 1px solid $glass-border;
  }

  &__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 $admin-space-sm 0;
    font-size: 0.6875rem;
    font-weight: 600;
    color: $color-text-secondary;
    text-transform: uppercase;
    letter-spacing: 0.5px;

    app-icon { color: $color-text-tertiary; }
  }
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: $admin-space-xs;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: $admin-space-sm;
  padding: $admin-space-sm;
  background: rgba(255, 255, 255, 0.3);
  border-radius: $radius-md;
  text-decoration: none;
  transition: all 0.2s ease;
  animation: staggerFade 0.2s ease-out both;

  @for $i from 1 through 5 {
    &:nth-child(#{$i}) {
      animation-delay: #{0.25 + $i * 0.03}s;
    }
  }

  &:hover {
    background: rgba($color-brand-primary, 0.06);
    transform: translateX(4px);
  }

  &__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba($color-brand-primary, 0.1);
    border-radius: 50%;
    color: $color-brand-primary;
    flex-shrink: 0;

    &.booking {
      background: rgba($color-warning, 0.1);
      color: $color-warning;
    }
  }

  &__content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
  }

  &__name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: $color-text-primary;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__meta {
    font-size: 0.6875rem;
    color: $color-text-secondary;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  &__time {
    font-size: 0.625rem;
    color: $color-text-tertiary;
    white-space: nowrap;
  }

  &__badge {
    font-size: 0.5625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.3px;

    &.pending {
      background: rgba($color-warning, 0.15);
      color: $color-warning;
    }
  }
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: $admin-space-sm;
  font-size: 0.75rem;
  font-weight: 500;
  color: $color-brand-primary;
  text-decoration: none;
  transition: gap 0.2s ease;

  &:hover { gap: 0.5rem; }
}

.empty-activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $admin-space-xl;
  text-align: center;

  app-icon {
    color: $color-success;
    opacity: 0.7;
  }

  h3 {
    margin: $admin-space-sm 0 0.25rem;
    font-size: 0.9375rem;
    color: $color-text-primary;
  }

  p {
    margin: 0;
    font-size: 0.8125rem;
    color: $color-text-secondary;
  }
}

// ===== SYSTEM INFO =====
.system-info {
  display: flex;
  flex-wrap: wrap;
  gap: $admin-space-sm $admin-space-lg;
  margin-top: $admin-space-lg;
  padding: $admin-space-sm $admin-space-md;
  background: $glass-bg;
  backdrop-filter: blur(20px);
  border: 1px solid $glass-border;
  border-radius: $radius-md;

  &__item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: $color-text-secondary;

    app-icon { color: $color-text-tertiary; }
  }
}

// ===== BUTTONS =====
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: $radius-md;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;

  &--primary {
    background: $gradient-primary;
    color: white;
    box-shadow: $shadow-brand;

    &:hover {
      transform: translateY(-1px);
      box-shadow: $shadow-brand-hover;
    }
  }
}
