/* ============================================
   NexonTech Brand Palette
   ============================================ */
:root {
  --color-deep-blue:      #002B5B;
  --color-electric-blue:  #0075FF;
  --color-soft-blue-gray: #DDE6F0;
  --color-off-white:      #FAFAFA;
  --color-dark-gray:      #1E1E1E;
  --color-error:          #d32f2f;
  --color-success:        #2e7d32;
  --color-card-bg:        #ffffff;
  --color-border:         #c8d8eb;
  --color-input-border:   #c0cfe0;
  --color-btn-hover:      #003f80;
  --color-text-muted:     #666;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-dark-gray);
  background: var(--color-off-white);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  max-width: 520px;
  width: 100%;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  gap: 0.375rem;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.lang-btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  letter-spacing: 0.03em;
}

.lang-btn:hover {
  background: var(--color-soft-blue-gray);
  color: var(--color-deep-blue);
  border-color: var(--color-electric-blue);
}

.lang-btn.active {
  background: var(--color-electric-blue);
  color: #fff;
  border-color: var(--color-electric-blue);
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

.header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.header-logo img {
  height: 40px;
  width: auto;
  display: block;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--color-deep-blue);
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Form */
form {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input[type="url"],
input[type="text"],
textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-input-border);
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background: var(--color-card-bg);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-electric-blue);
}

input.invalid,
textarea.invalid {
  border-color: var(--color-error);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.error-msg {
  display: block;
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.25rem;
  min-height: 1.2em;
}

button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--color-deep-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

button[type="submit"]:hover {
  background: var(--color-btn-hover);
}

button[type="submit"]:disabled {
  background: #999;
  cursor: not-allowed;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Progress Section */
#progress-section {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2rem 1.5rem;
}

.progress-header {
  text-align: center;
  margin-bottom: 2rem;
}

.progress-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.progress-header p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  position: relative;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--color-soft-blue-gray);
  border-top-color: var(--color-deep-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.checkmark {
  width: 24px;
  height: 24px;
  color: var(--color-success);
  position: absolute;
  top: 0;
  left: 0;
}

.step-text {
  font-size: 0.9375rem;
  color: var(--color-dark-gray);
}

.step.done .step-text {
  color: #888;
}

/* Result Section */
.result-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.result-icon {
  margin-bottom: 1rem;
}

.result-icon svg {
  width: 48px;
  height: 48px;
}

.success-icon svg {
  color: var(--color-success);
}

.error-icon svg {
  color: var(--color-error);
}

.result-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-card p {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.retry-btn {
  padding: 0.625rem 1.5rem;
  background: var(--color-card-bg);
  color: var(--color-deep-blue);
  border: 1px solid var(--color-deep-blue);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.retry-btn:hover {
  background: var(--color-soft-blue-gray);
}

/* ============================================
   Chat Mode — Split Layout
   ============================================ */

.container.chat-mode {
  max-width: 1200px;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.container.chat-mode .lang-switcher {
  width: 100%;
  order: -1;
}

/* Left Panel — Config Info */
#chat-config {
  width: 360px;
  flex-shrink: 0;
}

.config-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
}

.config-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--color-deep-blue);
}

.config-field {
  margin-bottom: 1rem;
}

.config-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.config-field a {
  color: var(--color-electric-blue);
  font-size: 0.875rem;
  word-break: break-all;
}

.config-field p {
  font-size: 0.875rem;
  color: var(--color-dark-gray);
  line-height: 1.5;
}

.config-field code {
  font-size: 0.8rem;
  background: var(--color-soft-blue-gray);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  word-break: break-all;
}

.config-status {
  font-size: 0.875rem;
  color: var(--color-success);
  font-weight: 500;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.build-another-btn {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.6rem;
  background: var(--color-card-bg);
  color: var(--color-deep-blue);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.build-another-btn:hover {
  background: var(--color-soft-blue-gray);
}

/* Right Panel — Chat Interface */
#chat-panel {
  flex: 1;
  min-width: 300px;
}

.chat-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  height: 600px;
}

.chat-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: var(--color-success);
  border-radius: 50%;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
}

.chat-bubble a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.chat-bubble .md-list {
  margin: 0.375rem 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.chat-bubble .md-list li {
  margin-bottom: 0.375rem;
}

.chat-bubble .md-list li:last-child {
  margin-bottom: 0;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--color-soft-blue-gray);
  border-radius: 2px 8px 8px 8px;
  color: var(--color-dark-gray);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--color-deep-blue);
  color: #fff;
  border-radius: 8px 2px 8px 8px;
}

.chat-bubble.error {
  align-self: center;
  background: #fff5f5;
  border: 1px solid #ffcdd2;
  color: #c62828;
  border-radius: 8px;
  font-size: 0.8125rem;
  text-align: center;
}

/* Typing Indicator */
.typing-indicator {
  align-self: flex-start;
  background: var(--color-soft-blue-gray);
  border-radius: 2px 8px 8px 8px;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.3rem;
  animation: fadeIn 0.3s ease;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

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

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* Reply Buttons */
.chat-reply-buttons {
  padding: 0.5rem 1.25rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-reply-buttons:empty {
  display: none;
}

.reply-btn {
  padding: 0.45rem 1rem;
  background: var(--color-soft-blue-gray);
  color: var(--color-dark-gray);
  border: 1px solid var(--color-input-border);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.reply-btn:hover {
  background: #c4d4e8;
  border-color: var(--color-electric-blue);
}

/* Input Area */
.chat-input-area {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-input-border);
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-height: 48px;
}

#chat-input:focus {
  border-color: var(--color-electric-blue);
}

#chat-input:disabled {
  background: var(--color-soft-blue-gray);
  color: #999;
}

#chat-send-btn {
  width: 48px;
  height: 48px;
  background: var(--color-deep-blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

#chat-send-btn:hover:not(:disabled) {
  background: var(--color-btn-hover);
}

#chat-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Session ended message */
.chat-session-ended {
  padding: 0.75rem 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* Contact CTA Form (shown after session ends) */
.contact-cta {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-off-white);
  animation: fadeIn 0.4s ease;
}

.contact-cta-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-deep-blue);
  margin-bottom: 0.875rem;
}

.contact-cta .field {
  margin-bottom: 0.75rem;
}

.contact-cta label {
  font-size: 0.8rem;
  color: #555;
}

.contact-cta input,
.contact-cta textarea {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.contact-cta textarea {
  min-height: unset;
  resize: none;
}

.contact-cta-btn {
  width: 100%;
  padding: 0.6rem;
  background: var(--color-deep-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.contact-cta-btn:hover {
  background: var(--color-btn-hover);
}

.contact-cta-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

.contact-cta-success {
  font-size: 0.875rem;
  color: var(--color-success);
  font-weight: 500;
  text-align: center;
  padding: 0.5rem 0;
}

.contact-cta-error {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.375rem;
}

/* ============================================
   Responsive — Mobile (≤768px)
   ============================================ */

@media (max-width: 960px) {
  .container.chat-mode {
    flex-direction: column;
    max-width: 100%;
  }

  #chat-config {
    width: 100%;
  }

  #chat-panel {
    width: 100%;
  }

  .config-card {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    padding: 1rem 1.25rem;
    align-items: center;
  }

  .config-card h2 {
    margin-bottom: 0;
    font-size: 1.1rem;
    width: 100%;
  }

  .config-field {
    margin-bottom: 0;
  }

  .config-card .config-field:nth-child(3),
  .config-card .config-field:nth-child(4) {
    display: none;
  }

  .build-another-btn {
    margin-top: 0;
    width: auto;
    padding: 0.4rem 1rem;
  }

  .chat-card {
    height: calc(100vh - 200px);
    min-height: 400px;
  }
}
