/**
 * HRZ OPS - Components
 * Reusable UI components (buttons, cards, badges, etc)
 * Version: 2.0
 */

/* ===== HEALTH ALERT BANNER ===== */
.health-banner {
  position: sticky;
  top: 0;
  z-index: 999;
  width: 100%;
  background: linear-gradient(90deg, #dc2626 0%, #b91c1c 100%);
  color: white;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border-bottom: 2px solid #991b1b;
  animation: healthBannerSlide 0.3s ease-out;
}
.health-banner.warning {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
  border-bottom-color: #b45309;
}
.health-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
.health-banner-icon {
  font-size: 18px;
  animation: healthBannerPulse 1.5s ease-in-out infinite;
}
.health-banner-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}
.health-banner-link {
  color: white;
  text-decoration: underline;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.health-banner-link:hover {
  text-decoration: none;
}
.health-banner-close {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: white;
  font-size: 18px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.health-banner-close:hover {
  background: rgba(255,255,255,0.2);
}
@keyframes healthBannerSlide {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes healthBannerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}


/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Variants */
.btn-primary {
  background: var(--emerald);
  color: #000;
  border-color: var(--emerald);
}

.btn-primary:hover:not(:disabled) {
  background: var(--emerald-hover);
  border-color: var(--emerald-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

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

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

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

[data-theme="light"] .btn-ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.03);
}

.btn-danger {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.btn-danger:hover:not(:disabled) {
  background: var(--rose-hover);
  border-color: var(--rose-hover);
}

/* Button Sizes */
.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

.btn-md {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: var(--font-size-base);
}

/* ===== CARDS ===== */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .card {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .card:hover {
  box-shadow: var(--shadow-md);
  background: var(--bg-secondary);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Glass Card Variant */
.glass-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

[data-theme="light"] .glass-card {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald);
}

.badge-info {
  background: rgba(56, 189, 248, 0.15);
  color: var(--sky);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
}

.badge-error {
  background: rgba(251, 113, 133, 0.15);
  color: var(--rose);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  transition: all var(--transition-fast);
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  border-color: var(--emerald);
  background: var(--bg-secondary);
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Input Group */
.input-group {
  margin-bottom: var(--space-4);
}

.input-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.input-help {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* ===== SELECT ===== */
.select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select:hover {
  border-color: var(--border-strong);
}

.select:focus {
  border-color: var(--emerald);
}

/* ===== CHECKBOX & RADIO ===== */
.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.checkbox input[type="checkbox"],
.radio input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ===== TABLES ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table thead {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ===== ALERTS ===== */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 3px solid;
  display: flex;
  align-items: start;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
}

.alert-success {
  background: rgba(52, 211, 153, 0.1);
  border-color: var(--emerald);
  color: var(--emerald);
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--sky);
  color: var(--sky);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: var(--amber);
  color: var(--amber);
}

.alert-error {
  background: rgba(251, 113, 133, 0.1);
  border-color: var(--rose);
  color: var(--rose);
}

/* ===== TOOLTIPS ===== */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-md);
  white-space: nowrap;
  z-index: var(--z-dropdown);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border-subtle);
  margin: 0 var(--space-4);
}

/* ===== AVATAR ===== */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 24px; height: 24px; font-size: var(--font-size-xs); }
.avatar-md { width: 32px; height: 32px; font-size: var(--font-size-sm); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--font-size-base); }

/* ===== SKELETON LOADER ===== */
.skeleton {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  to { left: 100%; }
}

.skeleton-text {
  height: 12px;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* ===== ACCORDION ===== */
@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.shimmer-bg {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(to right, var(--bg-tertiary) 4%, var(--border-default) 25%, var(--bg-tertiary) 36%);
  background-size: 1000px 100%;
}

.cmrc-hover-lift {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}
.cmrc-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.cmrc-accordion-content {
  display: none;
}
.cmrc-accordion-content.expanded {
  display: block;
}

/* ===== CELEBRATION FEED — "Conquistas da Equipe" (Wave 25 — 1 card/gestor) =====
 * 1 card por gestor com lista cronológica CRESCENTE de vídeos (1º feito → último).
 * Substitui o feed flat regressivo. Tokens semânticos, contraste AA, touch ≥44px.
 */
.cfg-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cfg-group {
  border: 1px solid var(--border-default, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  background: var(--bg-tertiary, rgba(255, 255, 255, 0.02));
  overflow: hidden;
}

.cfg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.cfg-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.cfg-header-text {
  flex: 1;
  min-width: 0;
}

.cfg-gestor-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #f0f0f8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-gestor-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary, rgba(240, 240, 248, 0.7));
  margin-top: 2px;
}

.cfg-video-icon {
  flex: 0 0 auto;
  color: var(--amber, #fbbf24);
}

.cfg-video-list {
  list-style: none;
  margin: 0;
  padding: 4px 6px 6px;
  display: flex;
  flex-direction: column;
}

.cfg-video-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
}

.cfg-video-item:last-child {
  border-bottom: none;
}

.cfg-video-seq {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary, rgba(240, 240, 248, 0.7));
  background: var(--bg-elevated, rgba(255, 255, 255, 0.06));
}

.cfg-video-client {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #f0f0f8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-video-meta {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary, rgba(240, 240, 248, 0.7));
  white-space: nowrap;
}

.cfg-video-go {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -12px -8px -12px 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-tertiary, rgba(240, 240, 248, 0.4));
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.cfg-video-go:hover,
.cfg-video-go:focus-visible {
  color: var(--sky, #38bdf8);
  background: var(--info-bg, rgba(56, 189, 248, 0.1));
}

.cfg-video-go:focus-visible {
  outline: 2px solid var(--sky, #38bdf8);
  outline-offset: 1px;
}

.cfg-loading,
.cfg-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-tertiary, rgba(240, 240, 248, 0.4));
  font-size: 12px;
}

.cfg-empty svg {
  opacity: 0.45;
  margin-bottom: 6px;
}

.cfg-empty-title {
  color: var(--text-secondary, rgba(240, 240, 248, 0.7));
  font-weight: 600;
}

.cfg-empty-sub {
  font-size: 11px;
  margin-top: 2px;
}

/* Telas estreitas: meta quebra pra baixo do cliente pra não espremer */
@media (max-width: 420px) {
  .cfg-video-item {
    flex-wrap: wrap;
  }
  .cfg-video-client {
    flex: 1 1 100%;
    order: 1;
  }
  .cfg-video-seq {
    order: 0;
  }
  .cfg-video-meta {
    order: 2;
    margin-left: 28px;
  }
  .cfg-video-go {
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cfg-video-go {
    transition: none;
  }
}
