html,
body {
  height: 100%;
}

/* ✅ Στη σελίδα chat: κρύψε εντελώς το header */
body.chat-page header {
  display: none !important;
}

/* ✅ Και το padding-top του main (που υπάρχει λόγω fixed header) */
body.chat-page main#top {
  padding-top: 0 !important;
}

/* Κρύβουμε footer μόνο στη σελίδα chat */
body.chat-page footer {
  display: none !important;
}

/* Non-owner: κρύψε owner-only κομμάτια */
body.chat-page .hidden-by-owner {
  display: none !important;
}

body.chat-page {
  height: 100vh; /* fallback */
  height: 100dvh; /* ✅ σωστό στο mobile με keyboard */
  overflow: hidden;
  overscroll-behavior: none;
  background: #fff;
}

.chat-app-root {
  height: 100vh; /* fallback */
  height: 100dvh; /* ✅ */
  width: 100%;
  background: #fff;
}

/* Main app layout */
.chat-app {
  height: 100%;
  display: flex;
  min-height: 0;
}

/* Toggle button (always visible) */
.menu-toggle-btn {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: 0.9rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-toggle-btn:hover {
  background: #f8fafc;
}

/* ✅ Mobile: πιο μικρό/στενό burger + πάντα “safe” θέση */
@media (max-width: 1023px) {
  .menu-toggle-btn {
    width: 34px; /* ✅ πιο στενό */
    height: 34px;
    border-radius: 999px; /* πιο “pill/circle” */
    left: 0.5rem;
    top: 0.5rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  }
  .menu-toggle-btn i {
    font-size: 0.85rem;
  }
}

@media (max-width: 1023px) {
  .side-top {
    padding-top: calc(0.85rem + env(safe-area-inset-top));
  }
}

/* ✅ Mobile: όταν ανοίγει το drawer, κρύψε το burger (θέλουμε μόνο όταν είναι κλειστό) */
@media (max-width: 1023px) {
  body.drawer-open .menu-toggle-btn {
    display: none !important;
  }
}

/* ✅ Το burger/toggle να φαίνεται ΜΟΝΟ σε mobile */
@media (min-width: 1024px) {
  .menu-toggle-btn {
    display: none !important;
  }
}

/* Backdrop (mobile drawer) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
body.drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Side menu (desktop sidebar) */
.side-menu {
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  height: 100%;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.18s ease, min-width 0.18s ease, max-width 0.18s ease;
}

/* Brand row */
.side-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: #2e4bdb;
  color: #fff;
  box-shadow: 0 10px 20px rgba(34, 63, 216, 0.25);
  flex: 0 0 auto;
}
.brand-text {
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Top row tweaks */
.side-top {
  padding: 0.85rem 0.85rem 0.75rem;
  border-bottom: 1px solid #eef2f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Icon buttons (collapse/close) */
.side-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 0.85rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.side-icon-btn:hover {
  background: #f8fafc;
}

/* Mobile close visible only on mobile (αλλά εμείς το κρύβουμε τελείως σε mobile) */
.side-close-btn {
  display: none;
}
/* ✅ Mobile: κρύψε το X (δεν χρειάζεται) */
@media (max-width: 1023px) {
  .side-close-btn {
    display: none !important;
  }
}

/* New chat block */
.side-newchat {
  padding: 0.75rem 0.75rem 0.5rem;
}
.side-newchat-btn {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid #dbe3ff;
  background: #eef2ff;
  color: #2e4bdb;
  padding: 0.7rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.side-newchat-btn:hover {
  background: #e6ecff;
}
.side-newchat-btn .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subhead above session list */
.side-subhead {
  padding: 0.1rem 0.95rem 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

/* Collapsed rail (desktop) */
.side-rail {
  display: none;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  height: 100%;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.5rem;
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rail-btn:hover {
  background: #f8fafc;
}

/* ✅ Rail hover hint (desktop) */
.rail-expand-btn {
  position: relative;
}
.rail-hint {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  color: #2e4bdb;
  border-color: #dbe3ff;
}
.rail-expand-btn:hover .rail-hint {
  opacity: 1;
  transform: translateY(-50%) translateX(2px);
}
.rail-expand-btn:hover {
  border-color: #cbd5e1;
}

/* ✅ ChatGPT-like tooltip: ΜΟΝΟ όταν το sidebar είναι collapsed (desktop) */
@media (min-width: 1024px) {
  body.sidebar-collapsed .rail-btn {
    position: relative;
  }

  body.sidebar-collapsed .rail-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.78rem;
    line-height: 1;
    padding: 0.45rem 0.6rem;
    border-radius: 0.6rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
  }

  body.sidebar-collapsed .rail-btn[data-tooltip]::before {
    content: "";
    position: absolute;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: rgba(15, 23, 42, 0.92);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
  }

  body.sidebar-collapsed .rail-btn:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(2px);
  }
  body.sidebar-collapsed .rail-btn:hover::before {
    opacity: 1;
  }
}

/* Show rail when sidebar is collapsed (desktop only) */
@media (min-width: 1024px) {
  body.sidebar-collapsed .side-rail {
    display: flex;
  }
}

/* Desktop collapsed */
body.sidebar-collapsed .side-menu {
  width: 0;
  min-width: 0;
  max-width: 0;
  border-right: none;
  overflow: hidden;
}

/* Sessions list */
.side-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.side-list {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem;
}

/* Session items */
.side-menu button.session-item {
  text-align: left;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  font-size: 0.82rem;
  line-height: 1.3;
  color: #0f172a;
  background: transparent;
}
.side-menu button.session-item:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}
.side-menu button.session-item.active {
  background: #e0ebff;
  border-color: #2e4bdb;
}
.side-menu .session-delete {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 0.8rem;
  color: #94a3b8;
}
.side-menu button.session-item:hover .session-delete {
  opacity: 1;
}
.side-menu .session-delete:hover {
  color: #ef4444;
}

/* Side actions */
.side-bottom {
  border-top: 1px solid #eef2f6;
  padding: 0.5rem;
  background: #fff;
}
.side-actions-title {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.25rem 0.35rem 0.5rem;
}
.side-lang-slot {
  padding: 0.25rem 0.35rem 0.5rem;
}
.side-action-btn {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 0.7rem;
  font-size: 0.85rem;
  color: #0f172a;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.side-action-btn i {
  width: 18px;
  text-align: center;
}
.side-action-btn:hover {
  background: #f8fafc;
}

/* Mobile drawer behavior: sidebar becomes off-canvas */
@media (max-width: 1023px) {
  .side-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 85;
    width: 18rem;
    min-width: 18rem;
    max-width: 18rem;
    transform: translateX(-105%);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease;
    border-right: 1px solid #e2e8f0;
  }
  body.drawer-open .side-menu {
    transform: translateX(0);
  }
  /* Σε mobile δεν έχει νόημα collapse width=0 */
  body.sidebar-collapsed .side-menu {
    width: 18rem;
    min-width: 18rem;
    max-width: 18rem;
  }
}

/* Chat container full screen */
.chat-shell {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-container {
  height: 100%;
  width: 100%;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Chatlog scroll + padding */
.chatlog {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1rem;
  padding-top: 1.25rem;
  padding-bottom: calc(
    var(--composer-h, 88px) + var(--bottomhint-h, 44px) + 1rem
  );
}

/* ✅ Mobile: άφησε χώρο πάνω ώστε το burger να μη πατάει ποτέ πάνω σε κείμενο */
@media (max-width: 1023px) {
  .chatlog {
    padding-top: 3.25rem;
    scroll-padding-top: 3.25rem;
  }
}

/* Composer */
/* ✅ Composer σαν ChatGPT */
#composer {
  position: sticky;
  bottom: calc(var(--bottomhint-h, 0px) + 0.5rem);
  margin: 0.75rem;
  z-index: 50;
  background: #fff;

  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  padding: 0.5rem;
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.25);

  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

@media (max-width: 1023px) {
  #composer {
    position: relative; /* ✅ όχι fixed */
    left: auto;
    right: auto;
    bottom: auto;

    margin: 0.75rem; /* ίδιο spacing */
    transform: none;
  }
}

/* ✅ Textarea ChatGPT-like + autosize */
#msg {
  width: 100%;
  font-size: 16px;
  line-height: 1.45;

  border: 0;
  outline: none;
  background: transparent;

  padding: 0.65rem 0.75rem;
  border-radius: 1rem;

  resize: none;
  overflow-y: hidden;
  min-height: 44px;
  max-height: 220px;
}

#msg:focus {
  outline: none;
}

/* Send button */
#sendBtn {
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #eef2ff;
  color: #2e4bdb;
  border: 1px solid #dbe3ff;
  flex: 0 0 auto;
}
#sendBtn:hover {
  background: #e6ecff;
}
#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bubbles */
.bubble {
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* ✅ Assistant: καθαρό, με brand hint */
.bubble.assistant {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  position: relative;
  padding-left: 1.35rem; /* χώρο για τη γραμμή */
}

/* λεπτή μπλε “accent” γραμμή αριστερά */
.bubble.assistant::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 3px;
  border-radius: 999px;
  background: #dbe3ff;
}

/* ✅ User: mirror accent (όχι “μπλε παράθυρο”) */
.bubble.user {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #dbe3ff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  position: relative;
  padding-right: 1.35rem; /* χώρο για τη γραμμή */
}

.bubble.user::after {
  content: "";
  position: absolute;
  right: 0.55rem;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 3px;
  border-radius: 999px;
  background: rgba(46, 75, 219, 0.55);
}

.thinking {
  color: #64748b;
  font-style: italic;
}

/* Prose + markdown styling */
.bubble.prose {
  line-height: 1.75;
  font-size: 0.98rem;
}

/* ✅ Spacing ανάμεσα στα μηνύματα */
.chatlog > .flex {
  margin: 0.75rem 0;
}
.chatlog > .flex + .flex {
  margin-top: 1rem;
}

.prose p {
  margin: 0.85em 0;
}
.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.12rem 0.32rem;
  border-radius: 0.4rem;
}
.prose pre {
  overflow-x: auto;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.prose pre code {
  background: transparent;
  padding: 0;
}

.prose h1,
.prose h2,
.prose h3 {
  margin: 0.9em 0 0.45em;
  line-height: 1.25;
}

.prose ul,
.prose ol {
  margin: 0.85em 0 0.85em 1.25em;
}

.prose li {
  margin: 0.45em 0;
}

/* Meta rows */
.meta-row {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem; /* ✅ περισσότερο κενό */
  align-items: center;
}

@media (max-width: 1023px) {
  .meta-row {
    gap: 0.45rem;
  }
  .sources-text {
    flex-basis: 100%;
  }
}

.sources-text {
  font-size: 0.7rem;
  color: #64748b;
}

.assistant-time {
  font-size: 0.72rem;
  color: #64748b;
}

.user-meta-row {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-stamp {
  font-size: 0.72rem;
  color: #475569;
  white-space: nowrap;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  user-select: none;
  white-space: nowrap;
}
.mode-chip--docs {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}
.mode-chip--general {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
}

/* PIN modal + bottom hint */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
}
.modal-backdrop.show {
  display: flex;
}

#bottomHint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
}
#bottomHint .inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 0.35rem;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  color: #64748b;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;
}
#bottomHint a {
  text-decoration: underline;
}

/* Print */
@media print {
  .menu-toggle-btn,
  .side-menu,
  .drawer-backdrop,
  #composer,
  #bottomHint {
    display: none !important;
  }
  body {
    background: #fff;
    font-size: 12px;
    line-height: 1.3;
  }
  .bubble {
    font-size: 12px;
    line-height: 1.4;
  }
}
