/* ============================================================
   Eddys Development — Workspace (post-login) styles
   Builds on styles.css (palette, bg layers, .card, .btn) +
   support.css (the support form fields/button).

   Layout: a wide "bento" dashboard — full-width hero strip, a
   horizontal KPI band, then a 2-column grid (invoices + live chat
   rail). Replaces the old single 600px centered column.
   ============================================================ */

/* The hidden attribute must always beat display:flex/grid rules below. */
[hidden] { display: none !important; }

/* Shell: wide, top-aligned (not the centered auth stage) */
.dash-page { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.dash-shell { width: min(1200px, 100%); margin: 0 auto; padding: clamp(20px, 4vw, 40px) clamp(16px, 3vw, 28px) 64px; }

/* Topbar */
.dash-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dash-brand { text-decoration: none; }
.dash-signout { margin-top: 0; width: auto; height: 40px; padding: 0 16px; font-size: 14px; }

/* Cards fill their slot (override styles.css's fixed auth-card width),
   and drop the auth card's cursor spotlight for clean static panels. */
.dash-card { width: auto; min-width: 0; }
.dash-card::before, .dash-card::after { content: none; }

/* Shared panel header (eyebrow + heading on the left, badge on the right) */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 3px; font: 600 11.5px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--violet); }
.dash-h2 { font-family: var(--font-display); font-weight: 700; font-size: 23px; color: var(--text); margin: 4px 0 0; }

/* ============================================================
   HERO STRIP — greeting on the left, account chips on the right
   ============================================================ */
.dash-hero-card {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: clamp(18px, 3vw, 36px); margin-bottom: 18px;
}
.hero-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber), var(--ember));
  box-shadow: 0 8px 20px rgba(226, 85, 43, .42), inset 0 1px 0 rgba(255, 255, 255, .25);
  font-family: var(--font-display); font-size: 26px; font-weight: 700; color: #fff; text-transform: uppercase;
}
.hero-id-text { min-width: 0; }
.dash-hero-card .title { margin: 0; font-size: clamp(24px, 4vw, 30px); line-height: 1.12; }
#userName { color: var(--text); }
.hero-sub { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; max-width: 48ch; }

.hero-chips { display: flex; gap: 10px; margin: 0; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 15px; min-width: 0;
  border: 1px solid var(--border); border-radius: 13px; background: var(--field-bg);
}
.chip dt { margin: 0; font: 600 10.5px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.chip dd { margin: 0; font: 600 14px var(--font-ui); color: var(--text); word-break: break-word; }

/* ============================================================
   KPI BAND — three tiles, horizontal (filled from real invoices)
   ============================================================ */
.dash-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden; display: grid; gap: 7px; padding: 18px 18px 16px;
  border: 1px solid var(--border); border-radius: 15px;
  background: linear-gradient(180deg, rgba(245, 165, 36, .05), rgba(245, 165, 36, 0) 60%), var(--glass-fill);
  transition: border-color .2s var(--ease-soft), background .2s var(--ease-soft);
}
.stat:hover { border-color: var(--border-strong); }
.stat-ico {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  color: var(--amber); background: rgba(245, 165, 36, .12); border: 1px solid rgba(245, 165, 36, .18);
}
.stat-ico svg { width: 19px; height: 19px; }
.stat-val { font-family: var(--font-display); font-weight: 700; font-size: clamp(23px, 3.2vw, 31px); line-height: 1; color: var(--text); letter-spacing: -.01em; }
.stat-key { font: 600 11.5px var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
/* The headline tile (Total advanced) gets the ember treatment */
.stat-accent { background: linear-gradient(180deg, rgba(245, 165, 36, .12), rgba(226, 85, 43, .04) 70%), var(--glass-fill); border-color: var(--border-strong); }
.stat-accent .stat-ico { color: #fff; background: linear-gradient(135deg, var(--amber), var(--ember)); border-color: transparent; box-shadow: 0 6px 16px rgba(226, 85, 43, .35); }

/* ============================================================
   BENTO GRID — invoices (main) + chat (rail)
   ============================================================ */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, .95fr); gap: 18px; align-items: stretch; }
.dash-grid .dash-card { margin: 0; }

.dash-invoices .sub { margin: 10px 0 14px; }

/* ============================================================
   SUPPORT CHAT (right rail — fills the column height on desktop)
   ============================================================ */
.dash-chat { display: flex; flex-direction: column; min-height: clamp(520px, 62vh, 720px); }
.dash-chat .sub { margin: 10px 0 16px; }
.chat-live {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  font: 600 11px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--field-bg);
}
.chat-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: livePulse 1.9s ease-out infinite; }
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70%  { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-thread {
  display: flex; flex-direction: column; gap: 10px; flex: 1;
  min-height: 120px; max-height: none; overflow-y: auto;
  padding: 4px 4px 6px 2px; margin-bottom: 14px;
}
.chat-empty { margin: auto; padding: 34px 0; color: var(--faint); font-size: 14px; text-align: center; }

.bubble { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble-time { display: block; margin-top: 4px; font: 500 10.5px var(--font-mono); opacity: .7; }
.bubble.from-client { align-self: flex-end; background: linear-gradient(135deg, var(--violet-600), var(--violet-700)); color: #fff; border-bottom-right-radius: 5px; }
.bubble.from-studio { align-self: flex-start; background: rgba(255, 255, 255, .06); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 5px; }
.bubble.from-studio .bubble-time { color: var(--faint); }

.chat-input { display: flex; align-items: flex-end; gap: 8px; }
.chat-input textarea {
  flex: 1; resize: none; max-height: 120px; box-sizing: border-box;
  background: rgba(30, 20, 12, .6); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font: 400 15px var(--font-ui); padding: 12px 14px; outline: none; line-height: 1.45;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input textarea:focus { border-color: var(--border-hover); box-shadow: 0 0 0 3px var(--ring); }
.chat-input textarea::placeholder { color: var(--faint); }
.chat-send {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center;
  border: 0; border-radius: 12px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--amber), var(--ember)); box-shadow: 0 6px 16px rgba(226, 85, 43, .4);
  transition: filter .15s, transform .1s;
}
.chat-send:hover { filter: brightness(1.06); }
.chat-send:active { transform: translateY(1px); }
.chat-send:disabled { opacity: .5; cursor: default; }

/* Footer note */
.foot { margin-top: 22px; text-align: center; }
.foot .mono { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }

/* Ghost button (sign out) --------------------------------- */
.btn.btn-ghost {
  background: rgba(245, 165, 36, .10); background-image: none; color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: none;
}
.btn.btn-ghost:hover { background: rgba(245, 165, 36, .16); background-image: none; border-color: var(--border-hover); box-shadow: none; filter: none; }
.btn.btn-ghost:active { transform: translateY(1px); }

/* Loading skeletons --------------------------------------- */
.skeleton {
  display: inline-block; min-width: 110px; border-radius: 6px; color: transparent !important;
  background-image: linear-gradient(90deg, rgba(245, 165, 36, .08) 25%, rgba(232, 201, 138, .20) 37%, rgba(245, 165, 36, .08) 63%);
  background-size: 320% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
.chip dd.skeleton { min-width: 150px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Invoices list (billing panel) --------------------------- */
.dash-inv-list { display: grid; gap: 8px; margin-top: 6px; }
.dash-inv-empty { color: var(--faint); font: 500 14px var(--font-mono); margin: 4px 0; line-height: 1.5; }
.dash-inv {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 15px; text-decoration: none;
  border: 1px solid var(--border); border-radius: 12px;
  background: rgba(33, 26, 20, .5);
  transition: border-color .15s, background .15s;
}
.dash-inv:hover { border-color: var(--border-hover); background: rgba(245, 165, 36, .08); }
.dash-inv[data-status="void"] { opacity: .55; }
.dash-inv-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-inv-no { font-size: 12px; color: var(--faint); }
.dash-inv-proj { font: 600 14.5px var(--font-ui); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-inv-right { display: flex; align-items: center; gap: 12px; flex: none; }
.dash-inv-amt { font-size: 14px; color: var(--text); }
.dash-inv-badge { font: 600 11px var(--font-ui); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.dash-inv-draft   { background: rgba(142, 136, 173, .18); color: var(--faint); }
.dash-inv-sent    { background: rgba(251, 191, 36, .16); color: #FBBF24; }
.dash-inv-paid    { background: rgba(52, 211, 153, .18); color: #5BE9B9; }
.dash-inv-overdue { background: rgba(251, 113, 133, .18); color: #FB7185; }
.dash-inv-void    { background: rgba(142, 136, 173, .14); color: var(--faint); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 980px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-chat { min-height: 0; }
  .chat-thread { max-height: 52vh; }
}
@media (max-width: 760px) {
  .dash-hero-card { grid-template-columns: 1fr; }
  .hero-chips { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .dash-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-accent { grid-column: 1 / -1; }
  .stat { padding: 14px 14px 12px; }
}
@media (max-width: 480px) {
  .dash-inv { flex-direction: column; align-items: stretch; gap: 8px; }
  .dash-inv-right { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .chat-live i { animation: none; }
}
