/* ==========================================================================
   Varelas AI — presentation layer for Chainlit 2.9.x
   --------------------------------------------------------------------------
   Colours come from public/theme.json (Chainlit's shadcn tokens). This file
   only shapes the native shell: login, sidebar, header, welcome, messages,
   offer tables, composer, dialogs. Dark mode is `html.dark`.
   `!important` is used only where a Tailwind utility on the same element
   would otherwise win.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Base
   -------------------------------------------------------------------------- */
:root {
  --vr-radius-lg: 16px;
  --vr-radius: 12px;
  --vr-radius-sm: 8px;
  --vr-shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 1px rgb(15 23 42 / 0.03);
  --vr-shadow-md: 0 8px 24px rgb(15 23 42 / 0.10), 0 2px 6px rgb(15 23 42 / 0.06);
  --vr-column: 1100px;
}

.dark {
  --vr-shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  --vr-shadow-md: 0 12px 32px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.35);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-size: 15px;
  line-height: 1.6;
}

::selection {
  background: hsl(var(--primary) / 0.18);
}

/* Scrollbars: thin and quiet everywhere. */
* {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--foreground) / 0.18) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: hsl(var(--foreground) / 0.18);
  border-radius: 999px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------------------------
   1. Login
   -------------------------------------------------------------------------- */
.grid.min-h-svh > div:first-child {
  background: hsl(var(--background));
}

.grid.min-h-svh img.logo {
  width: 168px !important;
  height: auto;
}

.grid.min-h-svh form {
  gap: 28px;
}

.grid.min-h-svh form h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.grid.min-h-svh form label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.grid.min-h-svh form input {
  height: 44px;
  border-radius: var(--vr-radius-sm);
  background: hsl(var(--card));
  font-size: 15px;
}

.grid.min-h-svh form input:focus-visible {
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.18);
  border-color: hsl(var(--primary));
}

.grid.min-h-svh form button {
  height: 44px;
  border-radius: var(--vr-radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.grid.min-h-svh form button:active {
  transform: translateY(1px);
}

/* Cognito is the only entry in production: make it the filled primary action.
   With the local review form present, the password submit is primary and
   Cognito becomes the outlined alternative. */
.grid.min-h-svh form:not(:has(#password)) button {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.grid.min-h-svh form:not(:has(#password)) button:hover {
  background: hsl(var(--primary) / 0.9);
}

.grid.min-h-svh form:has(#password) button[type="submit"] {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.grid.min-h-svh form:has(#password) button:not([type="submit"]) {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
}

.grid.min-h-svh form:has(#password) button:not([type="submit"]):hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  background: hsl(var(--accent));
}

/* The provider button reads just "Σύνδεση": sales reps don't know what
   Cognito is, so the AWS provider icon goes too. */
.grid.min-h-svh form button svg,
.grid.min-h-svh form button img {
  display: none;
}

/* Brand panel */
.grid.min-h-svh > div:last-child {
  background: #0B3D6B;
}

.grid.min-h-svh > div:last-child img {
  filter: none !important;
  object-position: center;
}

/* --------------------------------------------------------------------------
   2. Sidebar
   -------------------------------------------------------------------------- */
[data-sidebar="sidebar"] {
  border-right: 1px solid hsl(var(--sidebar-border));
}

[data-sidebar="header"] {
  padding: 12px 12px 8px;
}

[data-sidebar="header"] button {
  width: 36px;
  height: 36px;
  border-radius: var(--vr-radius-sm);
  color: hsl(var(--muted-foreground));
}

[data-sidebar="header"] button:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--sidebar-accent));
}

[data-sidebar="content"] {
  padding: 0 8px 12px;
}

[data-sidebar="group"] {
  padding: 4px 0;
}

/* No text-transform: CSS uppercase keeps Greek accents (ΣΉΜΕΡΑ), which reads wrong. */
[data-sidebar="group-label"] {
  height: auto;
  padding: 14px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: hsl(var(--muted-foreground));
}

[data-sidebar="menu"] {
  gap: 2px;
}

[data-sidebar="menu-button"] {
  height: 36px;
  padding: 0 10px;
  border-radius: var(--vr-radius-sm);
  font-size: 14px;
  color: hsl(var(--sidebar-foreground));
  transition: background-color 0.12s ease;
}

[data-sidebar="menu-button"]:hover {
  background: hsl(var(--sidebar-accent));
}

[data-sidebar="menu-button"][data-active="true"] {
  background: hsl(var(--sidebar-accent));
  font-weight: 500;
  box-shadow: inset 3px 0 0 hsl(var(--primary));
}

#thread-options {
  border-radius: 6px;
  color: hsl(var(--muted-foreground));
}

#thread-options:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--foreground) / 0.08);
}

/* Empty history: quiet text, not an alert box. */
#thread-history .alert,
#thread-history [role="alert"] {
  margin: 8px 6px;
  padding: 18px 12px;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--vr-radius);
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  text-align: center;
  justify-content: center;
  box-shadow: none;
}

#thread-history .alert *,
#thread-history [role="alert"] * {
  color: hsl(var(--muted-foreground));
}

#thread-history .alert svg,
#thread-history [role="alert"] svg {
  display: none;
}

/* Thread menu: rename and delete only. */
#share-thread {
  display: none !important;
}

/* --------------------------------------------------------------------------
   3. Header
   -------------------------------------------------------------------------- */
#header {
  height: 56px;
  padding: 0 16px;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
}

/* Persistent wordmark in the header centre (Chainlit's logo route). */
#header > div:nth-child(2)::before {
  content: "";
  display: block;
  width: 110px;
  height: 44px;
  background: url("/logo?theme=light") center / contain no-repeat;
}

.dark #header > div:nth-child(2)::before {
  background-image: url("/logo?theme=dark");
}

/* The welcome screen already shows the large logo; don't double it. */
main:has(#starters) #header > div:nth-child(2)::before {
  display: none;
}

#header button {
  border-radius: var(--vr-radius-sm);
  color: hsl(var(--muted-foreground));
}

#header button:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

#header #user-nav-button {
  border-radius: 999px;
  color: inherit;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 3px hsl(var(--border));
}

#header #user-nav-button:hover {
  background: transparent;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 3px hsl(var(--primary));
}

#header #user-nav-button .bg-primary {
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   4. Welcome screen + starters
   -------------------------------------------------------------------------- */
#starters {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 720px;
  margin: 8px auto 0;
}

#starters::before {
  content: "Τι θα ετοιμάσουμε σήμερα;";
  grid-column: 1 / -1;
  margin-bottom: 2px;
  text-align: center;
  font-size: 15px;
  color: hsl(var(--muted-foreground));
}

#starters > button,
#starters button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100% !important;
  height: auto;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--vr-radius);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  white-space: normal;
  box-shadow: var(--vr-shadow);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

#starters button:hover {
  border-color: hsl(var(--primary) / 0.5);
  background: hsl(var(--accent));
  transform: translateY(-1px);
  box-shadow: var(--vr-shadow-md);
}

#starters button > div {
  align-items: center;
  gap: 12px;
}

#starters button p {
  color: hsl(var(--foreground)) !important;
  font-size: 14px;
  font-weight: 500;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#starters button img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 0;
}

.dark #starters button img {
  filter: brightness(0) invert(1) opacity(0.85);
}

/* --------------------------------------------------------------------------
   5. Conversation
   -------------------------------------------------------------------------- */
main {
  background: hsl(var(--background));
}

/* Column width: Chainlit's wide layout pins 60rem inline; a nine-column
   offer table wants more before it has to scroll. */
main [style*="max-width: min(60rem"] {
  max-width: min(var(--vr-column), 100vw) !important;
}

.step {
  padding: 10px 0;
  font-size: 15px;
  line-height: 1.6;
}

/* Assistant text sits on the page surface; no bubble. */
.step[data-step-type="assistant_message"] .message-content,
.step[data-step-type="run"] .message-content {
  color: hsl(var(--foreground));
}

.step .prose {
  max-width: none;
  color: hsl(var(--foreground));
}

.step .prose h1,
.step .prose h2,
.step .prose h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

.step .prose h1 { font-size: 22px; margin: 0.4em 0 0.5em; }
.step .prose h2 { font-size: 18px; margin: 1em 0 0.5em; }
.step .prose h3 { font-size: 16px; margin: 1em 0 0.4em; }

.step .prose a {
  color: hsl(var(--primary));
  text-decoration-color: hsl(var(--primary) / 0.4);
  text-underline-offset: 3px;
}

.step .prose strong {
  font-weight: 600;
  color: hsl(var(--foreground));
}

.step .prose code {
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  font-size: 0.9em;
}

.step .prose hr {
  border-color: hsl(var(--border));
  margin: 1.2em 0;
}

.step .prose ul,
.step .prose ol {
  padding-left: 1.4em;
}

/* User message: right-aligned bubble. */
.step[data-step-type="user_message"] .bg-accent,
.step[data-step-type="user_message"] .rounded-3xl {
  width: fit-content !important;
  max-width: calc(100% - 44px) !important;
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px !important;
  background: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
  box-shadow: var(--vr-shadow);
}

.step[data-step-type="user_message"] .bg-accent *,
.step[data-step-type="user_message"] .rounded-3xl * {
  color: inherit;
}

/* Avatars: small, round, quiet. */
.step .rounded-full img,
.step img.rounded-full {
  width: 28px;
  height: 28px;
}

/* Message actions (copy) */
.step button {
  border-radius: 6px;
  color: hsl(var(--muted-foreground));
}

.step button:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

/* Feedback thumbs are not used by the sales team. */
.positive-feedback-off,
.negative-feedback-off,
.positive-feedback-on,
.negative-feedback-on {
  display: none !important;
}

/* Tool-call steps: collapsed, subtle. */
.step[data-step-type="tool"] > div:first-child,
.step[data-step-type="tool"] summary,
.step details summary {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}

/* Attached files (generated Word offers) */
.inline-file .bg-card,
.inline-file > div {
  border: 1px solid hsl(var(--border));
  border-radius: var(--vr-radius);
  background: hsl(var(--card));
  box-shadow: var(--vr-shadow);
}

/* Action buttons under a message (image choice, confirmation). Chainlit
   renders them as ghost buttons with `px-3` next to the icon-only copy
   button in the same wrap row. */
.step .ai-message .flex-wrap {
  gap: 8px;
  margin-top: 4px;
}

.step .ai-message .flex-wrap button.px-3 {
  height: 34px;
  padding: 0 14px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--vr-shadow);
}

.step .ai-message .flex-wrap button.px-3:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  background: hsl(var(--accent));
}

.step .ai-message .flex-wrap button.px-3 svg {
  color: hsl(var(--primary));
}

/* --------------------------------------------------------------------------
   6. Offer tables (the product)
   -------------------------------------------------------------------------- */
.step .prose table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

/* Wrapper: card with its own horizontal scroll. */
.step .prose .overflow-auto,
.step .prose div:has(> table),
.step .prose .table-wrapper {
  margin: 12px 0 16px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--vr-radius);
  background: hsl(var(--card));
  box-shadow: var(--vr-shadow);
  overflow: auto;
  max-width: 100%;
}

.step .prose table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  border-bottom: 1px solid hsl(var(--border));
}

/* Description column (always third) gets room; numbers stay compact. */
.step .prose table td:nth-child(3),
.step .prose table th:nth-child(3) {
  min-width: 240px;
}

.step .prose table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  color: hsl(var(--foreground));
}

.step .prose table tbody tr:last-child td {
  border-bottom: none;
}

.step .prose table tbody tr:nth-child(even) td {
  background: hsl(var(--muted) / 0.45);
}

.step .prose table tbody tr:hover td {
  background: hsl(var(--accent) / 0.6);
}

.step .prose table td:first-child,
.step .prose table th:first-child {
  padding-left: 14px;
}

.step .prose table td:last-child,
.step .prose table th:last-child {
  padding-right: 14px;
}

/* Numbers align right via the markdown alignment markers the tool emits. */
.step .prose table [align="right"],
.step .prose table [style*="text-align: right"],
.step .prose table [style*="text-align:right"] {
  text-align: right;
}

/* Total rows are emitted in bold. */
.step .prose table tr:has(td strong:only-child) td {
  background: hsl(var(--accent) / 0.5);
  font-weight: 600;
}

/* Thumbnails: the confirmation table links a preview image per row.
   Chainlit wraps every markdown image in a 16:9 aspect box with a muted
   background; collapse it to a 56px square tile. */
.step .prose table td a:has(img) {
  display: inline-block;
}

.step .prose table td a > div {
  width: 56px !important;
  max-width: 56px !important;
}

.step .prose table td [data-radix-aspect-ratio-wrapper] {
  padding-bottom: 100% !important;
}

.step .prose table td [data-radix-aspect-ratio-wrapper] > div {
  background: #fff !important;
  border: 1px solid hsl(var(--border));
  border-radius: 8px !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.step .prose table td img {
  margin: 0;
  padding: 3px;
  object-fit: contain;
}

.step .prose table a:hover [data-radix-aspect-ratio-wrapper] > div {
  transform: scale(1.04);
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.5);
}

/* Image-choice table (Επιλογή | Προεπισκόπηση): two columns, so the
   photo is the point — give it room to be judged. */
.step .prose table:has(thead th:nth-child(2):last-child) td a > div {
  width: 132px !important;
  max-width: 132px !important;
}

.step .prose table:has(thead th:nth-child(2):last-child) td:first-child {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--primary));
}

.step .prose table a {
  text-decoration: none;
}

.step .prose table td code {
  font-size: 12px;
  padding: 0.1em 0.35em;
}

/* --------------------------------------------------------------------------
   7. Composer
   -------------------------------------------------------------------------- */
#message-composer {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px;
  width: 100%;
  max-width: var(--vr-column) !important;
  margin: 0 auto;
  padding: 12px 14px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--vr-radius-lg) !important;
  background: hsl(var(--card)) !important;
  box-shadow: var(--vr-shadow-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#message-composer:focus-within {
  border-color: hsl(var(--primary) / 0.7);
  box-shadow: var(--vr-shadow-md), 0 0 0 3px hsl(var(--primary) / 0.14);
}

#message-composer #chat-input,
#message-composer [contenteditable="true"],
#message-composer textarea {
  min-height: 24px;
  padding: 4px 2px;
  font-size: 15px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: transparent;
}

#message-composer #chat-input:empty::before,
#message-composer [contenteditable="true"]:empty::before {
  color: hsl(var(--muted-foreground));
}

#message-composer button {
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

/* Attach: bare "+" on the left. */
#message-composer #upload-button {
  width: 36px !important;
  height: 36px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: hsl(var(--muted-foreground)) !important;
  box-shadow: none !important;
  transform: none !important;
}

#message-composer #upload-button svg {
  display: none !important;
}

#message-composer #upload-button::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto;
  background:
    linear-gradient(currentColor, currentColor) center / 1.75px 18px no-repeat,
    linear-gradient(currentColor, currentColor) center / 18px 1.75px no-repeat;
}

#message-composer #upload-button:hover {
  background: hsl(var(--muted)) !important;
  color: hsl(var(--foreground)) !important;
}

.dark #message-composer #upload-button:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: hsl(var(--foreground)) !important;
}

/* Send: filled navy circle. */
#message-composer #chat-submit,
#message-composer #stop-button {
  width: 36px !important;
  height: 36px !important;
  background: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
  box-shadow: var(--vr-shadow);
}

#message-composer #chat-submit:hover,
#message-composer #stop-button:hover {
  background: hsl(var(--primary) / 0.88) !important;
}

#message-composer #chat-submit:disabled {
  opacity: 0.4;
  box-shadow: none;
}

#message-composer #chat-submit svg,
#message-composer #stop-button svg {
  width: 18px;
  height: 18px;
}

/* Watermark under the composer */
.watermark,
a.watermark {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   8. Dialogs, menus, toasts
   -------------------------------------------------------------------------- */
[role="dialog"],
[role="alertdialog"] {
  border-radius: var(--vr-radius-lg) !important;
  border: 1px solid hsl(var(--border));
  box-shadow: var(--vr-shadow-md);
}

[role="dialog"] h2,
[role="alertdialog"] h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

[role="dialog"] input {
  height: 42px;
  border-radius: var(--vr-radius-sm);
}

[role="dialog"] button,
[role="alertdialog"] button {
  height: 40px;
  border-radius: var(--vr-radius-sm);
  font-weight: 500;
}

[role="menu"] {
  padding: 6px;
  border-radius: var(--vr-radius);
  border: 1px solid hsl(var(--border));
  box-shadow: var(--vr-shadow-md);
}

[role="menuitem"] {
  border-radius: var(--vr-radius-sm);
  font-size: 14px;
}

#delete-thread,
#delete-thread svg {
  color: hsl(var(--destructive));
}

[data-sonner-toast] {
  border-radius: var(--vr-radius) !important;
  box-shadow: var(--vr-shadow-md) !important;
}

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  #header {
    height: 52px;
    padding: 0 8px;
  }

  #starters {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  #message-composer {
    padding: 10px 12px 8px;
    border-radius: var(--vr-radius) !important;
  }

  .step .prose table {
    font-size: 13px;
  }

  .step .prose table thead th,
  .step .prose table tbody td {
    padding: 8px 10px;
  }

  .step[data-step-type="user_message"] .bg-accent,
  .step[data-step-type="user_message"] .rounded-3xl {
    max-width: calc(100% - 12px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
