/* ============================================================
   ARQELIVA — App Shell (dashboard / authenticated pages)
   Shared layout: sidebar + topbar + content
   ============================================================ */
.app { display: flex; min-height: 100vh; background: var(--bg); }
.app-sidebar {
  width: 240px; flex-shrink: 0; background: var(--navy); color: rgba(255,255,255,.7);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.app-sidebar .brand { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.app-sidebar .brand-name { color: #fff; }
.app-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.app-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  color: rgba(255,255,255,.65); text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: all .15s;
}
.app-nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.app-nav a.active { color: #fff; background: rgba(79,93,245,.25); border-left: 3px solid var(--indigo); }
.app-nav a .nav-ic { width: 20px; text-align: center; }
.app-sidebar .side-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: .78rem; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  height: 60px; background: var(--white); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.app-topbar .tb-title { font-weight: 700; font-size: 1.05rem; }
.app-topbar .tb-actions { display: flex; align-items: center; gap: 12px; }
.app-content { padding: 24px; flex: 1; }
.app-content:has(.chat) { padding: 0; display: flex; flex-direction: column; }

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* Stat cards row */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.stat-card .s-label { font-size: .78rem; color: var(--muted); }
.stat-card .s-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.stat-card .s-delta { font-size: .74rem; margin-top: 4px; }

/* Panels */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; }
.panel-head h3 { font-size: 1rem; }
.panel-body { padding: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th { text-align: left; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.table tr:hover td { background: var(--bg); }
.table .t-actions { display: flex; gap: 8px; }

/* Timeline (journey) */
.journey { display: flex; flex-direction: column; gap: 0; }
.journey-step { display: flex; gap: 14px; position: relative; padding-bottom: 20px; }
.journey-step::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.journey-step:last-child::before { display: none; }
.journey-dot { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .8rem; z-index: 1; }
.journey-dot.done { background: var(--green); color: #fff; }
.journey-dot.active { background: var(--indigo); color: #fff; }
.journey-dot.pending { background: var(--line-soft); color: var(--muted); }
.journey-body { flex: 1; }
.journey-body .j-title { font-weight: 600; font-size: .92rem; }
.journey-body .j-sub { font-size: .8rem; color: var(--muted); }

/* Chat (AI advisor) */
.chat { display: flex; flex-direction: column; flex: 1; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px 10%; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 600px; padding: 12px 18px; border-radius: var(--r-lg); font-size: .92rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--indigo); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 10px; padding: 16px 10%; border-top: 1px solid var(--line); background: var(--white); align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; min-height: 48px; max-height: 160px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); font-size: .92rem; font-family: inherit; line-height: 1.5; outline: none; transition: border-color .15s; background: var(--bg); }
.chat-input textarea:focus { border-color: var(--indigo); background: var(--white); }
.chat-input .btn { height: 48px; padding: 0 22px; flex-shrink: 0; }

@media (max-width: 768px) {
  .chat-messages { padding: 20px 16px; }
  .chat-input { padding: 16px; }
  .msg { max-width: 100%; }
}

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }

/* Form controls (shared across auth + onboarding + filters) */
.label { font-size: .85rem; font-weight: 600; color: var(--ink); }
.input, .select {
  width: 100%;
  padding: 11px 14px;
  font-size: .95rem;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.input::placeholder { color: #98A2B3; }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Badges / status */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.green { background: var(--green); }
.status-dot.amber { background: #F59E0B; }
.status-dot.red { background: #EF4444; }
.status-dot.gray { background: #C4CBD6; }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .e-icon { font-size: 2.4rem; margin-bottom: 12px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: .9rem; margin-bottom: 16px; }

/* Responsive */
@media (max-width: 1024px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app-sidebar { position: fixed; left: -240px; z-index: 200; transition: left .2s; }
  .app-sidebar.open { left: 0; }
  .stat-row { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
