/**
 * Copyright 2026 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

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

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-hover: #22222e;
  --border: #2a2a3a;
  --text: #e4e4ed;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --green: #00d68f;
  --green-bg: rgba(0, 214, 143, 0.1);
  --green-border: rgba(0, 214, 143, 0.25);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.1);
  --red-border: rgba(255, 107, 107, 0.25);
  --yellow: #feca57;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

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

.badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.badge-checking {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.badge-ready {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.badge-unavailable {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Error Banner ── */
.error-banner {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 16px;
  flex-shrink: 0;
}

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 8px;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.welcome-message h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.welcome-message p {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 400px;
  line-height: 1.6;
}

.example-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.example-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.example-icon {
  font-size: 16px;
}

/* ── Chat Bubbles ── */
.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.55;
  animation: fadeIn 0.2s ease;
}

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

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-system {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-safe {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  color: var(--green);
}

.msg-blocked {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
}

.msg-analyzing {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.msg-icon {
  margin-right: 6px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ── Chat Form ── */
.chat-form {
  flex-shrink: 0;
  padding: 16px 0 20px;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 6px 6px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  padding: 6px 0;
}

textarea::placeholder {
  color: var(--text-dim);
}

#send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

#send-btn:hover {
  filter: brightness(1.15);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.form-footer {
  min-height: 20px;
  margin-top: 6px;
}

.status-text {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--accent);
  color: #fff;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

.info-box {
  background: rgba(254, 202, 87, 0.1);
  border: 1px solid rgba(254, 202, 87, 0.25);
  color: var(--yellow);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin: 16px 0;
  line-height: 1.5;
}

.modal-ok-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}

.modal-ok-btn:hover {
  filter: brightness(1.15);
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}

/* ── Scrollbar ── */
.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Detection List (modal) ── */
.detection-list {
  margin: 16px 0;
}

.detection-list h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detection-list ul {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.detection-list li {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .header-left {
    flex-direction: column;
    gap: 2px;
  }

  .example-cards {
    flex-direction: column;
  }
}
