/* ── PALLETS SHELL ──
   Styles for the app chrome: auth screen, topbar,
   sidebar, modals, avatar menu, and shared buttons.
   Depends on: base.css (variables must be loaded first)
   ───────────────────────────────────────────────── */

/* ── AUTH SCREEN ── */
/* Display is controlled via inline styles by shell.js */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--shell-bg);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-card {
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-lg);
  width: 360px;
  padding: 2rem;
}

.auth-wordmark {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-on-shell);
  opacity: 0.6;
  margin-bottom: 2rem;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-on-shell);
  margin-bottom: 0.4rem;
}

.auth-sub {
  font-size: 12px;
  color: var(--text-on-shell-2);
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.auth-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-on-shell-2);
}

.auth-input {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--shell-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-on-shell);
  outline: none;
  width: 100%;
  transition: border-color var(--transition-fast);
}

.auth-input:focus { border-color: rgba(240, 95, 0, 0.5); }
.auth-input::placeholder { color: var(--text-on-shell-2); }

.auth-btn {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background var(--transition-fast);
}

.auth-btn:hover { background: var(--accent-hover); }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--shell-border);
  color: var(--text-on-shell);
}

.auth-btn.secondary:hover { background: rgba(255, 255, 255, 0.1); }

.auth-switch {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 12px;
  color: var(--text-on-shell-2);
}

.auth-switch a { color: var(--accent); cursor: pointer; }

.auth-error {
  background: rgba(192, 57, 43, 0.12);
  border: 1px solid rgba(192, 57, 43, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: #e74c3c;
  margin-bottom: 1rem;
  display: none;
  line-height: 1.4;
}

.auth-error.show { display: block; }

.auth-success {
  background: rgba(46, 125, 79, 0.12);
  border: 1px solid rgba(46, 125, 79, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: #2e7d4f;
  margin-bottom: 1rem;
  display: none;
  line-height: 1.4;
}

.auth-success.show { display: block; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.auth-divider-line { flex: 1; height: 1px; background: var(--shell-border); }
.auth-divider-text { font-size: 10px; color: var(--text-on-shell-2); }

.auth-magic-box {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(240, 95, 0, 0.08);
  border: 1px solid rgba(240, 95, 0, 0.2);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-on-shell-2);
  line-height: 1.6;
}

/* ── TOPBAR ── */
.topbar {
  grid-column: 1 / -1;
  background: var(--shell-bg);
  border-bottom: 1px solid var(--shell-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 10;
}

.wordmark {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--text-on-shell);
  opacity: 0.85;
  text-transform: uppercase;
  flex-shrink: 0;
}

.topbar-divider { width: 1px; height: 18px; background: var(--shell-border); }

.topbar-project-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-on-shell);
}

.topbar-project-type {
  font-size: 11px;
  color: var(--text-on-shell-2);
  margin-left: 0.4rem;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-on-shell-2);
  background: none;
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.topbar-btn span { position: relative; z-index: 1; pointer-events: none; }
.topbar-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.save-indicator {
  font-size: 10px;
  color: var(--text-on-shell-2);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-indicator.show { opacity: 1; }

/* ── AVATAR & DROPDOWN ── */
.avatar-wrap { position: relative; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-text);
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}

.avatar-menu {
  position: absolute;
  top: 36px;
  right: 0;
  background: var(--modal-dark-bg);
  border: 1px solid var(--modal-dark-border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  min-width: 200px;
  display: none;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.avatar-menu.open { display: block; animation: fadeIn 0.12s ease; }

.avatar-menu-user {
  padding: 0.5rem 0.75rem 0.75rem;
  border-bottom: 1px solid var(--modal-dark-border);
  margin-bottom: 0.4rem;
}

.avatar-menu-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-on-shell);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-menu-email {
  font-size: 10px;
  color: var(--text-on-shell-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-menu-role {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-top: 0.3rem;
}

.avatar-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 12px;
  color: var(--text-on-shell-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

.avatar-menu-item:hover { background: rgba(245, 239, 230, 0.06); color: var(--text-on-shell); }
.avatar-menu-item.danger:hover { background: rgba(192, 57, 43, 0.12); color: #e74c3c; }
.avatar-menu-divider { height: 1px; background: var(--modal-dark-border); margin: 0.4rem 0; }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--shell-bg);
  border-right: 1px solid var(--shell-border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-on-shell-2);
  padding: 0 1rem;
  margin-bottom: 0.4rem;
  margin-top: 1.25rem;
}

.sidebar-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-on-shell-2);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color var(--transition-fast), background var(--transition-fast);
  user-select: none;
}

.nav-item:hover { color: var(--text-on-shell); background: rgba(245, 239, 230, 0.04); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(240, 95, 0, 0.07); }
.nav-icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--shell-border);
}

.sidebar-footer-text { font-size: 10px; color: var(--text-on-shell-2); line-height: 1.6; }

/* Hidden everywhere by default — only shown on mobile when .active is added */
.sidebar-backdrop { display: none; }

/* ── MAIN CONTENT AREA ── */
.main {
  background: var(--ws-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  grid-column: 2;
  grid-row: 2;
}

.tabbar {
  background: var(--ws-surface);
  border-bottom: 1px solid var(--ws-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0;
  flex-shrink: 0;
}

.tab {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-on-ws-2);
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast);
  letter-spacing: 0.03em;
  user-select: none;
}

.tab:hover { color: var(--text-on-ws); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.tabbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

.tab-action-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-on-ws-2);
  background: none;
  border: 1px solid var(--ws-border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tab-action-btn span { position: relative; z-index: 1; pointer-events: none; }
.tab-action-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }

.content { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; position: relative; }
.content-panel { display: none; flex: 1; overflow: hidden; min-height: 0; }
.content-panel.active { display: flex; }

/* ── SHARED MODAL BASE ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.75);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--modal-dark-bg);
  border: 1px solid var(--modal-dark-border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.15s ease;
}

.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--modal-dark-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text-on-shell); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-on-shell-2);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover { color: var(--text-on-shell); }

.modal-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.modal-section { display: flex; flex-direction: column; gap: 0.6rem; }
.modal-section-label { font-size: 9px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-on-shell-2); }
.modal-section-desc { font-size: 11px; color: var(--text-on-shell-2); line-height: 1.5; }
.modal-divider { height: 1px; background: var(--modal-dark-border); }

.modal-input {
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--modal-dark-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-on-shell);
  outline: none;
  width: 100%;
  transition: border-color var(--transition-fast);
}

.modal-input:focus { border-color: rgba(240, 95, 0, 0.5); }
.modal-input::placeholder { color: var(--text-on-shell-2); }
.modal-row { display: flex; gap: 0.5rem; }

.modal-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--modal-dark-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-on-shell);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: background var(--transition-fast);
}

.modal-btn span { position: relative; z-index: 1; pointer-events: none; }
.modal-btn:hover { background: rgba(255, 255, 255, 0.1); }
.modal-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal-btn.accent:hover { background: var(--accent-hover); }
.modal-btn.danger { border-color: rgba(192, 57, 43, 0.4); color: #e74c3c; }
.modal-btn.danger:hover { background: rgba(192, 57, 43, 0.15); }
.modal-btn.full { width: 100%; text-align: center; }

.modal-danger-message {
  font-size: 13px; color: var(--text-on-shell-2); line-height: 1.6;
  padding: 0.75rem 1rem;
  background: rgba(192,57,43,0.08); border: 1px solid rgba(192,57,43,0.2);
  border-radius: var(--radius-sm);
}
.modal-danger-message strong { color: var(--text-on-shell); font-weight: 600; }
.modal-btn-row { display: flex; gap: 0.5rem; }

/* ── COPY LINK ROW ── */
.copy-link-row { display: flex; gap: 0.5rem; align-items: center; }
.copy-link-input {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--modal-dark-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-on-shell-2);
  outline: none;
}

/* ── ROLE SELECT ── */
.role-select {
  font-family: var(--font-ui);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--modal-dark-border);
  border-radius: var(--radius-sm);
  color: var(--text-on-shell);
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.role-select:focus { border-color: rgba(240, 95, 0, 0.5); }

/* ── TEAM MEMBERS ── */
.team-members-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.team-member { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }

.team-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid transparent;
  transition: border-color var(--transition-fast);
}

.team-member-name { font-size: 9px; color: var(--text-on-shell-2); text-align: center; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-member-role { font-size: 8px; color: var(--accent-text); text-align: center; }
.team-empty { font-size: 12px; color: var(--text-on-shell-2); padding: 0.5rem 0; }

/* ── TEAM LIST (manage modal) ── */
.team-list-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--modal-dark-border);
}

.team-list-row:last-child { border-bottom: none; }

.team-list-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.team-list-info { flex: 1; min-width: 0; }
.team-list-name { font-size: 12px; font-weight: 500; color: var(--text-on-shell); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-list-email { font-size: 10px; color: var(--text-on-shell-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.team-list-you {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-on-shell-2);
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border: 1px solid var(--shell-border);
  border-radius: 3px;
}

.team-list-remove {
  background: none;
  border: none;
  color: var(--text-on-shell-2);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.team-list-remove:hover { color: #e74c3c; }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {

  /* Auth */
  .auth-card { width: calc(100vw - 2rem); max-width: 360px; padding: 1.5rem; }

  /* App grid — stack topbar + full-width main, no sidebar */
  .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: var(--topbar-height) 1fr;
  }

  /* Topbar */
  .topbar { padding: 0 1rem; gap: 0.6rem; }
  .topbar-project-type { display: none; }
  .topbar-project-name { font-size: 12px; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Sidebar — becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: 220px;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .sidebar.mobile-open { transform: translateX(0); }

  /* Sidebar backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0,0,0,0.5);
    z-index: 79;
  }
  .sidebar-backdrop.active { display: block; }

  /* Main takes full width */
  .main { grid-column: 1; }
  .app.no-sidebar .main { grid-column: 1; }

  /* Hamburger menu button — shown only on mobile */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-on-shell-2);
    flex-shrink: 0;
  }

  /* Tabbar — horizontal scroll on small screens */
  .tabbar { padding: 0 0.75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabbar-right { gap: 0.35rem; }
  .tab { padding: 0.75rem 0.75rem; font-size: 11px; white-space: nowrap; }
  .tab-action-btn { padding: 4px 9px; font-size: 10px; white-space: nowrap; }

  /* Modal */
  .modal { width: calc(100vw - 2rem); max-width: 480px; }

  /* Script panel */
  .script-scroll { padding: 1rem 0.5rem; }
  .screenplay-page { width: 100%; min-width: 0; padding: 1.5rem 1.25rem 1.5rem 1.5rem; font-size: 11px; }
  .se-character { margin-left: 80px; }
  .se-parenthetical { margin-left: 60px; margin-right: 20px; }
  .se-dialogue { margin-left: 50px; margin-right: 20px; }

  /* Quick breakdown sidebar — hidden on mobile, accessible via tab */
  .quick-breakdown { display: none; }
  .script-layout { flex-direction: column; }

  /* Boards layout */
  .boards-layout { flex-direction: column; }
  .boards-scene-list { width: 100%; max-height: 140px; overflow-x: auto; overflow-y: hidden; display: flex; flex-direction: row; border-right: none; border-bottom: 1px solid var(--ws-border); }
  .boards-scene-item { min-width: 140px; border-bottom: none; border-right: 1px solid var(--ws-border); }

  /* Lightbox */
  .lightbox { flex-direction: column; width: 100%; max-height: 90vh; }
  .lb-frame-col { width: 100%; height: 200px; flex-shrink: 0; }
  .lb-detail-col { flex: 1; overflow-y: auto; }

  /* Diff overlay */
  .diff-header { flex-direction: column; gap: 0.75rem; }
  .diff-header-right { flex-wrap: wrap; }
  .diff-script { padding: 1rem; font-size: 11px; }
  .diff-line.diff-type-character { padding-left: 60px; }
  .diff-line.diff-type-parenthetical { padding-left: 40px; }
  .diff-line.diff-type-dialogue { padding-left: 30px; }
}

/* Desktop — hide mobile-only elements */
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
  .sidebar-backdrop { display: none !important; }
}
