/* aiavm chatbot — açık bej tema, aimevzuat layout pattern
   feedback_design: bej/beyaz, siyah zemin yasak
   feedback_copy_tone: emoji + pazarlama kelimesi yok
*/

*,*:before,*:after { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

:root {
  --bg:         #faf8fd;   /* çok hafif lavender-cream */
  --bg-alt:     #f1ebfa;   /* yumuşak mor-pastel */
  --surface:    #ffffff;
  --border:     #e6dff2;   /* mor-gri */
  --text:       #1d1830;   /* derin lacivert-mor */
  --text-soft:  #5b5374;
  --text-muted: #8d8499;
  --text-dim:   #5b5374;
  --accent:     #7c3aed;   /* violet-600 — ana mor */
  --accent-fg:  #ffffff;
  --accent-soft:#ede9fe;   /* violet-100 — hover/focus arka */
  --accent-strong: #6d28d9; /* violet-700 — vurgu yazı, hover */
  --user-bg:    #ede9fe;   /* user bubble: violet-100 */
  --user-text:  #1d1830;
  --user-border:#c4b5fd;   /* violet-300 */
  --bot-bg:     #ffffff;
  --bot-text:   #1d1830;
  --radius-sm:  6px;
  --radius:     12px;
  --radius-md:  12px;
  --radius-lg:  14px;
  --radius-pill: 999px;
  --safe-top:   env(safe-area-inset-top);
  --safe-bot:   env(safe-area-inset-bottom);
}

/* Sadece chat sayfası fixed-viewport. Diğer sayfalar normal scroll.
   --vvh: visualViewport.height (chat.js setVVH ile günceller).
   iOS Safari klavye açılınca window.innerHeight değişmiyor, ama
   visualViewport.height küçülüyor → header viewport içinde sabit kalır. */
body.chat-app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: var(--vvh, 100dvh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* HEADER */
.header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: rgba(250,248,243,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  gap: 12px;
}
.header-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 8px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
  flex-shrink: 0;
}
.brand-text {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@media (max-width: 380px) { .brand-text { display: none; } }
.brand-sub {
  font-size: 13px;
  color: var(--text-soft);
}
@media (max-width: 560px) { .brand-sub { display: none; } }

.menu-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.menu-btn:hover  { background: var(--bg-alt); }
.menu-btn:active { transform: scale(0.96); }

.new-chat {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.new-chat:hover { background: var(--bg-alt); border-color: var(--text-soft); }

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.login-btn:hover { background: var(--bg-alt); border-color: var(--text-soft); }

/* SEPET — header sağ üst (tüm sayfalarda paylaşılan) */
.shop-cart-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  background: var(--surface);
}
.shop-cart-link:hover { background: var(--bg-alt); }
.shop-cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}

/* USER MENU + DROPDOWN */
.user-menu { position: relative; cursor: pointer; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.user-dropdown {
  display: none;
  position: absolute;
  top: 44px;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  min-width: 240px;
  padding: 6px;
  z-index: 1000;
}
.user-dropdown .ud-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-dropdown .ud-name  { font-weight: 600; font-size: 13px; color: var(--text); }
.user-dropdown .ud-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown a {
  display: block;
  padding: 9px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
}
.user-dropdown a:hover { background: var(--bg-alt); }
.user-dropdown .ud-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* DRAWER */
.hist-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  z-index: 999;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.hist-overlay.open { display: block; }
.hist-drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  max-width: 90vw;
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: left .25s ease;
}
.hist-drawer.open { left: 0; }
.hist-head {
  padding: calc(14px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hist-head h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.hist-close {
  background: none;
  border: 0;
  color: var(--text-soft);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.hist-list  { flex: 1; overflow-y: auto; padding: 8px; }
.hist-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.hist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.hist-item:hover,
.hist-item.active { background: var(--bg-alt); }
.hist-item-body  { flex: 1; min-width: 0; }
.hist-item-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-item-date  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.hist-item-del {
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .15s;
}
.hist-item:hover .hist-item-del { opacity: 1; }
.hist-item-del:hover { background: var(--border); color: var(--text); }

.hist-foot {
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(14px + var(--safe-bot));
}
.hist-foot h4 {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  font-weight: 600;
}
.hist-foot a {
  display: block;
  padding: 7px 0;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
}
.hist-foot a:hover { color: var(--text); }

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

.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 20px;
  scroll-behavior: smooth;
}
.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.chat::-webkit-scrollbar       { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* WELCOME */
.welcome {
  text-align: center;
  padding: 48px 20px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  max-width: 640px;
  margin: 0 auto;
}
.welcome-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.18), 0 2px 6px rgba(124, 58, 237, 0.08);
}
.welcome h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome p {
  color: var(--text-soft);
  font-size: 15px;
  max-width: 460px;
  margin-bottom: 28px;
}
.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}
@media (max-width: 480px) { .suggestions { grid-template-columns: 1fr; } }
.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  font-family: inherit;
}
.suggestion:hover  { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); transform: translateY(-1px); }
.suggestion:active { transform: translateY(0); }

/* MESSAGES */
.msg {
  display: flex;
  gap: 12px;
  max-width: 100%;
  animation: slide .25s ease;
}
@keyframes slide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { justify-content: flex-end; }
.msg-body { flex: 1; min-width: 0; max-width: 100%; }
.msg.user .msg-body { max-width: 85%; flex: 0 1 auto; }
.msg-content {
  background: var(--bot-bg);
  color: var(--bot-text);
  padding: 14px 18px;
  border-radius: 18px;
  border-top-left-radius: 4px;
  border: 1px solid var(--border);
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.msg.user .msg-content {
  background: var(--user-bg);
  color: var(--user-text);
  border: 1px solid var(--user-border);
  border-top-left-radius: 18px;
  border-top-right-radius: 4px;
}

/* PRODUCT CARDS */
.product-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-top: 10px;
}
.product-card img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--bg-alt);
}
.product-card .pc-body    { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.product-card .pc-name    { font-weight: 600; font-size: 14px; line-height: 1.3; color: var(--text); }
.product-card .pc-price   { font-weight: 600; font-size: 15px; color: var(--text); }
.product-card .pc-meta    { color: var(--text-soft); font-size: 12px; }
.product-card .pc-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* CHECKOUT LINK BUTTON — bot multi-item için "Ödemeye geç" butonu üretir */
.checkout-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.28);
  transition: opacity .15s, transform .12s, box-shadow .15s;
}
.checkout-link-btn:hover  { opacity: 0.95; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4); }
.checkout-link-btn:active { transform: translateY(0); }
.checkout-link-btn svg     { flex-shrink: 0; }

/* Chat içi Google ile giriş butonu */
.inline-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 18px;
  background: #fff;
  color: #1f1d18;
  border: 1px solid var(--border, #e8e2d5);
  border-radius: var(--radius-pill, 999px);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow .15s, transform .12s, border-color .15s;
}
.inline-login-btn:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.12); transform: translateY(-1px); border-color: #d0c8b8; }
.inline-login-btn:active { transform: translateY(0); }
.inline-login-btn svg { flex-shrink: 0; }
.checkout-link-btn .cl-meta {
  font-weight: 500;
  opacity: 0.85;
  font-size: 13px;
}
@media (max-width: 480px) {
  .checkout-link-btn { padding: 11px 18px; font-size: 13px; gap: 8px; }
  .checkout-link-btn .cl-meta { display: block; margin-top: 2px; }
}

/* FULL IMAGE LINK */
.full-image-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
.full-image-link:hover  { background: var(--accent); color: var(--accent-fg); }
.full-image-link:hover svg { stroke: var(--accent-fg); }
.full-image-link svg { stroke: var(--accent-strong); display: block; }

/* IMAGE POPUP */
.img-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 16, 10, 0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px;
  cursor: zoom-out;
}
.img-popup-img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  cursor: default;
}
.img-popup-close {
  position: absolute; top: 18px; right: 22px;
  background: #fff; color: #333;
  border: none; border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 22px; font-weight: 600;
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.img-popup-close:hover { background: #f0f0f0; }

.btn {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 500;
}
.btn:hover { opacity: 0.92; }
.btn-alt {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-alt:hover { background: var(--bg-alt); }

/* TYPING */
.typing {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bot-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-top-left-radius: 4px;
  width: fit-content;
}
.typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: pulse 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%,60%,100% { opacity: 0.3; transform: translateY(0); }
  30%         { opacity: 1;   transform: translateY(-4px); }
}
.typing-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
  font-style: italic;
  transition: opacity 0.18s ease;
}

/* INPUT */
.input-wrap {
  padding: 10px 16px 8px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-inner {
  max-width: 760px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: border-color .15s;
}
.input-inner:focus-within { border-color: var(--text-soft); }
textarea {
  flex: 1;
  border: 0;
  background: none;
  padding: 14px 50px 14px 20px;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  min-height: 52px;
  max-height: 200px;
  font-weight: 400;
}
textarea::placeholder { color: var(--text-muted); }
.send {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s, opacity .15s, box-shadow .15s;
  padding: 0;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}
.send svg { transform: translateX(-1px); }
.send:disabled { opacity: 0.3; cursor: not-allowed; }
.send:not(:disabled):hover  { transform: scale(1.05); }
.send:not(:disabled):active { transform: scale(0.95); }

/* ERROR */
.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
}

/* CHAT FOOT LINKS — input altında küçük, sürekli görünür bilgi bar */
.chat-foot-links {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  padding: 4px 16px calc(6px + var(--safe-bot));
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}
.chat-foot-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 0;
}
.chat-foot-links a:hover { color: var(--text); }
.chat-foot-links .sep { color: var(--border); }
@media (max-width: 480px) {
  .chat-foot-links { font-size: 10.5px; gap: 2px 8px; padding: 3px 10px calc(5px + var(--safe-bot)); }
  .chat-foot-links .sep { display: none; }
}

/* MOBILE */
@media (max-width: 640px) {
  .chat-inner   { padding: 16px; gap: 20px; }
  .msg-content  { padding: 12px 16px; font-size: 15px; }
  .welcome h1   { font-size: 26px; }
  .header       { padding: calc(10px + var(--safe-top)) 14px 10px; }
  .input-wrap   { padding: 10px 12px calc(10px + var(--safe-bot)); }
  .product-card { grid-template-columns: 80px 1fr; }
  .product-card img { width: 80px; height: 80px; }
}
