/* BACKGROUND VIDEO */
.gv-bg-video {
  display: block;
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
  pointer-events: none;
  border: none;
  margin: 0;
  padding: 0;
}

.gv-bg-overlay {
  display: block;
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 5, 15, 0.72) 0%, rgba(2, 5, 15, 0.5) 40%, rgba(2, 5, 15, 0.55) 100%),
    radial-gradient(ellipse at 50% 50%, transparent 0%, rgba(2, 5, 15, 0.3) 80%);
}

body {
  background: transparent !important;
  overflow: hidden;
}

#giordano-app {
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
  background: transparent;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

/* TOP BAR */
.gv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(10, 14, 26, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-faint);
  z-index: 10;
}

.gv-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gv-brand-mark {
  width: 28px;
  height: 28px;
}

.gv-brand-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.2));
}

.gv-brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-primary);
}

.gv-top-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.gv-conn-status {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  border: none;
  padding: 0;
  transition: all 0.3s;
}

.gv-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-faint);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.gv-download:hover:not(:disabled) {
  color: var(--violet-bright);
  border-color: var(--border-subtle);
  background: rgba(139, 92, 246, 0.08);
}

.gv-download:disabled {
  opacity: 0.3;
  cursor: default;
}

.gv-download svg {
  width: 16px;
  height: 16px;
}

.gv-conn-status.connected {
  color: var(--green);
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.gv-conn-status.connecting {
  color: var(--amber);
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

.gv-conn-status.error {
  color: var(--red);
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.gv-back-link {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  transition: all 0.2s;
}

.gv-back-link:hover {
  color: var(--violet-bright);
  border-color: var(--border-bright);
  background: rgba(139, 92, 246, 0.08);
}

/* STAGE — two-column grid */
.gv-stage {
  display: grid;
  grid-template-columns: minmax(400px, 0.75fr) minmax(500px, 1.25fr);
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.gv-stage::before {
  display: none;
}

/* PANEL LEFT — GIORDANO */
.gv-panel-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
  contain: layout style;
  height: 100%;
  min-height: 0;
}

/* PANEL RIGHT — RESPONSE */
.gv-panel-right {
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(5, 8, 18, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
}

.gv-panel-right::-webkit-scrollbar {
  width: 6px;
}

.gv-panel-right::-webkit-scrollbar-track {
  background: transparent;
}

.gv-panel-right::-webkit-scrollbar-thumb {
  background: var(--border-faint);
  border-radius: 3px;
}

.gv-panel-right::-webkit-scrollbar-thumb:hover {
  background: var(--border-subtle);
}

/* EMPTY STATE */
.gv-right-empty {
  margin: auto;
  font-size: 14px;
  color: var(--text-dim);
  opacity: 0.5;
  text-align: center;
}

.gv-right-empty.hidden {
  display: none;
}

.gv-panel-right:has(.gv-response-entry) .gv-right-empty {
  display: none;
}

/* AVATAR */
.gv-avatar-wrap {
  position: relative;
  width: 440px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-obsidian);
  box-shadow: 0 0 0 1px var(--border-faint), 0 8px 40px rgba(0,0,0,0.6);
  transition: box-shadow 0.4s;
}

.gv-avatar-ring {
  display: none;
}

.gv-avatar-ring-2 {
  display: none;
}

.gv-avatar-wrap.listening {
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3), 0 0 30px rgba(239, 68, 68, 0.15), 0 8px 40px rgba(0,0,0,0.6);
}

.gv-avatar-wrap.processing {
  box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.3), 0 0 30px rgba(245, 166, 35, 0.12), 0 8px 40px rgba(0,0,0,0.6);
}

.gv-avatar-wrap.responding {
  box-shadow: 0 0 0 1px rgba(23, 232, 154, 0.3), 0 0 30px rgba(23, 232, 154, 0.12), 0 8px 40px rgba(0,0,0,0.6);
}

.gv-avatar-wrap.consulting {
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.3), 0 0 30px rgba(139, 92, 246, 0.12), 0 8px 40px rgba(0,0,0,0.6);
}

@keyframes gv-ring-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes gv-ring-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#gv-video {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
  object-position: center 15%;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.5s;
  transform: scale(1.3);
  transform-origin: center 20%;
}

#gv-video.active {
  opacity: 1;
}

.gv-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  background: var(--bg-obsidian);
}

.gv-avatar-placeholder.hidden {
  display: none;
}

.gv-placeholder-svg {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.15));
}

.gv-placeholder-svg circle:nth-child(1) {
  animation: gv-rotate 20s linear infinite;
  transform-origin: 30px 30px;
}

.gv-placeholder-svg circle:nth-child(2) {
  animation: gv-rotate 15s linear infinite reverse;
  transform-origin: 30px 30px;
}

.gv-placeholder-svg circle:nth-child(3) {
  animation: gv-rotate 10s linear infinite;
  transform-origin: 30px 30px;
}

@keyframes gv-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* STATE */
.gv-state-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  z-index: 1;
}

.gv-state-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  transition: all 0.3s;
}

.gv-state-indicator.listening {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: gv-blink 1s ease-in-out infinite;
}

.gv-state-indicator.processing {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
  animation: gv-blink 1.5s ease-in-out infinite;
}

.gv-state-indicator.responding {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.gv-state-indicator.consulting {
  background: var(--violet);
  box-shadow: 0 0 8px var(--violet);
  animation: gv-blink 2s ease-in-out infinite;
}

@keyframes gv-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.gv-state-text {
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  transition: color 0.3s;
}

.gv-state-text.listening { color: var(--red); }
.gv-state-text.processing { color: var(--amber); }
.gv-state-text.responding { color: var(--cyan); }
.gv-state-text.consulting { color: var(--violet-bright); }

/* SUBTITLE */
.gv-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
  z-index: 1;
  transition: opacity 0.3s;
}

.gv-subtitle.hidden {
  opacity: 0;
}

/* VOICE CONTROLS */
.gv-voice-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
  z-index: 1;
}

.gv-mic {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.1);
  border: 2px solid rgba(139, 92, 246, 0.3);
  color: var(--violet-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 1;
  flex-shrink: 0;
}

.gv-mic:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.6);
  transform: scale(1.05);
}

.gv-mic:active {
  transform: scale(0.95);
}

.gv-mic:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.gv-mic.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.7);
  color: var(--red);
  animation: gv-mic-pulse 1.5s ease-in-out infinite;
}

.gv-mic.speaking {
  background: rgba(23, 232, 154, 0.12);
  border-color: rgba(23, 232, 154, 0.5);
  color: var(--green);
}

@keyframes gv-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
}

.gv-mic-icon {
  width: 28px;
  height: 28px;
}

.gv-mic-stop {
  width: 24px;
  height: 24px;
  display: none;
}

.gv-mic.recording .gv-mic-icon { display: none; }
.gv-mic.recording .gv-mic-stop { display: block; }
.gv-mic.speaking .gv-mic-icon { display: none; }
.gv-mic.speaking .gv-mic-stop { display: block; }

.gv-voice-stop {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(239, 68, 68, 0.55);
  border-radius: 10px;
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
  transition: all 0.2s;
  flex-shrink: 0;
}

.gv-voice-stop:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.16);
  transform: translateY(-1px);
}

.gv-voice-stop:active:not(:disabled) {
  transform: scale(0.96);
}

.gv-voice-stop:disabled {
  opacity: 0.25;
  cursor: default;
  filter: saturate(0.3);
}

.gv-voice-stop svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

/* TRANSCRIPT */
.gv-transcript {
  display: none !important;
}

/* HISTORY */
.gv-history {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 1;
}

.gv-response-entry {
  width: 100%;
  animation: gv-fade-in 0.4s ease;
}

.gv-response-text {
  width: 100%;
  padding: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  text-align: left;
}

@keyframes gv-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.gv-response-text::before {
  content: 'RESPUESTA';
  display: block;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  color: var(--violet-bright);
  margin-bottom: 12px;
}

.gv-response-text h1,
.gv-response-text h2,
.gv-response-text h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 16px 0 8px 0;
  letter-spacing: 0.02em;
}

.gv-response-text h1:first-child,
.gv-response-text h2:first-child,
.gv-response-text h3:first-child {
  margin-top: 0;
}

.gv-response-text p {
  margin: 8px 0;
}

.gv-response-text ul,
.gv-response-text ol {
  margin: 8px 0;
  padding-left: 24px;
}

.gv-response-text ul { list-style: disc; }
.gv-response-text ol { list-style: decimal; }

.gv-response-text li {
  margin: 4px 0;
  color: var(--text-secondary);
}

.gv-response-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.gv-response-text em {
  color: var(--text-secondary);
}

.gv-response-text a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(21, 217, 255, 0.2);
}

.gv-response-text a:hover {
  border-bottom-color: var(--cyan);
}

.gv-response-text code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(139, 92, 246, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--violet-bright);
}

.gv-response-text pre {
  background: var(--bg-graphite);
  border: 1px solid var(--border-faint);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  margin: 12px 0;
}

.gv-response-text pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
}

.gv-response-text blockquote {
  border-left: 2px solid var(--violet);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-muted);
}

.gv-response-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}

.gv-response-text th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.gv-response-text td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-faint);
  color: var(--text-muted);
}

.gv-response-text tr:last-child td {
  border-bottom: none;
}

.gv-response-text hr {
  border: none;
  border-top: 1px solid var(--border-faint);
  margin: 16px 0;
}

.gv-error {
  color: var(--red);
  font-size: 14px;
}

/* SOURCES */
.gv-sources {
  width: 100%;
  margin-top: 20px;
  z-index: 1;
  display: none;
}

.gv-sources.visible {
  display: block;
}

.gv-sources-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 8px;
}

.gv-sources-header::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
}

.gv-source-item {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.gv-source-item:last-child {
  border-bottom: none;
}

.gv-source-doc {
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gv-source-page {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* LINKS — Accesos útiles */
.gv-links {
  width: 100%;
  margin-top: 16px;
  z-index: 1;
  display: none;
}

.gv-links.visible {
  display: block;
}

.gv-links-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 8px;
}

.gv-links-header::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 4px var(--cyan);
}

.gv-link-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin: 4px 6px 4px 0;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid var(--border-faint);
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  cursor: pointer;
}

.gv-link-item:hover {
  background: rgba(139, 92, 246, 0.14);
  border-color: var(--purple);
  color: var(--text-primary);
}

.gv-link-arrow {
  font-size: 11px;
  color: var(--cyan);
  opacity: 0.7;
}

/* FALLBACK INPUT */
.gv-fallback {
  display: none;
  gap: 8px;
  margin-top: 16px;
  max-width: 380px;
  width: 100%;
  z-index: 1;
}

.gv-fallback.visible {
  display: flex;
}

.gv-fallback-input {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-sans);
}

.gv-fallback-input:focus {
  border-color: var(--border-bright);
}

.gv-fallback-input::placeholder {
  color: var(--text-dim);
}

.gv-fallback-send {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--violet-bright);
  background: rgba(139, 92, 246, 0.08);
  transition: all 0.2s;
  flex-shrink: 0;
}

.gv-fallback-send:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--border-bright);
}

.gv-fallback-send svg {
  width: 16px;
  height: 16px;
}

/* TEXT TOGGLE */
.gv-text-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  border: 1px solid var(--border-faint);
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1;
  flex-shrink: 0;
}

.gv-text-toggle:hover {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.gv-text-toggle.active {
  color: var(--violet-bright);
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.08);
}

.gv-text-toggle svg {
  width: 18px;
  height: 18px;
}

/* HUD — hidden, kept for debug only */
.gv-hud {
  display: none;
}

.gv-hud-left, .gv-hud-center, .gv-hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gv-hud-label {
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.gv-hud-value {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* RESPONSIVE */
@media (max-width: 1024px) {
  .gv-stage {
    grid-template-columns: minmax(340px, 0.8fr) minmax(420px, 1.2fr);
  }
}

@media (max-width: 768px) {
  .gv-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
  }

  .gv-panel-left {
    padding: 16px 16px 8px;
    overflow: visible;
  }

  .gv-panel-right {
    border-left: none;
    border-top: 1px solid var(--border-faint);
    padding: 16px;
    overflow-y: visible;
  }

  .gv-avatar-wrap {
    width: 320px;
    height: 280px;
  }

  #gv-video {
    transform: scale(1.35);
  }
}

@media (max-width: 480px) {
  .gv-avatar-wrap {
    width: 260px;
    height: 220px;
  }

  #gv-video {
    transform: scale(1.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gv-bg-video {
    display: none;
  }
  .gv-bg-overlay {
    background-image: url('/static/media/giordano/fondo.png');
    background-size: cover;
    background-position: center center;
    z-index: 0;
  }
}
