@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Syne:wght@600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f0f;
  --surface:  #141414;
  --sidebar:  #0d0d0d;
  --border:   #222;
  --border-2: #2a2a2a;
  --ink:      #eaeaea;
  --ink-2:    #aaa;
  --ink-3:    #555;
  --accent:   #ff6a1a;
  --accent-2: #ff8a3d;
  --green:    #1aad6e;
  --mono:     'DM Mono', monospace;
  --display:  'Syne', sans-serif;
  --radius:   10px;
}

html, body { height: 100%; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--ink);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── LOGIN ── */
#login-page {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: #181818;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 48px 44px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.login-logo span { color: var(--accent); }

.login-subtitle {
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: #1f1f1f;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 11px 14px;
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}

.form-group input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-family: var(--mono);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}

.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.error-msg {
  margin-top: 12px;
  font-size: .78rem;
  color: var(--accent);
  text-align: center;
  min-height: 1.2em;
}

/* ── DASHBOARD LAYOUT ── */
#dashboard-page {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-user {
  font-size: .7rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section {
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.sidebar-section-title {
  font-size: .6rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 4px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.request-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.request-list::-webkit-scrollbar { width: 3px; }
.request-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.request-item {
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background .12s;
  border-left: 2px solid transparent;
}

.request-item:hover { background: #1a1a1a; }
.request-item.active { background: #1e1410; border-left-color: var(--accent); }

.req-title {
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.req-stage {
  font-size: .65rem;
  color: var(--ink-3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.empty-state, .loading-state {
  font-size: .72rem;
  color: var(--ink-3);
  padding: 10px 4px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#signout-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: .74rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

#signout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  min-width: 0;
}

.main-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  gap: 12px;
  font-size: .85rem;
}

/* ── REQUEST DETAIL ── */
.request-detail {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── DETAIL HEADER ── */
.detail-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.detail-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.meta-chip {
  font-size: .7rem;
  background: #1c1c1c;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 4px 10px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-badge {
  background: #2a1f14;
  color: var(--accent-2);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stage-badge.next { background: #1a2a1a; color: var(--green); }

/* ── CHAT SECTION FULL ── */
.chat-section-full {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── CHAT MESSAGES ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  min-height: 0;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.chat-loading {
  font-size: .75rem;
  color: var(--ink-3);
  text-align: center;
  padding: 20px 0;
}

.msg-wrap {
  display: flex;
  max-width: 70%;
}

.msg-wrap.mine   { align-self: flex-end; flex-direction: row-reverse; }
.msg-wrap.theirs { align-self: flex-start; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .82rem;
  line-height: 1.55;
  word-break: break-word;
  max-width: 100%;
}

.msg-wrap.mine .msg-bubble {
  background: linear-gradient(135deg, #3a2010, #4a2810);
  color: var(--ink);
  border-radius: 14px 14px 3px 14px;
}

.msg-wrap.theirs .msg-bubble {
  background: #1e1e1e;
  border: 1px solid var(--border-2);
  border-radius: 14px 14px 14px 3px;
}

.msg-sender {
  font-size: .63rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.msg-text { white-space: pre-wrap; }

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 5px;
}

.msg-time  { font-size: .6rem; color: var(--ink-3); }
.msg-status { font-size: .62rem; color: rgba(255,255,255,.35); }

.msg-image {
  max-width: 220px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  object-fit: cover;
  transition: opacity .15s;
  margin-bottom: 4px;
}

.msg-image:hover { opacity: .8; }

.msg-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 4px 0;
}

.msg-doc-icon { font-size: 1.3rem; flex-shrink: 0; }

.msg-doc-info { display: flex; flex-direction: column; min-width: 0; }

.msg-doc-name {
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.msg-doc-size { font-size: .65rem; opacity: .55; }
.msg-doc-dl   { font-size: .9rem; flex-shrink: 0; opacity: .5; }

/* ── CHAT INPUT ── */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: #111;
  flex-shrink: 0;
}

.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .72rem;
  color: var(--ink-2);
  background: #1a1a1a;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

.chat-attachment-preview.hidden { display: none; }

.chat-remove-attachment {
  background: none; border: none; cursor: pointer;
  font-size: .72rem; color: var(--ink-3); margin-left: auto; padding: 0 4px;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-attach-btn {
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background .12s;
  flex-shrink: 0;
  line-height: 1;
}

.chat-attach-btn:hover { background: #1a1a1a; }

.chat-text-input {
  flex: 1;
  background: #1b1b1b;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: .84rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}

.chat-text-input:focus { border-color: var(--accent); }
.chat-text-input::placeholder { color: var(--ink-3); }

.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}

.chat-send-btn:hover:not(:disabled) { background: var(--accent-2); }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; }

.chat-upload-bar {
  height: 3px;
  background: var(--border-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.chat-upload-bar.hidden { display: none; }

.chat-upload-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .15s ease;
  border-radius: 2px;
}

/* ── STAGE BAR ── */
.stage-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  border-top: 1px solid var(--border);
  background: #111;
  font-size: .76rem;
  color: var(--ink-2);
  flex-shrink: 0;
}

.stage-label { color: var(--ink-3); }
.arrow { color: var(--ink-3); }

.btn-advance {
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 5px 14px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: .74rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  margin-left: 4px;
}

.btn-advance:hover { border-color: var(--accent); color: var(--accent); }
.btn-advance:disabled { opacity: .4; cursor: not-allowed; }

.no-transition { font-size: .74rem; color: var(--ink-3); font-style: italic; }

/* ── TOAST ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  font-family: var(--mono);
  font-size: .78rem;
  background: #1f1f1f;
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  padding: 11px 16px;
  border-radius: 8px;
  color: var(--ink);
  max-width: 300px;
}

.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: #ff4444; }

/* ── LIGHTBOX ── */
#lightbox { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; }
#lightbox.open { display: flex; }
.lb-bg { position: absolute; inset: 0; background: rgba(0,0,0,.9); }
.lb-inner { position: relative; z-index: 1; }
.lb-inner img { max-width: 90vw; max-height: 88vh; border-radius: 8px; display: block; }
.lb-close {
  position: absolute; top: -34px; right: 0;
  background: none; border: none; color: #fff;
  font-size: 1.1rem; cursor: pointer; opacity: .6;
}
.lb-close:hover { opacity: 1; }