/**
 * Global Header Styles
 * Consistent header styling across all pages
 */

#globalHeader {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  min-height: 52px;
}

.gh-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* Logo */
.gh-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.gh-logo-img {
  height: 32px;
  width: auto;
  display: block;
}

/* Right section */
.gh-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Profile Switcher */
.gh-profile-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.gh-profile-switcher:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.gh-profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc9435 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.gh-profile-name {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Profile Dropdown */
.gh-profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 220px;
  padding: 8px;
  display: none;
  z-index: 1001;
}

.gh-profile-dropdown.show {
  display: block;
}

.gh-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  color: #374151;
}

.gh-dropdown-item:hover {
  background: #f3f4f6;
}

.gh-dropdown-item.active {
  background: #eff6ff;
  color: #1d4ed8;
}

.gh-dropdown-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc9435 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.gh-dropdown-name {
  flex: 1;
}

.gh-dropdown-check {
  color: #22c55e;
  font-weight: 600;
}

.gh-dropdown-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.gh-dropdown-icon {
  width: 32px;
  display: flex;
  justify-content: center;
}

.gh-dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 8px 0;
}

/* Profile Loading States */
.gh-dropdown-item.loading {
  pointer-events: none;
  opacity: 0.7;
}

.gh-dropdown-item.loading .gh-dropdown-avatar {
  animation: pulse 1s ease-in-out infinite;
}

.gh-profile-switcher.loading {
  pointer-events: none;
}

.gh-profile-switcher.loading .gh-profile-name {
  color: #9ca3af;
}

.gh-profile-switcher.loading .gh-profile-avatar {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.gh-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #dc9435;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Navigation Links */
.gh-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s;
}

.gh-nav-link svg {
  flex-shrink: 0;
  overflow: visible;
}

.gh-nav-link:hover {
  background: #f3f4f6;
  color: #1f2937;
}

/* Account Info */
.gh-account-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-left: 1px solid #e5e7eb;
  cursor: pointer;
  position: relative;
  border-radius: 8px;
  transition: background 0.2s;
}

.gh-account-wrapper:hover {
  background: #f9fafb;
}

.gh-account {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.gh-account-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.gh-account-type {
  font-size: 12px;
  color: #6b7280;
}

.gh-account-chevron {
  color: #9ca3af;
  transition: transform 0.2s;
}

.gh-account-wrapper:hover .gh-account-chevron {
  color: #6b7280;
}

/* Account Dropdown */
.gh-account-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  padding: 8px;
  display: none;
  z-index: 1001;
}

.gh-account-dropdown.show {
  display: block;
}

.gh-account-dropdown .gh-dropdown-item {
  text-decoration: none;
}

.gh-account-dropdown .gh-dropdown-item svg {
  flex-shrink: 0;
}

.gh-dropdown-logout {
  width: 100%;
  background: none;
  border: none;
  color: #dc2626;
}

.gh-dropdown-logout:hover {
  background: #fef2f2 !important;
}

/* Logout Button (legacy - can be removed) */
.gh-logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.gh-logout-btn:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* Login Button */
.gh-login-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #dc9435 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.gh-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Modal Styles */
.gh-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.gh-modal {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.gh-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.gh-modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: #1f2937;
}

.gh-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}

.gh-modal-close:hover {
  color: #6b7280;
}

.gh-form-group {
  margin-bottom: 16px;
}

.gh-form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: #374151;
}

.gh-form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.gh-form-group input:focus {
  outline: none;
  border-color: #dc9435;
}

.gh-optional {
  font-weight: 400;
  color: #6b7280;
}

.gh-modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.gh-btn-primary {
  flex: 1;
  padding: 12px;
  background: #dc9435;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.gh-btn-primary:hover {
  background: #c17f2a;
}

.gh-btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.gh-btn-secondary {
  flex: 1;
  padding: 12px;
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.gh-btn-secondary:hover {
  background: #e5e7eb;
}

.gh-btn-link {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

.gh-btn-link:hover {
  color: #374151;
}

.gh-btn-danger-sm {
  padding: 6px 12px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.gh-btn-danger-sm:hover {
  background: #fecaca;
}

/* Manage Profiles List */
.gh-manage-list {
  max-height: 300px;
  overflow-y: auto;
}

.gh-manage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #f3f4f6;
}

.gh-manage-item:last-child {
  border-bottom: none;
}

/* Skeleton Loader */
.gh-skeleton-loader {
  width: 180px;
  height: 28px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: gh-shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes gh-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Quick Generate Mode - Clean style matching normal profile switcher */
.gh-profile-avatar.gh-quick-mode {
  background: #6b7280;
}

.gh-profile-switcher.gh-quick-mode .gh-profile-name {
  font-weight: 500;
}

.gh-quick-generate-option {
  flex-wrap: wrap;
}

.gh-quick-generate-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
}

.gh-quick-generate-text .gh-dropdown-name {
  font-weight: 500;
}

.gh-quick-warning {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 400;
}

.gh-quick-generate-option.active {
  background: #f3f4f6;
  color: #374151;
}

.gh-quick-generate-option.active .gh-quick-warning {
  color: #c1535e;
}

/* Profile Selection Modal (on login) */
.gh-profile-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gh-profile-select-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.gh-profile-select-btn:hover {
  background: #f3f4f6;
  border-color: #dc9435;
  transform: translateY(-1px);
}

.gh-profile-select-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc9435 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

.gh-profile-select-name {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.gh-quick-generate-btn {
  background: #fffbf5;
  border-color: #f5d5a8;
}

.gh-quick-generate-btn:hover {
  background: #ffefda;
  border-color: #dc9435;
}

/* Hamburger Menu Button */
.gh-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  gap: 5px;
  padding: 8px;
  transition: all 0.2s;
}

.gh-hamburger:hover {
  background: #f3f4f6;
}

.gh-hamburger-line {
  width: 20px;
  height: 2px;
  background: #374151;
  border-radius: 2px;
  transition: all 0.3s;
}

.gh-hamburger.active .gh-hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.gh-hamburger.active .gh-hamburger-line:nth-child(2) {
  opacity: 0;
}

.gh-hamburger.active .gh-hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Menu Overlay */
.gh-mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.gh-mobile-menu.show {
  opacity: 1;
  visibility: visible;
}

.gh-mobile-menu-content {
  position: absolute;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  transition: right 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.gh-mobile-menu.show .gh-mobile-menu-content {
  right: 0;
}

.gh-mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.gh-mobile-menu-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  color: #6b7280;
}

.gh-mobile-menu-close:hover {
  background: #e5e7eb;
}

.gh-mobile-nav {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gh-mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #374151;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.2s;
}

.gh-mobile-nav-link:hover {
  background: #f3f4f6;
}

.gh-mobile-nav-link.active {
  background: #eff6ff;
  color: #1d4ed8;
}

.gh-mobile-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 8px 0;
}

.gh-mobile-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 4px;
}

.gh-mobile-profile-section {
  padding: 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  margin-top: auto;
}

.gh-mobile-profile-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.gh-mobile-profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc9435 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

.gh-mobile-profile-info {
  flex: 1;
  min-width: 0;
}

.gh-mobile-profile-name {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gh-mobile-profile-label {
  font-size: 12px;
  color: #6b7280;
}

.gh-mobile-logout {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: #fef2f2;
  color: #dc2626;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gh-mobile-logout:hover {
  background: #fee2e2;
}

/* Responsive Breakpoints */

/* Large tablets / small laptops - hide nav text, shrink profile name */
@media (max-width: 1100px) {
  .gh-profile-name {
    max-width: 80px;
  }
  
  .gh-account-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Medium screens - hide nav text, shrink names */
@media (max-width: 900px) {
  .gh-nav-link span {
    display: none;
  }
  
  .gh-nav-link {
    padding: 8px 10px;
  }
  
  .gh-account-name {
    max-width: 80px;
  }
  
  .gh-profile-name {
    max-width: 60px;
  }
  
  .gh-right {
    gap: 8px;
  }
}

@media (max-width: 768px) {
  #globalHeader {
    padding: 10px 16px;
  }

  .gh-logo-img {
    height: 28px;
  }

  /* Hide desktop navigation */
  .gh-right .gh-nav-link,
  .gh-right .gh-profile-switcher,
  .gh-right .gh-account-wrapper {
    display: none;
  }

  /* Show hamburger */
  .gh-hamburger {
    display: flex;
  }

  /* Show mobile menu structure */
  .gh-mobile-menu {
    display: block;
  }
}

/* ── Help Button ───────────────────────────────────── */
.gh-help-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  cursor: pointer;
  color: #6b7280;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.gh-help-btn:hover {
  background: #fff7f2;
  border-color: #dc9435;
  color: #dc9435;
}

@media (max-width: 768px) {
  .gh-help-btn.gh-help-desktop {
    display: none;
  }
}

@media (max-width: 480px) {
  #globalHeader {
    padding: 8px 12px;
  }
  
  .gh-logo-img {
    height: 24px;
  }
  
  .gh-hamburger {
    width: 36px;
    height: 36px;
  }
  
  .gh-mobile-menu-content {
    width: 100%;
    right: -100%;
  }
}
