/* ==========================================================================
   Components Styles - Dropdowns, Notifications, Command Palette, Toasts, Badges
   ========================================================================== */

/* ==========================================================================
   Dropdown Menus (Header Popovers)
   ========================================================================== */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  z-index: 100;
  width: 320px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* User Profile Menu */
.user-dropdown {
  width: 260px;
  padding: 0.5rem;
}

.user-dropdown-header {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.user-dropdown-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.user-dropdown-email {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 0.4rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

.dropdown-item.text-danger {
  color: var(--danger);
}

.dropdown-item.text-danger:hover {
  background-color: var(--danger-light);
  color: var(--danger);
}

.dropdown-item-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

/* Notifications Popover */
.notifications-dropdown {
  width: 380px;
  max-width: calc(100vw - 2rem);
}

.notifications-header {
  padding: 1rem 1.25rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.notifications-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.btn-text-action:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Notification Tabs */
.notifications-tabs {
  display: flex;
  padding: 0.5rem 1.25rem 0;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.notif-tab {
  background: none;
  border: none;
  padding: 0.4rem 0.2rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.notif-tab.active {
  color: var(--primary);
}

.notif-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary);
  border-radius: var(--radius-full);
}

.notifications-list {
  max-height: 360px;
  overflow-y: auto;
  list-style: none;
}

.notification-item {
  padding: 0.85rem 1.25rem;
  display: flex;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.15s ease;
  position: relative;
  cursor: pointer;
}

.notification-item:hover {
  background-color: var(--bg-surface-hover);
}

.notification-item.unread {
  background-color: var(--primary-light);
}

.notification-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notification-content {
  flex: 1;
}

.notification-text {
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.notification-text strong {
  color: var(--text-main);
  font-weight: 600;
}

.notification-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--primary);
  display: inline-block;
}

.notifications-footer {
  padding: 0.75rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-muted);
}

.notifications-footer a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

/* ==========================================================================
   Command Palette / Search Modal (⌘K)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 1rem 2rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.search-modal {
  width: 100%;
  max-width: 600px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(-20px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show .search-modal {
  transform: translateY(0) scale(1);
}

.search-modal-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.search-modal-icon {
  color: var(--text-muted);
}

.search-modal-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
}

.search-modal-input::placeholder {
  color: var(--text-muted);
}

.search-modal-close-btn {
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
}

.search-modal-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.75rem;
}

.search-category-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.35rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-result-item:hover,
.search-result-item.highlighted {
  background-color: var(--primary-light);
  color: var(--primary);
}

.search-result-item .item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.search-modal-footer {
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-muted);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-modal-footer .shortcuts {
  display: flex;
  gap: 0.85rem;
}

.search-modal-footer kbd {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.btn-soft {
  background-color: var(--primary-light);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background-color: var(--primary-200);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.85rem 1.65rem;
  font-size: 1rem;
}

/* Spinner inside button */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* ==========================================================================
   Toast Notifications System
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.2s ease;
}

.toast.toast-hiding {
  opacity: 0;
  transform: translateX(100%);
}

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

.toast-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error .toast-icon { color: var(--danger); }
.toast.toast-info .toast-icon { color: var(--info); }

.toast-body {
  flex: 1;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.toast-msg {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.15s ease;
}

.toast-close:hover {
  color: var(--text-main);
}
