$background: #eef2ff;
$surface: #ffffff;
$text-dark: #0f172a;
$text-muted: #6b7280;
$border: rgba(148, 163, 184, 0.4);

:host {
  display: block;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: $text-dark;
}

.dashboard-wrapper {
  min-height: 100vh;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 35%, #ffffff 100%);
  display: flex;
  flex-direction: column;
}

.dashboard-main {
  flex: 1;
  padding-bottom: 4rem;
}

.loading-container,
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
}

.spinner-wrapper {
  margin-bottom: 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  color: #4f46e5;
}

.loading-text {
  color: $text-muted;
}

.error-card {
  background: $surface;
  border-radius: 24px;
  padding: 2rem;
  border: 1px solid $border;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12);
  max-width: 520px;
}

.error-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  color: #ef4444;
}

.retry-button {
  margin-top: 1.5rem;
  border: none;
  border-radius: 14px;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #1b64f2, #7b5bff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.tab-shell {
  max-width: 1400px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
}

.tab-panel {
  background: $surface;
  border-radius: 24px;
  padding: 1.5rem;
  border: 1px solid $border;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

@media (max-width: 768px) {
  .tab-shell {
    padding: 0 1rem;
  }

  .tab-panel {
    border-radius: 18px;
    padding: 1rem;
  }
}

// ============================================================================
// Facebook-style Chat Widget
// ============================================================================

.chat-widget-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 420px;
  height: 650px;
  max-height: calc(100vh - 120px);
  background: var(--bg-primary, #ffffff);
  border-radius: var(--radius-xl, 24px);
  box-shadow: var(--shadow-2xl, 0 30px 60px rgba(15, 23, 42, 0.25));
  border: 1px solid var(--color-gray-200, rgba(148, 163, 184, 0.4));
  display: flex;
  flex-direction: column;
  z-index: 10002;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;

  &.hidden {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
  }

  @media (max-height: 800px) {
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
  color: var(--text-inverse, #ffffff);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 1rem;
}

.chat-widget-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;

  svg {
    width: 20px;
    height: 20px;
  }
}

.chat-widget-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--text-inverse, #ffffff);
  color: var(--color-primary-dark, #1d4ed8);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.chat-widget-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-action-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  color: var(--text-inverse, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);

  svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.5;
  }

  &:hover:not(.disabled):not(:disabled) {
    transform: translateY(-1px) scale(1.05);
    background: rgba(255, 255, 255, 0.4);
  }

  &.disabled,
  &:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.15);
  }

  &.delete-btn {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.4);
  }
}

.chat-widget-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--text-inverse, #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
  }
}

.chat-widget-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;

  app-chat {
    flex: 1;
    display: flex;
    flex-direction: column;

    .chat-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      border: none;
      box-shadow: none;
      border-radius: 0;
    }

    .chat-sidebar,
    .chat-main {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    .conversation-list,
    .messages-container {
      flex: 1;
      min-height: 0;
      overflow-y: auto;
    }
  }
}
