$primary-blue: #1b64f2;
$primary-blue-dark: #154ecc;
$text-dark: #0f172a;
$text-muted: #65738b;
$border-color: #e2e8f0;
$surface: #ffffff;
$danger: #e53935;
$bg-highlight: #f1f5ff;
$shadow: 0 10px 30px rgba(15, 23, 42, 0.08);

:host {
  display: block;
  background: linear-gradient(135deg, #f4f7fb 0%, #ffffff 60%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: $shadow;
}

.dashboard-header {
  background: transparent;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;

  @media (max-width: 1024px) {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem;
  }
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;

  .medical-icon {
    width: 48px;
    height: 48px;
    color: $primary-blue;
  }

  .dashboard-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: $text-dark;
  }

  .dashboard-subtitle {
    margin: 0.125rem 0 0;
    color: $text-muted;
    font-size: 0.95rem;
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification-container {
  position: relative;
}

.notification-button {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid $border-color;
  background: $surface;
  color: $text-dark;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;

  &:hover {
    border-color: $primary-blue;
    color: $primary-blue;
    box-shadow: 0 10px 20px rgba(27, 100, 242, 0.15);
  }

  &.has-notifications {
    border-color: $primary-blue;
    color: $primary-blue;
  }

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

.notification-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: $danger;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 360px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12);
  padding: 1rem;
  z-index: 20;

  @media (max-width: 480px) {
    width: 300px;
    right: -40px;
  }
}

.notification-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;

  h3 {
    margin: 0;
    font-size: 1.1rem;
    color: $text-dark;
  }

  .subtitle {
    margin: 0.2rem 0 0;
    color: $text-muted;
    font-size: 0.85rem;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  button {
    background: transparent;
    border: none;
    color: $primary-blue;
    font-weight: 600;
    cursor: pointer;
    padding: 0.15rem 0.25rem;

    &:hover {
      text-decoration: underline;
    }
  }

  .delete-all {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid $border-color;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;

    &:hover {
      border-color: $danger;
      color: $danger;
    }

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

.notification-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notification-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid $border-color;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    border-color: $primary-blue;
    background: $bg-highlight;
  }

  &.unread {
    border-color: $primary-blue;
    box-shadow: 0 10px 30px rgba(27, 100, 242, 0.08);
  }
}

.notification-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(27, 100, 242, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: $primary-blue;

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

.notification-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  .notification-title {
    font-weight: 600;
    color: $text-dark;
  }

  .notification-message {
    font-size: 0.85rem;
    color: $text-muted;
  }

  .notification-time {
    font-size: 0.78rem;
    color: rgba(15, 23, 42, 0.6);
  }
}

.notification-delete {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(226, 232, 240, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    border-color: $danger;
    color: $danger;
    background: rgba(229, 57, 53, 0.1);
  }

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

.no-notifications {
  text-align: center;
  color: $text-muted;
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

.refresh-button,
.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 12px;
  border: 1px solid $border-color;
  background: $surface;
  color: $text-dark;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;

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

  &:hover:not(:disabled) {
    border-color: $primary-blue;
    color: $primary-blue;
    box-shadow: 0 10px 20px rgba(27, 100, 242, 0.1);
  }

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

.logout-button {
  border-color: rgba(229, 57, 53, 0.4);
  color: $danger;

  &:hover:not(:disabled) {
    box-shadow: 0 10px 20px rgba(229, 57, 53, 0.15);
  }
}

// ============================================================================
// Chat Menu + Blocked Users Styles
// ============================================================================

.chat-menu-container {
  position: relative;
  z-index: 20;
}

.chat-menu-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid $border-color;
  background: $surface;
  color: $text-muted;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm, 0 10px 20px rgba(15, 23, 42, 0.08));

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

  &:hover {
    border-color: $primary-blue;
    color: $primary-blue;
    transform: translateY(-2px);
  }

  &.active {
    background: linear-gradient(135deg, var(--color-primary, #2563eb) 0%, var(--color-accent, #8b5cf6) 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
  }

  &.has-unread {
    animation: pulse-chat 2s infinite;
  }
}

@keyframes pulse-chat {
  0%, 100% {
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.15);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.15);
  }
}

.chat-menu-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border: 2px solid #fff;
}

.chat-menu-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 22px;
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.2s ease-out;
  z-index: 25;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);

  h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: $text-dark;
  }
}

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

.chat-menu-close,
.chat-menu-blocked-users {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: rgba(15, 23, 42, 0.05);
  color: $text-muted;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: rgba(15, 23, 42, 0.1);
    color: $text-dark;
  }
}

.chat-menu-blocked-users {
  &:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
  }
}

.chat-menu-search {
  padding: 1rem 1.5rem 0.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.search-input-container {
  position: relative;
  display: flex;
  align-items: center;
  background: #f7f8fc;
  border-radius: 14px;
  padding: 0 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);

  .search-icon {
    width: 18px;
    height: 18px;
    color: $text-muted;
  }

  .search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem;
    outline: none;
    font-size: 0.95rem;
    color: $text-dark;
  }

  .search-clear {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    background: rgba(148, 163, 184, 0.2);
    color: $text-muted;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;

    &:hover {
      background: rgba(148, 163, 184, 0.35);
      color: $text-dark;
    }
  }
}

.conversation-list-dropdown {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-results-section {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(37, 99, 235, 0.04);

  .search-results-header {
    font-weight: 600;
    color: $text-dark;
    margin-bottom: 0.75rem;
  }
}

.conversations-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.conversation-item-dropdown {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  gap: 0.75rem;

  &:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.2);
  }

  &.active {
    border-color: var(--color-primary, #2563eb);
    background: rgba(37, 99, 235, 0.12);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.15);
  }
}

.conversation-avatar-dropdown {
  position: relative;
  flex-shrink: 0;

  .avatar-image,
  .avatar-circle-dropdown {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.15);
  }

  .avatar-circle-dropdown {
    background: linear-gradient(135deg, var(--color-primary, #2563eb), var(--color-accent, #8b5cf6));
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
  }

  .online-indicator-dropdown {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;

    &.online {
      background: #22c55e;
    }
    &.offline {
      background: #94a3b8;
    }
    &.busy {
      background: #f97316;
    }
  }
}

.conversation-info-dropdown {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  .conversation-name-dropdown {
    font-weight: 600;
    color: $text-dark;
  }

  .conversation-preview-dropdown {
    font-size: 0.85rem;
    color: $text-muted;
  }
}

.conversation-meta-dropdown {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: $text-muted;

  .conversation-unread-dropdown {
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: $primary-blue;
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
  }
}

.no-conversations {
  text-align: center;
  padding: 1.5rem 1rem;
  color: $text-muted;

  .subtext {
    margin-top: 0.25rem;
    font-size: 0.85rem;
  }
}

.blocked-users-container {
  position: relative;
  z-index: 20;
}

.blocked-users-button-header {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid $border-color;
  background: $surface;
  color: $text-muted;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    border-color: $danger;
    color: $danger;
    transform: translateY(-2px);
  }

  &.active {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    border-color: transparent;
  }
}

.blocked-users-panel-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.2s ease-out;
}

.blocked-users-header-dropdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.05) 100%);

  h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: $text-dark;
  }

  .close-blocked-users {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: none;
    background: rgba(15, 23, 42, 0.05);
    color: $text-muted;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: rgba(15, 23, 42, 0.1);
      color: $text-dark;
    }
  }
}

.blocked-users-content-dropdown {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
}

.blocked-loading {
  padding: 2rem 1rem;
  text-align: center;
  color: $text-muted;
  font-weight: 600;
}

.blocked-users-list-dropdown {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.blocked-user-item-dropdown {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #fff;
  box-shadow: 0 15px 30px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;

  &:hover {
    border-color: rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
  }
}

.blocked-user-avatar-dropdown {
  position: relative;

  .avatar-image,
  .avatar-circle-dropdown {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
  }

  .avatar-circle-dropdown {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
  }
}

.blocked-user-info-dropdown {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;

  .blocked-user-name-dropdown {
    font-weight: 600;
    color: $text-dark;
  }

  .blocked-user-details-dropdown {
    font-size: 0.85rem;
    color: $text-muted;
  }
}

.unblock-button-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  border: none;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: rgba(239, 68, 68, 0.25);
  }
}

.no-blocked-users-dropdown {
  text-align: center;
  padding: 2rem 1rem;
  color: $text-muted;

  span {
    display: block;
    font-size: 0.85rem;
    margin-top: 0.25rem;
  }
}

