/* css/layout.css — app shells */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--bg-sidebar) 0%, var(--bg-main) 100%);
  padding: 32px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--accent-light);
  border-radius: var(--r-lg);
  padding: 40px;
  box-shadow: var(--shadow-card);
}
.auth-brand-logo {
  display: block;
  text-align: center;
  margin-bottom: 20px;
  text-decoration: none;
}
.auth-brand-logo img {
  height: 44px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  vertical-align: middle;
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-dark);
}
.auth-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .footer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--sidebar-divider);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-section {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--sidebar-divider);
}
.sidebar-section.user-section,
.sidebar-section:last-child {
  border-bottom: none;
  margin-top: auto;
  background: rgba(179, 222, 193, 0.25);
  flex-shrink: 0;
}
.sidebar-section h3 {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0 0 8px;
}
.sidebar-section .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.sidebar-section .section-header h3 {
  margin: 0;
  flex: 1 1 auto;
}
.sidebar-section.scrolling {
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
}
.sidebar-empty {
  padding: 14px 4px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border: 1px dashed var(--accent-light);
  border-radius: var(--r-md);
}

/* Loading placeholder shown inside .sidebar-list while the initial fetch is
   in flight. Replaced by the real list (or .sidebar-empty) once data arrives. */
.sidebar-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 4px;
  color: var(--text-muted);
  font-size: 13px;
}
.sidebar-loading .spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
  border-top-color: var(--accent-primary);
  animation: sidebarSpin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes sidebarSpin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-loading .spinner { animation: none; }
}

/* Account menu: collapsed by default; toggle via .user-section (sidebar-account-menu.js) */
.sidebar-section.account-menu {
  transition: max-height 0.28s ease, opacity 0.22s ease, padding-top 0.28s ease, padding-bottom 0.28s ease,
    margin 0.28s ease;
  max-height: 420px;
  opacity: 1;
  overflow: hidden;
}
.sidebar-section.account-menu.account-menu-collapsed {
  max-height: 0 !important;
  min-height: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  border-bottom-color: transparent;
}
.user-account-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(117, 13, 55, 0.35);
  border-radius: var(--r-md, 8px);
}
.account-menu-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform 0.25s ease;
}
.account-menu-chevron svg {
  width: 18px;
  height: 18px;
}
.user-account-toggle.account-menu-open .account-menu-chevron {
  transform: rotate(180deg);
}

.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow: hidden;
  min-width: 0;
}
.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--accent-light);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}
.chat-header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header .title {
  font-weight: 600;
  color: var(--accent-dark);
  font-size: 16px;
}
.chat-header .subtitle {
  color: var(--text-muted);
  font-size: 12px;
}
.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-input-wrap {
  background: var(--bg-card);
  padding: 14px 24px 18px;
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--accent-light);
  border-radius: var(--r-md);
  padding: 8px 10px;
}
.chat-input-row:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(117, 13, 55, 0.1);
}

/* Row of file chips shown above the composer while attachments are queued. */
.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--accent-light);
  border-radius: 999px;
  font-size: 12px;
  max-width: 280px;
}
.attachment-chip .chip-icon {
  width: 14px; height: 14px; flex: 0 0 14px;
  color: var(--accent-primary);
}
.attachment-chip .chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-chip .chip-size {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.attachment-chip .chip-remove {
  background: none; border: 0; cursor: pointer;
  color: var(--text-secondary);
  padding: 0; margin-left: 2px; display: inline-flex;
}
.attachment-chip .chip-remove:hover { color: var(--accent-dark); }
.attachment-chip .chip-remove i { width: 14px; height: 14px; display: block; }
.attachment-chip.uploading { opacity: 0.7; }
.attachment-chip.error { border-color: #c0392b; color: #c0392b; }

/* Paperclip button inside the composer row. */
.icon-btn.attach-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  flex: 0 0 32px;
  align-self: flex-end;
}
.icon-btn.attach-btn:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.icon-btn.attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.icon-btn.attach-btn i { width: 18px; height: 18px; display: block; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 24px;
  gap: 12px;
  flex: 1;
}
.empty-state h2 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 20px;
}
.empty-state p { margin: 0; max-width: 420px; }

.banner {
  margin: 0 24px 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #fff0f0;
  border: 1px solid var(--dot-red);
  color: #8a2323;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.chat-header .banner {
  margin: 0;
  padding: 8px 10px;
}
.banner button {
  margin-left: 0;
}
#deleteSiteBtn {
  margin-left: auto;
}
#reconnectBtn {
  margin-left: 8px;
}

/* Ensure the [hidden] HTML attribute always wins over display:flex etc. */
[hidden] { display: none !important; }

/* Team collaborators: same Account nav markup as owners, but hide entries they cannot use (see nav-owner-only). */
html.is-team-member .nav-owner-only {
  display: none !important;
}
