/*
 * asystent.css — Generator Stron AI
 * Jasny motyw, WCAG 2.2 AA
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* === ZMIENNE === */
:root {
  --font: 'Inter', sans-serif;

  /* Paleta jasna — spójna z home.css */
  --bg:         #ffffff;
  --surface:    #f9fafb;
  --border:     #e5e7eb;
  --border-mid: #d1d5db;

  --text:       #111827;   /* 17.7:1 */
  --text-sub:   #374151;   /* 10.0:1 */
  --text-muted: #6b7280;   /*  4.6:1 — tylko large text AA */

  --blue:       #1d4ed8;   /* primary 7:1 */
  --blue-h:     #1e40af;   /* hover */
  --blue-light: #eff6ff;

  --error:      #b91c1c;

  /* Dymki */
  --bubble-ai-bg:   #f3f4f6;
  --bubble-ai-text: #111827;
  --bubble-user-bg: #1d4ed8;
  --bubble-user-text: #ffffff;

  --focus-ring: #2563eb;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* === SKIP LINK === */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--blue);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
}
.skip-link:focus { left: 8px; }

/* === HEADER === */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}
.logo-word   { color: #374151; }
.logo-accent { color: #1d4ed8; }
.nav { display: flex; align-items: center; gap: 12px; }
.nav-link {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.nav-link:hover { background: var(--surface); }
.nav-cta {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
  padding: 8px 18px;
  border: 2px solid var(--blue);
  border-radius: 8px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}
.nav-cta:hover { background: var(--blue); color: #fff; }

/* === PAGE LAYOUT === */
.page-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === CHAT WRAPPER — 2/3 szerokości === */
.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: clamp(400px, 66.667%, 860px);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  overflow: hidden;
  min-height: 0;
}

/* Chat stage: column, full height */
#chat-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* === HISTORIA WIADOMOŚCI === */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  min-height: 0;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* === DYMKI === */
.msg {
  display: flex;
  gap: 10px;
  max-width: 82%;
  animation: msgIn 0.18s ease-out both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg--ai   { align-self: flex-start; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  margin-top: 3px;
}
.msg--ai  .msg-avatar { background: var(--blue); color: #fff; }
.msg--user .msg-avatar { background: var(--border); color: var(--text-sub); }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg--ai  .msg-bubble {
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border-top-left-radius: 4px;
  border: 1px solid var(--border);
}
.msg--user .msg-bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-top-right-radius: 4px;
}

/* === TYPING INDICATOR === */
.typing-indicator {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 80px;
}
.typing-indicator .msg-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* === INPUT AREA === */
.chat-input-area {
  padding: 14px 0 20px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.chat-input {
  display: block;
  width: 100%;
  resize: none;
  background: var(--bg);
  border: 1.5px solid var(--border-mid);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  min-height: 88px;   /* ~3 wiersze */
  max-height: 200px;
  overflow-y: auto;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* Przyciski pod textarea — wyśrodkowane */
.chat-input-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.btn-icon:active { transform: scale(0.94); }

.btn-send {
  background: var(--blue);
  color: #fff;
  border: 2px solid var(--blue);
}
.btn-send:hover:not(:disabled) { background: var(--blue-h); border-color: var(--blue-h); }
.btn-send:disabled {
  background: var(--border);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-mic {
  background: var(--bg);
  border: 1.5px solid var(--border-mid);
  color: var(--text-muted);
}
.btn-mic:hover { border-color: var(--blue); color: var(--blue); }
.btn-mic.recording {
  background: #fef2f2;
  border-color: #ef4444;
  color: #ef4444;
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.btn-mic.unsupported { display: none; }

.chat-input-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* === PRZYCISK ZAKOŃCZ === */
.btn-end-chat {
  display: block;
  margin: 10px auto 0;
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-end-chat:hover { border-color: var(--blue); color: var(--blue); }

/* === PANEL PODSUMOWANIA === */
.summary-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 24px 0;
  gap: 20px;
  overflow-y: auto;
}
.summary-panel.active { display: flex; }

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.summary-card h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 18px;
}
.summary-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 14px;
}
.summary-row:last-child { margin-bottom: 0; }
.summary-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-value {
  font-size: 0.9375rem;
  color: var(--text-sub);
  line-height: 1.5;
}
.summary-question {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
}

/* === MODAL EMAIL === */
.email-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.email-modal-overlay.active { display: flex; }
.email-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.email-modal h2 { font-size: 1.125rem; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.email-modal p  { font-size: 0.9rem; color: var(--text-muted); margin: 0 0 20px; line-height: 1.5; }
.email-modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border-mid);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  margin-bottom: 8px;
}
.email-modal-input::placeholder { color: var(--text-muted); }
.email-modal-input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(29,78,216,0.12); }
.email-modal-error { font-size: 0.8125rem; color: var(--error); min-height: 1.2em; margin-bottom: 16px; }
.email-modal-actions { display: flex; gap: 10px; }

/* === PANEL SUKCESU === */
.success-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 16px;
  height: 100%;
}
.success-panel.active { display: flex; }
.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--blue-light);
  border: 2px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-size: 1.75rem;
  flex-shrink: 0;
}
.success-panel h2 { font-size: 1.5rem; font-weight: 800; color: var(--text); margin: 0; }
.success-panel p  { font-size: 0.9375rem; color: var(--text-muted); max-width: 400px; line-height: 1.6; margin: 0; }
.success-link-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  width: 100%;
}
.success-link-url {
  flex: 1;
  font-size: 0.875rem;
  color: var(--blue);
  word-break: break-all;
  text-decoration: none;
}
.success-link-url:hover { text-decoration: underline; }
.btn-copy {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--border);
  border: none;
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-copy:hover { background: var(--blue); color: #fff; }

/* === PRZYCISKI GŁÓWNE === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--blue); color: #fff; border: 2px solid var(--blue); }
.btn--primary:hover:not(:disabled) { background: var(--blue-h); border-color: var(--blue-h); }
.btn--primary:disabled { background: var(--border); border-color: var(--border); color: var(--text-muted); cursor: not-allowed; }
.btn--secondary {
  background: var(--bg);
  color: var(--text-sub);
  border: 1.5px solid var(--border-mid);
}
.btn--secondary:hover { border-color: var(--blue); color: var(--blue); }

/* === SPINNER === */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === RESPONSYWNOŚĆ === */
@media (max-width: 640px) {
  .chat-wrapper {
    max-width: 100%;
    padding: 0 12px;
  }
  .msg { max-width: 90%; }
  .btn { width: 100%; }
  .email-modal-actions { flex-direction: column; }
  .success-link-box { flex-direction: column; align-items: stretch; }
  .btn-copy { width: 100%; }
  .header-inner { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
