:root {
  --primary-color: #007aff;
  --primary-dark: #005bb5;
  --background-color: #f7f9fc;
  --card-background: #ffffff;
  --text-color: #1d1d1f;
  --text-secondary: #6e6e73;
  --border-color: #d2d2d7;
  --user-message-bg: #007aff;
  --ai-message-bg: #e5e5ea;
  --font-family: 'Roboto', sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

.hidden {
    display: none !important;
}

/* --- Card & Container Styles --- */
.card {
  background-color: var(--card-background);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  padding: 32px;
  width: 100%;
}

#setup-container {
    max-width: 650px;
}

#chat-container {
    max-width: 800px;
    height: 90vh;
    max-height: 800px;
}

#chat-container .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.company-logo {
  display: block;
  margin: 0 auto 24px auto;
  width: 64px;
  height: 64px;
  color: var(--primary-color);
}

h1 {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 8px;
}

#setup-container p {
    text-align: center;
    margin-bottom: 32px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

#chat-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
}


/* --- Form Styles --- */
#setup-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.form-group, .select-group {
    display: flex;
    flex-direction: column;
}

.form-group label,
.select-group label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.form-group input,
.select-group select {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-size: 1rem;
  font-family: var(--font-family);
  background-color: #fcfcfc;
  transition: all 0.2s ease;
}

.form-group input:focus,
.select-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

#start-button {
    padding: 16px;
    border: none;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

#start-button:hover {
    background-color: var(--primary-dark);
}


/* --- Chat Window Styles --- */
#chat-window {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

#message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
  padding: 10px;
}

.message {
  padding: 12px 18px;
  border-radius: 20px;
  max-width: 75%;
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 1rem;
}

.user-message {
  background-color: var(--user-message-bg);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

.user-message img {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 8px;
}

.ai-message {
  background-color: var(--ai-message-bg);
  color: var(--text-color);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  position: relative;
  padding-right: 40px;
}

.ai-message.speaking {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.speak-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.speak-button:hover {
  background-color: rgba(0,0,0,0.1);
}

.ai-message strong {
  color: var(--primary-dark);
  font-weight: 600;
}

.ai-message ul {
  padding-left: 20px;
  margin: 8px 0;
}

.ai-message p {
  margin-bottom: 8px;
}

.ai-message p:last-child {
  margin-bottom: 0;
}

.system-message {
  font-style: italic;
  color: var(--text-secondary);
  text-align: center;
  align-self: center;
  background-color: transparent;
  width: 100%;
}


/* --- Message Form Styles --- */
#message-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

#message-input {
  flex-grow: 1;
  padding: 14px 20px;
  border-radius: 24px;
  border: 1px solid var(--border-color);
  font-size: 1rem;
  background-color: #fff;
  transition: all 0.2s ease;
}
#message-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}


#mic-button,
#send-button {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease-in-out;
}

#mic-button {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

#mic-button:hover:not(.listening) {
    background-color: var(--ai-message-bg);
}

#mic-button.listening {
    background-color: #ff453a;
    color: white;
    border-color: #ff453a;
    animation: pulse 1.5s infinite;
}

#send-button:hover:not(:disabled) {
  background-color: var(--primary-dark);
}

#send-button:disabled {
  background-color: #a3c9f7;
  cursor: not-allowed;
}

#send-button svg {
    margin-left: 2px;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 69, 58, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 69, 58, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 69, 58, 0);
    }
}

/* Attachment Styles */
#attachment-container {
    position: relative;
}

#attachment-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: white;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

#attachment-button:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

#attachment-menu {
    position: absolute;
    bottom: 110%;
    left: 0;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 150px;
}

#attachment-menu button {
    width: 100%;
    text-align: left;
    padding: 10px;
    border-radius: 6px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: 0.95rem;
}

#attachment-menu button:hover {
    background-color: var(--ai-message-bg);
}


/* Image Preview Styles */
#image-preview-container {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
    position: relative;
    width: fit-content;
}

#image-preview {
    max-width: 100px;
    max-height: 100px;
    border-radius: 6px;
}

#remove-image-button {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background-color: var(--text-color);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
}

/* Camera Modal Styles */
#camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#camera-container {
    position: relative;
    width: 90%;
    max-width: 600px;
    background-color: black;
    border-radius: 16px;
    overflow: hidden;
}

#camera-view {
    width: 100%;
    display: block;
}

#camera-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

#camera-controls button {
    padding: 12px 24px;
    border-radius: 24px;
    border: 1px solid white;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#camera-controls button:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

/* --- Typing Indicator --- */
#typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

#typing-indicator .loader {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-secondary);
  animation: bounce 1.4s infinite ease-in-out both;
}

#typing-indicator .loader:nth-child(2) {
  animation-delay: -0.16s;
}

#typing-indicator .loader:nth-child(3) {
  animation-delay: -0.32s;
}

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

/* --- Footer Styles --- */
footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#setup-container footer {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

footer p {
    margin: 0;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}


/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: stretch;
    }
    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        height: 100vh;
        max-height: none;
    }
    #setup-container.card {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    h1 {
        font-size: 2rem;
    }
}