/* ============================================================
   ALBERT — Multi-Chat Dashboard
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { cursor: pointer; font: inherit; background: none; border: none; }
textarea { font: inherit; resize: none; }
a { color: inherit; }

/* --- Variables --- */
:root {
  --red:    #3a3a3a;
  --black:  #111111;
  --dark:   #2a2a2a;
  --mid:    #666666;
  --lite:   #aaaaaa;
  --border: #e0e0e0;
  --bg:     #FFFCF6;
  --white:  #ffffff;

  --r-card:  14px;
  --r-glass: 22px;

  --fs:    12px;
  --fs-sm: 11px;
  --fs-xs: 10px;

  --header-h: 50px;
  --gap: 10px;

  /* Card size constraints */
  --card-min: 200px;
  --card-max: 340px;
}

/* --- Base --- */
html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: var(--fs);
  background: var(--bg);
  color: var(--black);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  height: var(--header-h);
  background: rgba(40, 40, 42, 0.90);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  position: relative;
  /* fix: force all children to inherit light color */
  color: #FFFCF6;
}

.header__label {
  color: #FFFCF6;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-right: 14px;
  opacity: 0.9;
}

.header__socials {
  display: flex;
  align-items: center;
  gap: 22px;
}

.header__social {
  color: rgba(255, 252, 246, 0.88);
  display: flex;
  align-items: center;
  transition: color 0.15s, transform 0.15s;
  text-decoration: none;
}
.header__social:hover {
  color: #FFFCF6;
  transform: scale(1.12);
}
.header__social svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ============================================================
   LANG TOGGLE — Apple-style sliding pill
   ============================================================ */
.lang-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  gap: 0;
  padding: 3px;
}

/* Sliding liquid glass pill */
.lang-pill {
  position: absolute;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px) saturate(160%) brightness(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(160%) brightness(1.1);
  box-shadow:
    0 0 0 0.5px rgba(255,255,255,0.45),
    inset 0 1px 0 rgba(255,255,255,0.65),
    0 2px 8px rgba(0,0,0,0.1);
  pointer-events: none;
  z-index: 0;
  transform-origin: center center;
}

@keyframes pill-squish {
  0%   { transform: scaleX(1)    scaleY(1); }
  18%  { transform: scaleX(1.22) scaleY(0.82); }
  42%  { transform: scaleX(0.88) scaleY(1.10); }
  65%  { transform: scaleX(1.06) scaleY(0.95); }
  82%  { transform: scaleX(0.97) scaleY(1.02); }
  100% { transform: scaleX(1)    scaleY(1); }
}

.lang-pill--squish {
  animation: pill-squish 0.42s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}

.lang-btn {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 252, 246, 0.6);
  border-radius: 16px;
  padding: 3px 9px;
  line-height: 1;
  position: relative;
  z-index: 1;
  transition: color 0.2s;
}

.lang-btn.active {
  color: #FFFCF6;
}

.lang-btn:hover:not(.active) {
  color: rgba(255, 252, 246, 0.88);
}

/* ============================================================
   PAGE SCROLL WRAPPER
   ============================================================ */
.page-scroll {
  min-height: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.page-scroll::-webkit-scrollbar { width: 4px; }
.page-scroll::-webkit-scrollbar-track { background: transparent; }
.page-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   GRID — min/max card size, 4 columns, centered
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(var(--card-min), var(--card-max)));
  gap: var(--gap);
  padding: var(--gap);
  justify-content: center;
}

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(var(--card-min), var(--card-max))); }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: minmax(var(--card-min), var(--card-max)); }
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  height: 480px;
}

/* --- Card Header --- */
.card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.card__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card__avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(235,12,34,0.18);
}

.card__name {
  flex: 1;
  font-weight: 600;
  font-size: var(--fs);
  color: var(--dark);
}

.card__clear {
  font-size: var(--fs-xs);
  color: var(--lite);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  transition: color 0.15s, border-color 0.15s;
}
.card__clear:hover { color: var(--red); border-color: var(--red); }

/* --- Card Body --- */
.card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* --- Chat Column --- */
.card__chat {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 10px 12px 72px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
.card__chat::-webkit-scrollbar { width: 3px; }
.card__chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   ACTIVE CARD — stays same size, moves to col 1 row 1
   ============================================================ */
.card--active {
  grid-column: 1;
  grid-row: 1;
}

/* ============================================================
   SIDE PANEL — spans columns 2-4 of row 1
   ============================================================ */
.side-panel {
  display: none;
  grid-column: 2 / 5;
  grid-row: 1;
  background: var(--white);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  height: 480px;
  flex-direction: column;
  overflow: hidden;
  animation: panel-in 0.18s ease;
}

.side-panel.visible {
  display: flex;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1100px) {
  .side-panel { grid-column: 2 / 3; }
}

@media (max-width: 600px) {
  .side-panel { display: none !important; }
  .card--active { grid-column: unset; grid-row: unset; }
}

/* --- Side Panel Header --- */
.side-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.side-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.side-panel__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--lite);
  transition: background 0.15s, color 0.15s;
}
.side-panel__close:hover { background: var(--bg); color: var(--black); }

/* --- Side Panel Schema area --- */
.side-panel__schema {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 16px 20px 0;
  overflow: hidden;
}

.schema__label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--lite);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.schema__svg {
  width: 100%;
  max-width: 520px;
  height: auto;
}

/* --- Side Panel info section --- */
.side-panel__info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
  padding: 12px 20px 16px;
}

.panel__section { display: flex; flex-direction: column; gap: 5px; }

.panel__label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--lite);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel__tools { display: flex; flex-wrap: wrap; gap: 4px; }

.tag {
  font-size: var(--fs-xs);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--mid);
}

.panel__reasoning-live {
  font-size: var(--fs-sm);
  color: var(--mid);
  line-height: 1.6;
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 36px;
}

/* ============================================================
   MESSAGES
   ============================================================ */
.message { display: flex; max-width: 100%; }

/* User — plain text */
.message--user { justify-content: flex-end; }
.message--user .message__text {
  font-size: var(--fs);
  color: var(--dark);
  line-height: 1.5;
  max-width: 88%;
  word-break: break-word;
}

/* Bot — liquid glass bubble */
.message--bot { justify-content: flex-start; }

.message__bubble {
  position: relative;
  max-width: 88%;
  word-break: break-word;
  border-radius: 12px 12px 12px 3px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 0.5px rgba(200, 200, 200, 0.4),
    0 2px 12px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  -webkit-backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  padding: 7px 11px;
}

/* Ring lens — distortion only at the border */
.message__bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  filter: url(#glass-edge);
  mask-image: radial-gradient(ellipse calc(100% - 12px) calc(100% - 12px) at 50% 50%, transparent 99%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse calc(100% - 12px) calc(100% - 12px) at 50% 50%, transparent 99%, black 100%);
  pointer-events: none;
  z-index: 0;
}

/* Highlight + rim */
.message__bubble::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, transparent 50%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 -0.5px 0 rgba(0,0,0,0.05),
    inset 1px 0 0 rgba(255,255,255,0.35),
    inset -1px 0 0 rgba(255,255,255,0.35);
  pointer-events: none;
  z-index: 0;
}

.message__bubble .message__text {
  font-size: var(--fs);
  color: var(--dark);
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

/* ============================================================
   LIQUID GLASS INPUT ISLAND
   ============================================================ */
.card__input {
  position: absolute;
  bottom: 9px;
  left: 9px;
  right: 9px;
  z-index: 20;

  border-radius: var(--r-glass);

  /*
    Liquid glass:
    - low blur so background shapes remain recognizable
    - slightly higher tint for glass visibility
    - edge defined by ring-lens distortion + highlight rim
  */
  backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  -webkit-backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  background: rgba(255, 255, 255, 0.16);

  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.5),
    0 6px 24px rgba(0, 0, 0, 0.07);

  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
}

/* Ring lens — distortion only at the border */
.card__input::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  filter: url(#glass-edge);
  mask-image: radial-gradient(ellipse calc(100% - 14px) calc(100% - 14px) at 50% 50%, transparent 99%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse calc(100% - 14px) calc(100% - 14px) at 50% 50%, transparent 99%, black 100%);
  pointer-events: none;
  z-index: 0;
}

/* Highlight + rim */
.card__input::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.28) 0%, transparent 50%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -0.5px 0 rgba(0,0,0,0.06),
    inset 1px 0 0 rgba(255,255,255,0.4),
    inset -1px 0 0 rgba(255,255,255,0.4);
  pointer-events: none;
  z-index: 0;
}

/* Input children render above the backdrop layer */
.card__input > * { position: relative; z-index: 1; }

/* --- Input elements --- */
.input__attach {
  display: flex;
  align-items: center;
  color: var(--lite);
  transition: color 0.15s;
  flex-shrink: 0;
  padding: 2px;
}
.input__attach:hover { color: var(--red); }

.input__file-badge {
  font-size: var(--fs-xs);
  color: var(--mid);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}
.input__file-badge.visible { display: block; }

.input__field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--fs);
  color: var(--dark);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.input__field::placeholder { color: var(--lite); }

/* Rounded triangle send button */
.input__send {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  min-width: 26px;
  color: var(--white);
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
.input__send:hover { opacity: 0.82; transform: scale(1.06); }
.input__send:active { transform: scale(0.95); }

/* ============================================================
   TOOLTIP — liquid glass
   ============================================================ */
.tooltip {
  position: fixed;
  z-index: 500;
  pointer-events: none;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: var(--fs-sm);
  color: #555;
  max-width: 200px;
  white-space: normal;
  line-height: 1.4;

  /* Liquid glass */
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  -webkit-backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.5),
    0 6px 20px rgba(0, 0, 0, 0.1);

  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Ring lens */
.tooltip::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  filter: url(#glass-edge);
  mask-image: radial-gradient(ellipse calc(100% - 10px) calc(100% - 10px) at 50% 50%, transparent 99%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse calc(100% - 10px) calc(100% - 10px) at 50% 50%, transparent 99%, black 100%);
  pointer-events: none;
}

/* Highlight + rim */
.tooltip::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, transparent 50%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.85),
    inset 0 -0.5px 0 rgba(0,0,0,0.05);
  pointer-events: none;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  padding: 16px 20px 24px;
  margin-top: auto;
}

.footer p {
  font-size: var(--fs-xs);
  color: var(--lite);
  line-height: 1.6;
  text-align: center;
}

.footer__link {
  text-decoration: underline;
  color: var(--lite);
  transition: color 0.15s;
}
.footer__link:hover { color: var(--mid); }

/* ============================================================
   COOKIE BANNER — liquid glass
   ============================================================ */
.cookie-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 400;
  width: min(520px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.cookie-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}

.cookie-banner__body {
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;

  /* Liquid glass */
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  -webkit-backdrop-filter: blur(7px) saturate(120%) brightness(1.02);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.5),
    0 12px 40px rgba(0, 0, 0, 0.12);
  position: relative;
}

/* Ring lens */
.cookie-banner__body::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.08);
  filter: url(#glass-edge);
  mask-image: radial-gradient(ellipse calc(100% - 14px) calc(100% - 14px) at 50% 50%, transparent 99%, black 100%);
  -webkit-mask-image: radial-gradient(ellipse calc(100% - 14px) calc(100% - 14px) at 50% 50%, transparent 99%, black 100%);
  pointer-events: none;
  z-index: 0;
}

/* Highlight + rim */
.cookie-banner__body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.28) 0%, transparent 50%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -0.5px 0 rgba(0,0,0,0.06),
    inset 1px 0 0 rgba(255,255,255,0.4),
    inset -1px 0 0 rgba(255,255,255,0.4);
  pointer-events: none;
  z-index: 0;
}

.cookie-banner__body > * { position: relative; z-index: 1; }

.cookie-banner__text {
  font-size: var(--fs-sm);
  color: var(--dark);
  line-height: 1.55;
}

.cookie-banner__note {
  color: var(--mid);
  font-size: var(--fs-xs);
}

.cookie-banner__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.cookie-banner__btn {
  font-size: var(--fs-sm);
  padding: 5px 14px;
  border-radius: 8px;
  transition: opacity 0.15s;
}
.cookie-banner__btn--accept {
  background: var(--red);
  color: var(--white);
}
.cookie-banner__btn--decline {
  background: var(--bg);
  color: var(--mid);
  border: 1px solid var(--border);
}
.cookie-banner__btn:hover { opacity: 0.82; }

/* ============================================================
   UTILITIES
   ============================================================ */
.svg-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
