:root {
  --bg-body: #F4F5F7; /* Soft grey-white for better contrast */
  --bg-surface: #FFFFFF;
  --bg-card: #FAFAFA; /* Subtle contrast for inner cards */
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --accent-color: #111111;
  --gold-accent: #BDA06D;
  --border-light: #EAEAEA;
  
  --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.05);
  --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.02);
  
  --font-display: "Playfair Display", serif;
  --font-body: "Lato", sans-serif;
  
  --radius-xl: 32px;
  --radius-lg: 20px;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-body);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("https://images.pexels.com/photos/18541712/pexels-photo-18541712.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
  background-size: cover;
  background-position: center;
  filter: blur(8px);
  opacity: 0.4; /* Adjusted opacity for elegance */
  z-index: -1;
}


.container {
  width: 90%;
  max-width: 900px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 4rem 3rem;
  box-shadow: 
    0 20px 50px -12px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0,0,0,0.02); /* Border tint */
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 600px; /* Taller for grandeur */
  position: relative;
  transition: all 0.5s ease;
}

/* Controls Section */
.controls {
  display: flex;
  justify-content: space-between; /* Better distribution */
  align-items: flex-start; /* Align smoothly */
  width: 100%;
  max-width: 600px; /* Constrain width */
  margin: 0 auto 3rem auto; /* Center with margin bottom */
}

.language-select-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1; /* Take equal width */
}

.language-select-group label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

select {
  background: transparent;
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 1.5rem;
  cursor: pointer;
  appearance: none;
  text-align: center;
  transition: all 0.3s ease;
}

select:hover {
  background: var(--bg-card);
}

select:focus {
  outline: none;
  background: var(--bg-card);
  box-shadow: 0 0 0 2px var(--border-light);
}

.swap-btn {
  background: white;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-card);
  margin-top: 1.2rem; /* Align with inputs */
}

.swap-btn:hover {
  transform: rotate(180deg) scale(1.05);
  border-color: var(--gold-accent);
  color: var(--gold-accent);
}

/* Mic Section */
.interaction-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 2rem; /* Add spacing below mic area */
}

.mic-container {
  margin-bottom: 2rem;
  position: relative;
  height: 120px; /* Increased height to accommodate button and text */
  display: flex;
  flex-direction: column; /* Stack vertically */
  justify-content: center;
  align-items: center;
}

.mic-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: var(--accent-color);
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 15px 35px rgba(0,0,0,0.2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  z-index: 10;
  flex-shrink: 0; /* Prevent shrinking */
}

.mic-button:hover {
  transform: scale(1.1);
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

.mic-button.listening {
  background: #FFFFFF;
  color: #E63946;
  border: 2px solid #E63946;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.4); }
  70% { box-shadow: 0 0 0 20px rgba(230, 57, 70, 0); }
  100% { box-shadow: 0 0 0 0 rgba(230, 57, 70, 0); }
}

#statusText {
  position: static; /* Remove absolute positioning to prevent overlap */
  margin-top: 1.5rem; /* Space from button */
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  opacity: 0.7;
  height: 1.5em; /* Reserve height */
  text-align: center;
  max-width: 200px;
}

/* Results Area - The "Cards" */
.results-container {
  display: flex;
  flex-direction: row; /* Side by side */
  gap: 2rem;
  width: 100%;
  max-width: 850px; /* Wider to accommodate side-by-side */
  margin: 0 auto;
}

.conversation-box {
  flex: 1; /* Equal width */
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  min-height: 200px; /* Taller for better look in row */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.conversation-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  background: #FFFFFF;
}

.conversation-box .label {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  opacity: 0.6;
}

#transcription {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

#translation {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--text-primary);
  line-height: 1.4;
  font-weight: 500;
}

.audio-btn {
  position: absolute;
  bottom: 1rem;
  right: 1.5rem;
  background: rgba(0,0,0,0.03);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.audio-btn:hover:not(:disabled) {
  background: var(--accent-color);
  color: #fff;
}

.hidden {
  display: none;
}

/* Custom Select Styles merged */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 200px;
}

.custom-select {
  position: relative;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
  padding: 0.5rem;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.custom-select:hover {
  opacity: 0.7;
}

.custom-select::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--gold-accent);
  border-bottom: 2px solid var(--gold-accent);
  transform: rotate(45deg);
  margin-top: -4px;
  transition: transform 0.3s;
}

.custom-select.open::after {
  transform: rotate(-135deg);
  margin-top: 2px;
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 220px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 10px 15px -3px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 300px;
  overflow-y: auto;
}

.custom-select.open + .custom-options {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.custom-option {
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  text-align: left;
}

.custom-option:hover {
  background: var(--bg-body);
  color: var(--text-primary);
}

.custom-option.selected {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 700;
}

/* Scrollbar for options */
.custom-options::-webkit-scrollbar {
  width: 4px;
}
.custom-options::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .results-container {
    flex-direction: column;
  }
  
  .controls {
    flex-direction: row;
    gap: 1rem;
    align-items: center;
  }
  
  .container {
    padding: 2rem 1.5rem;
  }
}
