:root {
  /* Core Palette: modern black + solar yellow accents */
  --bg: #0b0b0b;
  --surface: #121212;
  --card: #171717;
  --text-primary: #f5f5f5;
  --text-secondary: #b0b0b0;
  --border-color: #222222;
  --accent: #ffd400; /* Solar yellow */
  --accent-hover: #ffc107;
  --error: #ff4757;
  --success: #2ed573;

  /* Typography */
  --font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
    sans-serif;
  --font-size-base: 16px;

  /* Spacing */
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Border Radius */
  --border-radius: 10px;

  /* Shadow */
  --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* ============================================
   REGISTRATION FORM STYLES
   ============================================ */

.registration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: var(--spacing-md);
}

.registration-overlay.hidden {
  display: none;
}

.registration-modal {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.registration-header {
  padding: var(--spacing-lg);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--card) 0%, var(--surface) 100%);
  border-radius: 16px 16px 0 0;
}

.registration-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.registration-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.registration-form {
  padding: var(--spacing-lg);
}

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.form-group input.error {
  border-color: var(--error);
}

.form-group input.valid {
  border-color: var(--success);
}

.phone-input-group {
  display: flex;
  gap: 8px;
}

.phone-input-group .country-select {
  width: 130px;
  flex-shrink: 0;
}

.phone-input-group input {
  flex: 1;
}

.field-error {
  display: block;
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 4px;
  min-height: 18px;
}

.btn-register {
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #151515;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: var(--spacing-lg);
}

.btn-register:hover {
  background: var(--accent-hover);
}

.btn-register:active {
  transform: scale(0.98);
}

.btn-register:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-register .btn-loading {
  display: flex;
  align-items: center;
}

.btn-register .btn-loading.hidden {
  display: none;
}

.btn-register .btn-text.hidden {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

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

.form-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--spacing-md);
  opacity: 0.7;
}

/* Hide chat container initially */
.chat-container.hidden {
  display: none;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background:
    radial-gradient(1000px 600px at 10% 10%, #111 0%, var(--bg) 60%), var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
}

.chat-container {
  width: 100vw;
  height: 100vh;
  background: var(--surface);
  backdrop-filter: saturate(120%);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: var(--spacing-md);
  background: #000;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

.chat-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 12px;
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.user-info .user-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch-user-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.switch-user-btn:hover {
  background: rgba(255, 212, 0, 0.15);
  color: var(--accent);
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: var(--surface);
}

.welcome-message {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--spacing-lg) var(--spacing-md);
}

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

.message {
  max-width: 80%;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

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

.message.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

.message.system {
  background: #2a2a2a;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-style: italic;
  margin: 10px auto;
  max-width: 80%;
  text-align: center;
}

/* Message formatting */
.message a.phone-link,
.message a.email-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
}

.message a.phone-link:hover,
.message a.email-link:hover {
  border-bottom-style: solid;
}

.message.user a.phone-link,
.message.user a.email-link {
  color: #151515;
  border-bottom-color: #151515;
}

.message strong {
  font-weight: 600;
}

.message em {
  font-style: italic;
}

.message img {
  max-width: 100%;
  border-radius: var(--border-radius);
  margin-bottom: var(--spacing-sm);
}

.message .caption {
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--spacing-md);
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

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

.input-container {
  padding: var(--spacing-md);
  background: #0a0a0a;
  border-top: 1px solid var(--border-color);
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border-color);
  border-radius: 28px;
  padding: 6px 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 212, 0, 0.15);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-actions.left {
  padding-left: 4px;
}

.input-actions.right {
  padding-right: 4px;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: rgba(255, 212, 0, 0.1);
  color: var(--accent);
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn.active {
  background: var(--accent);
  color: #151515;
  animation: pulse 1.5s infinite;
}

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

.action-btn svg {
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  min-width: 0;
}

#messageInput::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #151515;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  margin-left: 2px;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 16px;
  width: 90%;
  max-width: 540px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--box-shadow);
}

.modal-header {
  padding: var(--spacing-md);
  background: #000;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-color);
}

.image-preview-container,
.camera-container {
  padding: var(--spacing-md);
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--surface);
}

#previewImage {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

#cameraVideo {
  width: 100%;
  max-height: 300px;
  border-radius: 8px;
  background: #000;
}

.caption-container {
  padding: 0 20px 20px;
}

#captionInput {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--card);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

#captionInput:focus {
  border-color: var(--primary-color);
}

.modal-actions {
  padding: var(--spacing-md);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  background: var(--primary-bg);
  border-top: 1px solid var(--border-color);
}

.btn-cancel,
.btn-send,
.btn-capture {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-cancel:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-send,
.btn-capture {
  background: var(--accent);
  border: none;
  color: #151515;
}

.btn-send:hover,
.btn-capture:hover {
  background: var(--accent-hover);
}

/* Scrollbar Styles */
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 0;
  }

  .chat-container {
    height: 100vh;
    border-radius: 0;
  }

  .message {
    max-width: 90%;
  }

  .input-wrapper {
    padding: 4px 6px;
    border-radius: 24px;
  }

  .action-btn {
    width: 36px;
    height: 36px;
  }

  .action-btn svg {
    width: 20px;
    height: 20px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  .send-btn svg {
    width: 18px;
    height: 18px;
  }

  #messageInput {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Registration responsive */
  .registration-modal {
    max-height: 95vh;
  }

  .registration-header {
    padding: var(--spacing-md);
  }

  .registration-header h2 {
    font-size: 1.25rem;
  }

  .registration-form {
    padding: var(--spacing-md);
  }

  .phone-input-group {
    flex-direction: column;
  }

  .phone-input-group .country-select {
    width: 100%;
  }

  /* Chat header responsive */
  .chat-header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .chat-header h1 {
    font-size: 1rem;
  }

  .header-right {
    gap: 8px;
  }

  .user-info {
    padding: 2px 4px 2px 8px;
  }

  .user-info .user-name {
    max-width: 80px;
    font-size: 0.8rem;
  }

  .clear-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}
