/* ============================================
   EDITOR HEADER - PROFESSIONAL SUITE
   ============================================ */

:root {
  /* Tokens específicos do header */
  --header-height: 64px;
  --header-bg: var(--surface-0);
  --header-border: var(--surface-200);
  --header-shadow: 
    0 1px 0 rgba(0, 0, 0, 0.02),
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.03);
  
  --transition-header: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */

.editor-header {
  height: var(--header-height);
  background: linear-gradient(
    180deg,
    var(--surface-0) 0%,
    var(--surface-50) 100%
  );
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  
  position: relative;
  z-index: 30;
  
  /* Previne quebra de layout */
  flex-shrink: 0;
  min-width: 0;
}

/* ============================================
   LADO ESQUERDO - INFO DO PROJETO
   ============================================ */

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0; /* Para ellipsis funcionar */
  flex: 1;
}

/* Logo/Ícone do projeto */
.project-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius-lg);
  color: white;
  font-size: 1.25rem;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  flex-shrink: 0;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0; /* Para ellipsis */
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Título editável */
.page-title-text {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all var(--transition-header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.page-title-text:hover {
  background: var(--surface-100);
  border-color: var(--surface-200);
}

.page-title-text:focus {
  outline: none;
  background: var(--surface-0);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

/* Ícone de edição sutil */
.page-title-text::after {
  content: '\f303'; /* FontAwesome pencil */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  opacity: 0;
  color: var(--text-muted);
  transition: opacity var(--transition-header);
}

.page-title-text:hover::after {
  opacity: 1;
}

/* Gradiente premium no título */
.text-gradient {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 50%, #ec4899 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Metadados do projeto */
.project-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.meta-divider {
  width: 4px;
  height: 4px;
  background: var(--surface-300);
  border-radius: 50%;
}

/* Badge de status com pulse */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background: var(--surface-100);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition-header);
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.5;
}

.status-badge.active {
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 20%, transparent);
}

.status-badge.active::before {
  background: var(--success);
  opacity: 1;
  animation: status-pulse 2s ease infinite;
}

@keyframes status-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

.status-badge.unsaved {
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 20%, transparent);
}

.status-badge.unsaved::before {
  background: var(--warning);
  opacity: 1;
}

/* ============================================
   CENTRO - CONTROLES DE ZOOM
   ============================================ */

.editor-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  
  background: var(--surface-100);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-full);
  padding: 0.25rem;
  
  box-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  
  font-size: 0.875rem;
  cursor: pointer;
  
  transition: all var(--transition-header);
  will-change: transform, background-color;
}

.zoom-btn:hover {
  background: var(--surface-0);
  color: var(--text-primary);
  border-color: var(--surface-300);
  transform: scale(1.05);
}

.zoom-btn:active {
  transform: scale(0.95);
  transition-duration: 50ms;
}

.zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.zoom-level {
  min-width: 70px;
  padding: 0 0.5rem;
  
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: center;
  
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-header);
}

.zoom-level:hover {
  background: var(--surface-200);
}

/* Dropdown de zoom */
.zoom-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  
  background: var(--surface-0);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  
  padding: 0.5rem;
  min-width: 140px;
  
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-header);
  z-index: 1000;
}

.zoom-controls:hover .zoom-dropdown,
.zoom-dropdown:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.zoom-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-header);
}

.zoom-option:hover {
  background: var(--surface-100);
}

.zoom-option.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
}

.zoom-option kbd {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface-100);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

/* ============================================
   LADO DIREITO - AÇÕES
   ============================================ */

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: flex-end;
}

/* Grupos de ações */
.header-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  position: relative;
}

.header-actions-group:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 1px;
  background: var(--surface-200);
}

/* ============================================
   BOTÕES UNIVERSAIS
   ============================================ */

/* Botão ícone base */
.btn-icon {
  --btn-size: 36px;
  
  width: var(--btn-size);
  height: var(--btn-size);
  
  display: inline-flex;
  align-items: center;
  justify-content: center;
  
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  
  font-size: 1rem;
  cursor: pointer;
  position: relative;
  
  transition: all var(--transition-header);
  will-change: transform, background-color;
}

.btn-icon:hover {
  background: var(--surface-100);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-icon:active {
  transform: translateY(0);
  transition-duration: 50ms;
}

.btn-icon:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Variantes de tamanho */
.btn-icon.sm {
  --btn-size: 32px;
  font-size: 0.875rem;
}

.btn-icon.lg {
  --btn-size: 40px;
  font-size: 1.125rem;
}

/* Estado ativo/pressionado */
.btn-icon.active {
  background: var(--primary);
  color: white;
  border-color: color-mix(in srgb, var(--primary) 80%, black);
}

.btn-icon.active:hover {
  background: color-mix(in srgb, var(--primary) 90%, black);
}

/* Badge de notificação */
.btn-icon.has-badge::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--surface-0);
  box-shadow: 0 0 0 1px var(--error);
  animation: badge-pulse 2s ease infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* ============================================
   BOTÕES COM TEXTO
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  
  cursor: pointer;
  position: relative;
  overflow: hidden;
  
  transition: all var(--transition-header);
  will-change: transform, box-shadow;
}

/* Efeito de ripple sutil */
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.5s ease;
}

.btn:active::before {
  opacity: 1;
  transform: scale(2);
  transition: 0s;
}

/* Variante secundária */
.btn-secondary {
  background: var(--surface-0);
  border-color: var(--surface-200);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: var(--surface-50);
  border-color: var(--surface-300);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.btn-secondary:active {
  transform: translateY(0);
  background: var(--surface-100);
}

/* Variante primária */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
  color: white;
  border-color: transparent;
  box-shadow: 
    0 1px 2px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  transform: translateY(-1px);
  box-shadow: 
    0 4px 12px rgba(2, 132, 199, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.2);
}

/* Variante ghost (para ações secundárias) */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-100);
  color: var(--text-primary);
}

/* Tamanhos */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ============================================
   DROPDOWNS PROFISSIONAIS
   ============================================ */

.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-toggle::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  transition: transform var(--transition-header);
}

.dropdown.open .dropdown-toggle::after {
  transform: rotate(180deg);
}

/* Menu dropdown */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  
  background: var(--surface-0);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  
  box-shadow: 
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(0, 0, 0, 0.02);
  
  min-width: 220px;
  padding: 0.5rem;
  
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  
  transition: all var(--transition-header);
  z-index: 1000;
}

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

/* Itens do menu */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  
  cursor: pointer;
  transition: all var(--transition-header);
}

.dropdown-item:hover {
  background: var(--surface-100);
}

.dropdown-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* Ícones nos itens */
.dropdown-item i,
.dropdown-item .icon {
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.dropdown-item:hover i,
.dropdown-item:hover .icon {
  color: var(--primary);
}

/* Atalhos de teclado */
.dropdown-item kbd {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface-100);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-200);
}

/* Estado danger/destrutivo */
.dropdown-item.danger {
  color: var(--error);
}

.dropdown-item.danger i,
.dropdown-item.danger .icon {
  color: var(--error);
}

.dropdown-item.danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

/* Separadores */
.dropdown-divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--surface-200),
    transparent
  );
  margin: 0.5rem;
}

/* Header do dropdown */
.dropdown-header {
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE & ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .editor-header *,
  .btn,
  .btn-icon,
  .dropdown-menu,
  .zoom-dropdown {
    transition: none !important;
    animation: none !important;
  }
}

/* Compact mode para telas menores */
@media (max-width: 1024px) {
  .editor-header {
    padding: 0 1rem;
  }
  
  .page-title-text {
    max-width: 200px;
  }
  
  .header-actions-group:not(:last-child)::after {
    display: none;
  }
}

/* ============================================
   UTILITÁRIOS
   ============================================ */

/* Estado de loading nos botões */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btn-spinner 0.6s linear infinite;
  color: inherit;
}

@keyframes btn-spinner {
  to { transform: rotate(360deg); }
}

/* Tooltip simples para botões */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  
  padding: 0.375rem 0.75rem;
  background: var(--surface-900);
  color: var(--surface-0);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-md);
  
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-header);
  z-index: 10000;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}