:root{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --border:#e5e7eb;
  --bgg:#2563eb;
  --bgg-600:#1d4ed8;
  --shadow:0 6px 20px rgba(17,24,39,0.06);
  --radius:14px;
}

*{
  box-sizing:border-box;
}

html,body{
  margin:0;
  padding:0;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Inter,Helvetica,Arial,sans-serif;
  color:var(--text);
  background:var(--bg);
}

img{
  display:block;
  max-width:100%;
}

a{
  color:inherit;
  text-decoration:none;
}

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

.app{
  display:grid;
  grid-template-columns:260px 1fr;
  min-height:100vh;
}

.sidebar{
  background:#ffffff;
  border-right:1px solid var(--border);
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:6px 4px;
}

.brand .title{
  font-weight:800;
  letter-spacing:.2px;
}

.brand .subtitle{
  font-size:12px;
  color:var(--muted);
}

.globe{
  width:28px;
  height:28px;
}

/* ===== Navigation ===== */

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.nav-item{
  padding:10px 12px;
  border-radius:10px;
  color:#111827;
  border:1px solid transparent;
}

.nav-item:hover{
  background:#f3f4f6;
  border-color:var(--border);
}

.nav-item.active{
  background:#eff6ff;
  border-color:#dbeafe;
  color:var(--bgg);
  font-weight:700;
}

.divider{
  height:1px;
  background:var(--border);
  margin:8px 0;
}

/* sub-nav (role-based) */

.sub-nav-item{
  padding:6px 14px 6px 28px;
  font-size:14px;
  font-weight:400;
  color:#4d4d4d;
  cursor:pointer;
  display:flex;
  align-items:center;
  border-radius:10px;
}

.sub-nav-item::before{
  content:"•";
  margin-right:8px;
  color:#a5a5a5;
  font-size:10px;
  position:relative;
  top:-1px;
}

.sub-nav-item:hover{
  background:#f6f6fc;
  border-left:3px solid #4c6fff;
  box-shadow:inset 0 0 3px rgba(0,0,0,0.05);
}

/* ===== Main area ===== */

.main{
  display:flex;
  flex-direction:column;
}

.header{
  background:var(--panel);
  border-bottom:1px solid var(--border);
  padding:12px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  box-shadow:var(--shadow);
}

.header-left h1{
  font-size:18px;
  margin:0 0 2px 0;
}

.subtext{
  margin:0;
  color:var(--muted);
  font-size:12px;
}

.header-right{
  display:flex;
  align-items:center;
  gap:10px;
}

/* ===== Controls (language, buttons) ===== */

.lang-select{
  appearance:none;
  background:#fff;
  border:1px solid var(--border);
  border-radius:10px;
  padding:8px 10px;
  color:#111827;
}

.btn{
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  padding:9px 14px;
  cursor:pointer;
}

.btn:hover{
  box-shadow:0 4px 12px rgba(0,0,0,.06);
}

.btn.primary{
  background:var(--bgg);
  border-color:var(--bgg);
  color:#fff;
}

.btn.primary:hover{
  background:var(--bgg-600);
}

.btn.login{
  background:var(--bgg);
  border-color:var(--bgg);
  color:#fff;
  font-weight:600;
}

/* keep login button always clickable / on top */
#loginBtn{
  position:relative;
  z-index:9999;
  pointer-events:auto;
}

/* ===== Profile chip + dropdown ===== */

/* Profile container (we already hide/show with .show) */
.profile{
  display:none;
  visibility:hidden;
  pointer-events:none;
  align-items:center;
  gap:8px;
  position:relative;
  cursor:pointer;
}

.profile.show{
  display:flex;
  visibility:visible;
  pointer-events:auto;
}

/* Avatar-circle for user initials */
.profile-avatar{
  width:28px;
  height:28px;
  border-radius:999px;
  background:linear-gradient(135deg,#2563eb,#60a5fa);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:700;
  flex-shrink:0;
}

.profile-avatar .initials{
  text-transform:uppercase;
}

/* Text block */
.profile-info{
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.profile-info .name{
  font-size:14px;
  font-weight:600;
  color:var(--text);
}

.profile-info .meta-line{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  color:var(--muted);
}

/* Email text */
.profile-info .email{
  max-width:180px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* Role pill */
.profile-info .role-pill{
  padding:2px 6px;
  border-radius:999px;
  border:1px solid #dbeafe;
  background:#eff6ff;
  color:#1d4ed8;
  font-size:10px;
  font-weight:500;
}

/* Dropdown (only small tweak to use .dropdown.open which JS toggles) */
.profile .dropdown{
  position:absolute;
  top:38px;
  right:0;
  background:#fff;
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow:var(--shadow);
  min-width:160px;
  z-index:20;
  display:none;
  flex-direction:column;
}

.profile .dropdown.open{
  display:flex;
}

/* ===== Content / chat ===== */

.content{
  padding:16px;
  display:grid;
  grid-template-rows:auto 1fr auto;
  gap:10px;
  min-height:0;
}

.chat-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  box-shadow:var(--shadow);
}

.chat-title{
  font-weight:700;
}

.model-badge{
  font-size:12px;
  color:#1f2937;
  background:#eff6ff;
  border:1px solid #dbeafe;
  border-radius:999px;
  padding:4px 8px;
}

.chat{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow:var(--shadow);
  overflow:auto;
  min-height:320px;
}

.msg{
  display:flex;
  gap:10px;
  margin-bottom:12px;
}

.msg .bubble{
  background:#f9fafb;
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  max-width:900px;
}

.msg.you{
  justify-content:flex-end;
}

.msg.you .bubble{
  background:#ecfeff;
  border-color:#cffafe;
}

.avatar-chip{
  width:28px;
  height:28px;
  border-radius:8px;
  background:linear-gradient(135deg,#2563eb,#60a5fa);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:800;
  flex:0 0 auto;
}

.meta{
  font-size:11px;
  color:var(--muted);
  margin-bottom:6px;
}

.text{
  font-size:14px;
  line-height:1.55;
}

.dim{
  color:#9ca3af;
  font-size:12px;
}

.composer{
  display:flex;
  gap:10px;
  align-items:center;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 8px;
  box-shadow:var(--shadow);
}

.input{
  flex:1;
  border:none;
  outline:none;
  background:transparent;
  padding:10px;
  border-radius:8px;
}

.input::placeholder{
  color:#9ca3af;
}

/* ===== Responsive ===== */

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }

  /* Show mobile menu button */
  .mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    z-index: 50;
    background: #ffffff;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out, box-shadow 0.22s ease-out;
    box-shadow: none;
  }

  /* When open */
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 18px rgba(15, 23, 42, 0.28);
  }

  /* Make nav scrollable on small screen */
  .sidebar .nav {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  /* Content shifts underneath fixed header */
  .main {
    margin-left: 0;
  }

  .brand .subtitle {
    display: none;
  }
}

@media (max-width: 600px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chat {
    min-height: 260px;
    padding: 12px;
  }

  .composer {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .composer .btn {
    width: 100%;
    text-align: center;
  }
}

.composer-footer{
  margin-top:4px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:11px;
  color:var(--muted);
}

.composer-footer-left{
  display:flex;
  align-items:center;
  gap:6px;
}

.model-label{
  font-size:11px;
  color:var(--muted);
}

.model-select{
  appearance:none;
  background:#fff;
  border:1px solid var(--border);
  border-radius:999px;
  padding:4px 8px;
  font-size:11px;
  color:#111827;
}

.composer-footer-right{
  text-align:right;
  max-width:auto;
}

.composer-hint{
  font-size:11px;
  color:var(--muted);
}

/* Project / Topic bar above chat */
.project-topic-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.project-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0; /* allow shrinking on smaller screens */
}

.project-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.project-select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  max-width: 220px;
  min-width: 140px;
}

/* === Project / Topic panel (elegant sidebar card) === */

/* Card container inside sidebar */
.sidebar .project-topic-bar {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Optional subtle header line inside the card */
.sidebar .project-topic-bar::before {
  content: "Workspace";
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Project row */
.sidebar .project-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar .project-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar .project-select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}

/* Topic row */
.sidebar .topic-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.sidebar .topic-label {
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar .topic-title {
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.btn.newchat {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--bgg);
  font-weight: 600;
  padding: 9px 14px;
}

.btn.newchat:hover {
  background: #f0f4ff;
  border-color: #bcd4ff;
}

/* Smaller buttons for + / New inside the card */
.sidebar .btn.small {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 999px;
  border-color: #dbeafe;
  background: #eff6ff;
}

/* On hover make them a bit more vivid */
.sidebar .btn.small:hover {
  background: #dbeafe;
}

.mobile-only {
  display: none;
}

.icon-btn {
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.icon-btn:hover {
  background: #e5e7eb;
}
