/* ===== Weylo Global Styles ===== */

:root {
  --primary: #111111;
  --on-primary: #ffffff;
  --accent: #2563eb;
  --surface: #ffffff;
  --page-bg: #f5f6f8;
  --side-w: 248px;
  --side-w-collapsed: 64px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #111;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Layout ===== */

.app {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: var(--side-w);
  background: var(--primary);
  color: var(--on-primary);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0.75rem;
  transition: width 0.2s ease;
}
.sidebar.collapsed {
  width: var(--side-w-collapsed);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 1rem;
  font-weight: 800;
}
.side-brand a {
  color: var(--on-primary);
  text-decoration: none;
}
.side-logo {
  height: 28px;
  width: auto;
  border-radius: 4px;
}

.tog {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--on-primary);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

.nav-section {
  margin-top: 0.75rem;
}
.nav-h {
  font-size: 0.8rem;
  opacity: 0.75;
  margin: 0.5rem 0 0.25rem;
  font-weight: 700;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  color: var(--on-primary);
  text-decoration: none;
  opacity: 0.95;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
}
.nav-link.active {
  background: var(--on-primary);
  color: var(--primary);
  border-color: var(--on-primary);
  font-weight: 700;
}
.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-h,
.sidebar.collapsed .brand-text {
  display: none;
}

.content {
  flex: 1;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Flash Messages ===== */

.flash {
  padding: 0.8rem 1rem;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}
.flash.success {
  background: #e8f7ee;
  color: #0f5132;
  border: 1px solid #badbcc;
}
.flash.danger {
  background: #fde2e1;
  color: #842029;
  border: 1px solid #f5c2c7;
}
.flash.warning {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
}
.flash.info {
  background: #e7f1ff;
  color: #084298;
  border: 1px solid #b6d4fe;
}

/* ===== Cards ===== */

.card {
  background: var(--surface);
  border-radius: 0.8rem;
  padding: 1rem;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.06);
}

/* ===== Footer ===== */

footer {
  opacity: 0.7;
  font-size: 0.85rem;
  margin: 2rem 0;
  text-align: center;
}

/* ===== Weylo Scrollbar Enhancements ===== */

/* Keep page layout stable and prevent scrollbar overlap */
html, body {
  overflow: hidden; /* Prevent global scroll */
  height: 100%;
  scrollbar-gutter: stable;
}

/* Sidebar that contains chat list */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  overflow: hidden;
}

/* Only the Last 15 section should scroll */
.chat-list {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-right: 8px;
}

/* Main chat content area scrolls separately */
.chat-content, .thread {
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-right: 12px;
}

/* Smooth thin scrollbars (modern, clean look) */
.chat-list::-webkit-scrollbar,
.chat-content::-webkit-scrollbar,
.thread::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-thumb,
.chat-content::-webkit-scrollbar-thumb,
.thread::-webkit-scrollbar-thumb {
  background: #b5b5b5;
  border-radius: 6px;
}
.chat-list::-webkit-scrollbar-thumb:hover,
.chat-content::-webkit-scrollbar-thumb:hover,
.thread::-webkit-scrollbar-thumb:hover {
  background: #888;
}
.chat-list::-webkit-scrollbar-track,
.chat-content::-webkit-scrollbar-track,
.thread::-webkit-scrollbar-track {
  background: transparent;
}

/* Momentum scrolling for touch devices */
.chat-list,
.chat-content,
.thread {
  -webkit-overflow-scrolling: touch;
}

/* ===== Fix for 'Last 15 Chats' Scrolling ===== */

/* Ensure the chat sidebar layout behaves as a column */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  overflow: hidden;
}

/* The header ("New Chat", "Load Last 15", etc.) stays static */
.chat-sidebar-header {
  flex-shrink: 0;
}

/* The list itself scrolls within the remaining height */
.chat-list {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-right: 8px;
}

/* Hide global scroll so the chat list controls scrolling */
html, body {
  height: 100%;
  overflow: hidden;
}

/* Thin modern scrollbar styling */
.chat-list::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-thumb {
  background: #b5b5b5;
  border-radius: 6px;
}
.chat-list::-webkit-scrollbar-thumb:hover {
  background: #888;
}
.chat-list::-webkit-scrollbar-track {
  background: transparent;
}
