/* ============================================================
   Radiante v2 — Layout
   Reset, body, container, header, cards, grid
   ============================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Google Sans', 'Google Sans Text', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f7f9fc;
  color: var(--text-primary);
  min-height: 100vh;
  padding: 1rem 1.25rem 2rem;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.login-mode {
  padding: 0;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.brand-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  margin-top: 0.375rem;
}

.brand .tagline {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.brand .separator {
  color: var(--border-subtle);
}

.brand .subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
}

.actions-group {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.5rem;
}

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

.legacy-run-actions {
  display: none !important;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 1rem;
  align-items: start;
}

.results-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-card-wide {
  grid-column: auto;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: none;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.card:hover {
  border-color: rgba(11, 87, 208, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--accent);
  flex-shrink: 0;
}

.card-header-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0;
  line-height: 1.25;
}

.card-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.5;
}

.meta-highlight {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.875rem 1rem;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
}

.meta-item-hero .meta-label {
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.meta-item-hero .meta-value {
  font-size: 1.0625rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.875rem 1rem;
  margin-top: 0;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.meta-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.meta-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.status-text {
  font-size: 0.875rem;
  color: var(--info);
  font-weight: 500;
}

.app-status {
  grid-column: 1 / -1;
  min-height: 0;
  padding: 0;
  color: var(--accent-blue);
  overflow-wrap: anywhere;
}

.app-status:empty {
  display: none;
}

.download-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 1.25rem;
}

/* ============================================================
   Loading Overlay — Material3 Design
   ============================================================ */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlayFadeIn 0.25s ease;
}

.loading-ambient {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(26, 115, 232, 0.08), transparent 70%);
  animation: ambientDrift 6s ease-in-out infinite alternate;
  pointer-events: none;
}

.loading-card {
  position: relative;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem 1.75rem 1.75rem;
  animation: cardSlideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.loading-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.25rem;
}

.loading-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: #e8f0fe;
  color: #1a73e8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: iconPulse 2s ease-in-out infinite;
}

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

.loading-title {
  font-size: 1rem;
  font-weight: 500;
  color: #1f1f1f;
  line-height: 1.4;
}

.loading-subtitle {
  font-size: 0.8125rem;
  color: #5f6368;
  margin-top: 0.125rem;
}

.loading-timer-badge {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: #f8f9fa;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #444746;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.loading-timer-badge svg {
  color: #5f6368;
}

/* ============================================================
   M3 Timeline (dentro do loading card)
   ============================================================ */
.m3-timeline {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
}

.m3-step {
  display: flex;
  gap: 0.875rem;
  padding: 0.5rem 0;
  transition: opacity 0.3s ease;
}

.m3-step-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 28px;
  flex-shrink: 0;
}

.m3-step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #dadce0;
  background: #fff;
  flex-shrink: 0;
  z-index: 1;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
}

.m3-step-dot.is-active {
  border-color: #1a73e8;
  background: #1a73e8;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.16);
  animation: dotRipple 1.5s ease-in-out infinite;
}

.m3-step-dot.is-done {
  border-color: #188038;
  background: #188038;
}

.m3-step-dot.is-done::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 8px; height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.m3-step-dot.is-error {
  border-color: #d93025;
  background: #d93025;
}

.m3-step-dot.is-error::after {
  content: '!';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  line-height: 1;
}

.m3-step-line {
  width: 2px;
  flex: 1;
  min-height: 18px;
  background: #dadce0;
  transition: background 0.4s ease;
}

.m3-step-line.is-active {
  background: #1a73e8;
}

.m3-step-line.is-done {
  background: #188038;
}

.m3-step-body {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.125rem 0 0.5rem;
  min-height: 24px;
}

.m3-step-label {
  font-size: 0.875rem;
  color: #5f6368;
  font-weight: 400;
  transition: color 0.3s ease;
}

.m3-step.is-active .m3-step-label {
  color: #1f1f1f;
  font-weight: 500;
}

.m3-step.is-done .m3-step-label {
  color: #188038;
  font-weight: 500;
}

.m3-step.is-error .m3-step-label {
  color: #d93025;
}

.m3-step-badge {
  font-size: 0.6875rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 100px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.m3-step-badge.is-pending {
  background: #f1f3f4;
  color: #80868b;
}

.m3-step-badge.is-active {
  background: #e8f0fe;
  color: #1a73e8;
}

.m3-step-badge.is-done {
  background: #e6f4ea;
  color: #188038;
}

.m3-step-badge.is-error {
  background: #fce8e6;
  color: #d93025;
}

/* Sub-steps (rodadas da Etapa 3) */
.m3-substeps {
  padding-left: 38px;
  margin-bottom: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.m3-substep {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0;
  transition: opacity 0.3s ease;
}

.m3-substep-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #dadce0;
  background: #fff;
  flex-shrink: 0;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.m3-substep-dot.is-active {
  border-color: #1a73e8;
  background: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.16);
  animation: subDotPulse 1.2s ease-in-out infinite;
}

.m3-substep-dot.is-done {
  border-color: #188038;
  background: #188038;
}

.m3-substep-dot.is-error {
  border-color: #d93025;
  background: #d93025;
}

.m3-substep-label {
  font-size: 0.75rem;
  color: #80868b;
  transition: color 0.2s ease;
  flex: 1;
}

.m3-substep.is-active .m3-substep-label {
  color: #1f1f1f;
  font-weight: 500;
}

.m3-substep.is-done .m3-substep-label {
  color: #188038;
}

.m3-substep.is-error .m3-substep-label {
  color: #d93025;
}

.m3-substep-badge {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: 100px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.m3-substep-badge.is-pending {
  background: #f1f3f4;
  color: #80868b;
}

.m3-substep-badge.is-active {
  background: #e8f0fe;
  color: #1a73e8;
}

.m3-substep-badge.is-done {
  background: #e6f4ea;
  color: #188038;
}

.m3-substep-badge.is-error {
  background: #fce8e6;
  color: #d93025;
}

/* Animations */
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ambientDrift {
  0% { transform: translate(-30px, -30px) scale(1); }
  100% { transform: translate(30px, 30px) scale(1.2); }
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes dotRipple {
  0%, 100% { box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.16); }
  50% { box-shadow: 0 0 0 8px rgba(26, 115, 232, 0.08); }
}

@keyframes subDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modalFadeIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
