/* ============================================================
   LEXLY — Design System
   Dark, premium, minimalist. Linear-adjacent.
   ============================================================ */

:root {
  /* Core palette */
  --bg:        #0A0A0F;
  --bg-2:      #0c0c12;
  --surface:   #13131A;
  --surface-2: #17171f;
  --surface-3: #1c1c26;

  /* Violet accent ramp */
  --violet:        #7C3AED;
  --violet-bright: #8B5CF6;
  --violet-soft:   #a78bfa;
  --violet-dim:    rgba(124, 58, 237, 0.14);
  --violet-line:   rgba(124, 58, 237, 0.34);

  /* Text */
  --white:    #F8F8FF;
  --text:     #EDEDF2;
  --text-2:   #a9a9b8;
  --text-3:   #6c6c7c;
  --text-4:   #4a4a57;

  /* Lines */
  --line:    rgba(255, 255, 255, 0.07);
  --line-2:  rgba(255, 255, 255, 0.11);
  --line-3:  rgba(255, 255, 255, 0.16);

  /* Status */
  --green:  #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --amber:  #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --red:    #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);

  --shadow-lg: 0 24px 60px -12px rgba(0,0,0,0.6);
  --shadow-md: 0 8px 30px -8px rgba(0,0,0,0.5);

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --sidebar-w: 256px;
  --header-h:  64px;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'Newsreader', Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-feature-settings: 'cv05' 1, 'ss01' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

::selection { background: var(--violet); color: white; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); background-clip: padding-box; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  background:
    radial-gradient(1100px 600px at 78% -8%, rgba(124,58,237,0.10), transparent 60%),
    var(--bg);
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 30%), var(--bg-2);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--violet-bright), var(--violet));
  box-shadow: 0 6px 18px -4px rgba(124,58,237,0.6), inset 0 1px 0 rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.brand-name {
  font-size: 19px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--white);
}
.brand-name b { color: var(--violet-soft); font-weight: 600; }
.brand-sub {
  font-size: 10.5px; color: var(--text-3); letter-spacing: 0.04em;
  text-transform: uppercase; margin-top: 1px; font-weight: 500; white-space: nowrap;
}

.nav-group-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-4);
  padding: 14px 10px 7px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  position: relative;
  transition: background .15s, color .15s;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item .ic { color: var(--text-3); transition: color .15s; flex-shrink: 0; }
.nav-item:hover .ic { color: var(--text-2); }
.nav-item.active {
  background: var(--violet-dim);
  color: var(--white);
}
.nav-item.active .ic { color: var(--violet-soft); }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: var(--violet-bright);
}
.nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  background: var(--red); color: white;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; display: grid; place-items: center;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; }
.upsell {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 13px;
  background: linear-gradient(160deg, var(--violet-dim), transparent);
}
.upsell h4 { font-size: 12.5px; font-weight: 600; color: var(--white); margin-bottom: 3px; }
.upsell p { font-size: 11.5px; color: var(--text-2); line-height: 1.45; margin-bottom: 11px; }
.upsell button {
  width: 100%; padding: 7px; border-radius: 8px;
  background: var(--white); color: #16121f; font-size: 12px; font-weight: 600;
  transition: transform .12s;
}
.upsell button:hover { transform: translateY(-1px); }

/* ---------- Main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; }

.header {
  height: var(--header-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 26px;
  gap: 16px;
  background: rgba(10,10,15,0.6);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 1000;
}
.header-title { min-width: 0; }
.header-title h1 {
  font-size: 15px; font-weight: 600; color: var(--white); letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px;
}
.header-title p { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.plan-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 9px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: linear-gradient(180deg, rgba(124,58,237,0.22), rgba(124,58,237,0.12));
  border: 1px solid var(--violet-line);
  color: var(--violet-soft);
}
.plan-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--violet-bright); box-shadow: 0 0 8px var(--violet-bright); }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 4px 4px 11px;
  border-radius: 22px;
  border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.user-chip:hover { border-color: var(--line-2); background: rgba(255,255,255,0.02); }
.user-chip .uname { font-size: 12.5px; font-weight: 500; color: var(--text); }
.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(150deg, #3a3a4a, #23232e);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--text);
  border: 1px solid var(--line-2);
}

.content { flex: 1; min-height: 0; overflow-y: auto; position: relative; }

/* Mobile top bar (hidden on desktop) */
.mobile-bar { display: none; }

/* ============================================================
   Reusable bits
   ============================================================ */
.lex-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(155deg, #1f1830, #15121d);
  border: 1px solid var(--violet-line);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: transform .12s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary {
  background: linear-gradient(180deg, var(--violet-bright), var(--violet));
  color: white;
  box-shadow: 0 6px 20px -6px rgba(124,58,237,0.7), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover { box-shadow: 0 8px 26px -6px rgba(124,58,237,0.85), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--line-3); }

.section-pad { padding: 26px 30px 40px; max-width: 980px; margin: 0 auto; }

.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--violet-soft); margin-bottom: 8px;
}
.h-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: var(--white); }
.h-sub { font-size: 14px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 7px;
}
.field label .opt { color: var(--text-3); font-weight: 400; }
.input, .textarea, .select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13.5px; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--violet-line);
  box-shadow: 0 0 0 3px var(--violet-dim);
}
.textarea { resize: vertical; line-height: 1.6; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236c6c7c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.footer-disclaimer {
  text-align: center;
  font-size: 11px; color: var(--text-4);
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* Spinner */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: white;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Typing dots */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--violet-soft);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .35s cubic-bezier(.2,.7,.3,1); }
@media (prefers-reduced-motion: reduce) {
  .fade-up, .auth-overlay, .auth-card, .msg-row, .user-menu { animation: none !important; }
}

/* ============================================================
   Responsive
   ============================================================ */
.scrim { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 280px;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.3,.7,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .app.menu-open .sidebar { transform: none; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 15;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .app.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    height: 56px; flex-shrink: 0;
    padding: 0 16px; border-bottom: 1px solid var(--line);
    background: var(--bg-2);
  }
  .mobile-bar .brand-name { font-size: 17px; }
  .menu-btn { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; border: 1px solid var(--line-2); color: var(--text); }
  .header { padding: 0 16px; }
  .header-title p { display: none; }
  .user-chip .uname { display: none; }
  .section-pad { padding: 20px 16px 32px; }
}
