body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #1e1e1e;
    color: #f1f1f1;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
}

#theme-toggle-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #f1f1f1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle-btn:hover {
    background: #3a3a3a;
}

/* --- Theme Icon Visibility --- */
#theme-toggle-btn #moon-icon {
    display: none;
}
#theme-toggle-btn #sun-icon {
    display: none;
}
body:not(.light-theme) #theme-toggle-btn #sun-icon {
    display: block;
}
body.light-theme #theme-toggle-btn #moon-icon {
    display: block;
}


.chat-body {
    padding: 0 1rem 12rem 1rem;
    flex-grow: 1;
    overflow-y: auto;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

#welcome-message {
    text-align: center;
    margin-top: 20vh;
    color: #f1f1f1;
}

#welcome-message h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.chat-message.bot .message-icon {
    color: #f1f1f1;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

.chat-message.bot .message-bubble {
    background-color: #2a2a2a;
    color: #f1f1f1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    max-width: 80%;
    line-height: 1.4;
    border: 1px solid #3a3a3a;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user .message-bubble {
    background-color: #2563eb;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    max-width: 80%;
    line-height: 1.4;
}

.chat-footer {
    padding: 1.5rem 1rem;
    background: linear-gradient(to top, #1e1e1e 60%, transparent 100%);
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

body.light-theme .chat-footer {
    background: linear-gradient(to top, #ffffff 60%, transparent 100%);
}

.footer-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 24px;
    padding: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.input-area:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #818cf8;
}

.input-area input[type="text"] {
    flex-grow: 1;
    border: none;
    outline: none;
    background-color: transparent;
    font-size: 1rem;
    padding: 0.25rem 0.25rem;
    color: #f1f1f1;
    margin: 0;
    min-width: 0;
}

.input-area input[type="text"]::placeholder {
    color: #888;
}

.input-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    visibility: visible;
}

.voice-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-area .icon-btn {
    background: #3a3a3a;
    border: 1px solid #555;
    color: #f1f1f1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

.input-area .icon-btn:hover {
    color: #fff;
    background-color: #4a4a4a;
}

#recording-status {
    display: none;
    align-items: center;
    padding: 0.5rem 0.5rem;
    color: #888;
    min-width: 0;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    border-radius: 50%;
    margin-right: 0.75rem;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    transform: scale(1);
    transition: transform 0.1s ease-out;
}

#recording-timer {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    color: #ef4444;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-message.bot.typing-indicator .message-bubble {
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #888;
    border-radius: 50%;
    animation: typing-pulse 1.4s infinite both;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

#send-btn {
    display: none;
    color: #fff;
    background-color: #2563eb;
    border-color: #2563eb;
}

/* --- Button Visibility Logic --- */

/* 1. Has Text (Not Recording) */
.input-area.has-text .action-buttons {
    visibility: hidden;
}
.input-area.has-text #live-voice-btn {
    display: none;
}
.input-area.has-text #send-btn {
    display: flex;
}

/* 2. Is Recording */
.input-area.is-recording input[type="text"] {
    display: none;
}
.input-area.is-recording #recording-status {
    display: flex;
}
.input-area.is-recording #speaker-btn,
.input-area.is-recording #live-voice-btn {
    display: none;
}
.input-area.is-recording #mic-btn {
    display: flex;
    color: #ef4444;
}
.input-area.is-recording #send-btn {
    display: none;
}
.input-area.is-recording .action-buttons {
    visibility: visible;
}


#voice-overlay {
  position: absolute;
  inset: 0;
  background: #1e1e1e;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 50;
  transition: opacity 0.3s ease, background-color 0.3s ease;
}

#voice-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#voice-animation {
  width: 180px;
  height: 180px;
  background: radial-gradient(circle at 50% 50%, #3b82f6 0%, #60a5fa 40%, rgba(96,165,250,0.15) 70%, transparent 100%);
  border-radius: 50%;
  transform: scale(0);
  opacity: 0;
  animation: none;
  transition: all 0.6s ease;
}

#voice-animation.active {
  transform: scale(1);
  opacity: 1;
  animation: pulseWave 5s ease-in-out infinite;
}

@keyframes pulseWave {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.close-voice {
  margin-top: 6rem;
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f1f1f1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.close-voice:hover {
  background-color: #3a3a3a;
  transform: scale(1.1);
}

#live-voice-btn.active {
  background-color: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

@keyframes typing-pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* ================== Light Theme ================== */
body.light-theme {
    background-color: #ffffff;
    color: #1f2937;
}

body.light-theme #welcome-message {
    color: #1f2937;
}

body.light-theme #theme-toggle-btn {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
}
body.light-theme #theme-toggle-btn:hover {
    background-color: #e5e7eb;
}

body.light-theme .chat-message.bot .message-icon {
    color: #1f2937;
}

body.light-theme .chat-message.bot .message-bubble {
    background-color: #f3f4f6;
    color: #1f2937;
    border-color: #e5e7eb;
}

body.light-theme .input-area {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

body.light-theme .input-area input[type="text"] {
    color: #1f2937;
}
body.light-theme .input-area input[type="text"]::placeholder {
    color: #6b7280;
}

body.light-theme .input-area .icon-btn {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #4b5563;
}
body.light-theme .input-area .icon-btn:hover {
    background-color: #e5e7eb;
    color: #1f2937;
}

body.light-theme #live-voice-btn.active,
body.light-theme #send-btn {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

body.light-theme #speaker-btn.tts-enabled {
    color: #2563eb;
}

body.light-theme #mic-btn.is-recording {
    color: #ef4444;
}

body.light-theme #voice-overlay {
    background: #ffffff;
}

body.light-theme .close-voice {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1f2937;
}
body.light-theme .close-voice:hover {
    background-color: #f3f4f6;
}

body.light-theme .typing-dot {
    background-color: #6b7280;
}