:root {
  --brand-primary: #1a56db;
  --brand-secondary: #1e429f;
  --brand-accent: #3f83f8;

  --surface-primary: #ffffff;
  --surface-secondary: #f9fafb;
  --surface-tertiary: #f3f4f6;

  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-light: #ffffff;

  --status-success: #059669;
  --status-warning: #d97706;
  --status-error: #dc2626;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  --border-radius: 0.5rem;
  --max-width: 48rem;

  --transition-base: 200ms ease-in-out;
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--surface-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

header {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-md);
  width: 100%;
}

header h1 {
  color: var(--text-light);
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  max-width: 100%;
  margin: 0;
}

.sophia-highlight {
  font-weight: 700;
  background: linear-gradient(120deg, #fff, #e0f2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.timer {
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  color: var(--text-primary);
  padding: 0.4rem 1.2rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base);
  margin: 0 auto 1rem auto;
  display: none; /* Começa escondido */
  align-items: center;
}

#timer-time {
  font-weight: 700;
  margin-left: 0.5rem;
}

.timer.warning {
  color: #92400e;
  background: #fef3c7;
  border-color: #fcd34d;
}

.timer.danger {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fca5a5;
  animation: pulse 1s infinite;
}

/* Video Container */
#video-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  width: 100%;
  margin: 0 auto 1.5rem;
  overflow: hidden;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius);
}

#start-interview-button {
  width: 100%;
  max-width: 20rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface-primary);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  overflow: hidden;
}

#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message {
  max-width: 85%;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bot-message {
  background: var(--surface-tertiary);
  border-left: 3px solid var(--brand-primary);
  margin-right: auto;
}

.user-message {
  background: var(--brand-primary);
  color: var(--text-light);
  margin-left: auto;
}

/* Formulários e input-group */
#user-input-form {
  display: flex;
  padding: 0.75rem;
  background: var(--surface-primary);
  border-top: 1px solid var(--surface-tertiary);
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.input-group {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
}

#user-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface-tertiary);
  border-radius: var(--border-radius);
  font-size: 1rem;
  color: var(--text-primary);
  transition: border-color var(--transition-base);
  box-sizing: border-box;
  min-width: 0;
}

#user-input:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px rgba(63, 131, 248, 0.1);
}

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

button {
  padding: 0.75rem 1rem;
  margin-left: 0.5rem;
  background: var(--brand-primary);
  color: var(--text-light);
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-base), transform var(--transition-base);
  box-sizing: border-box;
  white-space: nowrap;
}

button:hover {
  background: var(--brand-secondary);
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
}

/* Botão mic na input-group */
#mic-btn {
  padding: 0.2rem;
  margin: 0 .3rem;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background .22s;
}

#mic-btn.recording {
  background: var(--brand-accent, #3f83f8);
  border-radius: 50%;
}

#mic-btn img {
  filter: grayscale(40%);
  transition: filter 0.2s;
}

#mic-btn.recording img {
  filter: grayscale(0%) drop-shadow(0 0 6px #2f7efb);
}

/* Formulário de upload de currículo */
#resume-upload-form {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  background: var(--surface-primary);
  border-top: 1px solid var(--surface-tertiary);
  width: 100%;
  box-sizing: border-box;
}

#resume-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface-tertiary);
  border-radius: var(--border-radius);
  font-size: 1rem;
  color: var(--text-primary);
  transition: border-color var(--transition-base);
  box-sizing: border-box;
  margin-bottom: 0.5rem;
  background-color: var(--surface-secondary);
}

#resume-upload-form button {
  width: 100%;
  margin-left: 0;
  box-sizing: border-box;
}

footer {
  background: var(--surface-primary);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  width: 100%;
  overflow-x: hidden;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.footer-cta {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.footer-cta .sophia-highlight {
  color: var(--brand-primary);
  background: none;
  -webkit-text-fill-color: initial;
}

footer a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-base);
}

footer a:hover {
  color: var(--brand-secondary);
  text-decoration: underline;
}

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

#chat-messages::-webkit-scrollbar {
  width: 0.375rem;
}

#chat-messages::-webkit-scrollbar-track {
  background: var(--surface-secondary);
}

#chat-messages::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 0.375rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  padding: 0;
  margin: -1px;
}

/* Responsividade */
@media (min-width: 768px) {
  header h1 { font-size: 1.75rem; }
  #resume-upload-form { flex-direction: row; align-items: center; }
  #resume-input { flex: 1; margin-bottom: 0; margin-right: 0.5rem; }
  #resume-upload-form button { width: auto; }
}

@media (max-width: 400px) {
  header h1 { font-size: 1.25rem; }
  .timer { font-size: 0.8rem; padding: 0.4rem 0.9rem; }
  .message { max-width: 90%; padding: 0.625rem 0.875rem; font-size: 0.875rem; }
  #user-input-form, #resume-upload-form { padding: 0.5rem; }
  #user-input, #resume-input { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
  button { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
}

@media (max-width: 768px) and (orientation: landscape) {
  #resume-upload-form { flex-direction: row; align-items: center; }
  #resume-input { flex: 1; margin-bottom: 0; margin-right: 0.5rem; max-width: calc(100% - 170px); }
  #resume-upload-form button { width: auto; min-width: 150px; }
}

button {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message, h1, p {
  overflow-wrap: break-word;
  word-wrap: break-word;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
}

/* Indicador "Digitando..." */
.typing-indicator {
  display: flex;
  align-items: center;
}
.typing-indicator span {
  height: 8px;
  width: 8px;
  background-color: var(--text-tertiary);
  border-radius: 50%;
  display: inline-block;
  margin: 0 2px;
  animation: typing-bounce 1.4s infinite both;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Player de Áudio Customizado */
.user-message .audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  border-radius: calc(var(--border-radius) - 4px);
}

.audio-player button.play-pause-btn {
  background: var(--surface-primary);
  color: var(--brand-secondary);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.audio-player button.play-pause-btn svg {
  width: 20px;
  height: 20px;
}

.audio-player .progress-bar-container {
  flex-grow: 1;
  background-color: rgba(255, 255, 255, 0.3);
  height: 5px;
  border-radius: 5px;
  cursor: pointer;
  overflow: hidden;
}

.audio-player .progress-bar {
  background-color: var(--surface-primary);
  width: 0%;
  height: 100%;
  border-radius: 5px;
}

/* ---- NOVOS ESTILOS PARA GRAVAÇÃO DE VÍDEO ---- */

#video-recording-container {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--surface-secondary);
  border-top: 1px solid var(--surface-tertiary);
}

.video-question {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    margin: 0;
}

.video-preview-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#video-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Efeito espelho */
}

.video-timer-display {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-light);
    padding: 0.25rem 0.6rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 0.9rem;
}

.video-instructions {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 400px;
    margin: 0;
}

.video-controls {
    display: flex;
    gap: 1rem;
}

.danger-button {
    background-color: var(--status-error);
}
.danger-button:hover {
    background-color: #b91c1c;
}
