/* ═══════════════════════════════════════════════════════════════
   AGENTIKA — Shared App Shell Styles
   Covers: screen-bar, sidebar, topbar, nav, user-footer
   Import AFTER theme.css in every app-shell screen.
═══════════════════════════════════════════════════════════════ */

/* ── SCREEN CHROME (mockup nav bar, not part of the real product) ── */
.screen-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.back-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--txt2);
  text-decoration: none; padding: 5px 10px; border-radius: var(--radius-xs);
  background: var(--surface2); border: 1px solid var(--border);
  transition: background var(--tx), color var(--tx);
}
.back-btn:hover { background: var(--surface3); color: var(--txt); }
.back-btn svg { width: 14px; height: 14px; transition: transform var(--tx-spring); }
.back-btn:hover svg { transform: translateX(-2px); }
.screen-id {
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  color: var(--accent); letter-spacing: .06em;
  background: var(--accent2); border: 1px solid rgba(37,99,235,.2);
  padding: 2px 8px; border-radius: 4px;
}
.bar-title { font-size: 12px; font-weight: 600; color: var(--txt2); }
.bar-spacer { flex: 1; }

/* ── APP SHELL ── */
.app-shell { display: flex; height: 100vh; padding-top: 44px; }

/* ── SIDEBAR ── */
.sidebar { width: 236px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.logo-row { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px; background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px var(--glow); flex-shrink: 0;
}
.logo-mark svg { width: 15px; height: 15px; color: #fff; }
.logo-name { font-size: 15px; font-weight: 700; color: var(--txt); letter-spacing: -.03em; }
.logo-name .logo-dot { color: var(--accent); }
.logo-tag { font-size: 9px; font-weight: 600; color: var(--txt3); background: var(--surface2); border: 1px solid var(--border); padding: 2px 7px; border-radius: var(--radius-pill); margin-left: 4px; }

.tenant-switch {
  margin: 10px 18px 0; padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: flex; align-items: center; gap: 8px; cursor: pointer;
  transition: background var(--tx), border-color var(--tx), transform var(--tx-spring);
}
.tenant-switch:hover { background: var(--surface3); border-color: var(--border2); transform: translateY(-1px); }
.tenant-switch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; animation: livePulse 2.2s ease-out infinite; }
.tenant-switch-name { font-size: 12px; font-weight: 600; color: var(--txt); }
.tenant-switch-sub { font-size: 10px; color: var(--txt3); }

.sidebar-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 4px; }
.nav-label { display: block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--txt3); padding: 12px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--txt2); cursor: pointer; text-decoration: none;
  transition: background var(--tx), color var(--tx), transform var(--tx); position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--txt); transform: translateX(2px); }
.nav-item.active { background: var(--accent2); color: var(--accent); font-weight: 600; }
.nav-item.active:hover { transform: none; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 20%; bottom: 20%; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; transition: top var(--tx), bottom var(--tx); }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .7; transition: opacity var(--tx), transform var(--tx-spring); }
.nav-item:hover svg { transform: scale(1.1); }
.nav-item.active svg { opacity: 1; }
.nav-item .nav-count { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--txt3); background: var(--surface3); padding: 1px 6px; border-radius: var(--radius-pill); }
.nav-item.active .nav-count { color: var(--accent); background: #fff; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--tx); }
.user-row:hover { background: var(--surface2); }
.user-row:hover .avatar { transform: scale(1.06); box-shadow: 0 3px 10px var(--glow); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent2); border: 1.5px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--accent); flex-shrink: 0; transition: transform var(--tx-spring), box-shadow var(--tx); }
.user-meta { min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--txt3); }

/* ── MAIN / TOPBAR ── */
.main { flex: 1; overflow-y: auto; background: var(--bg); }
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 56px; display: flex; align-items: center; gap: 14px;
}
.page-title { font-size: 15px; font-weight: 700; color: var(--txt); }
.page-sub { font-size: 11px; color: var(--txt3); }
.topbar-spacer { flex: 1; }

.main-content { padding: 24px 28px 48px; max-width: 1280px; }
/* kpi-row's own children already stagger themselves — skip the outer fade so it isn't double-applied */
.main-content > *:not(.kpi-row) { animation: fadeInUp .45s cubic-bezier(.4,0,.2,1) backwards; }
.main-content > *:nth-child(1) { animation-delay: 0s; }
.main-content > *:nth-child(2) { animation-delay: .04s; }
.main-content > *:nth-child(3) { animation-delay: .08s; }
.main-content > *:nth-child(4) { animation-delay: .12s; }
.main-content > *:nth-child(5) { animation-delay: .16s; }
.main-content > *:nth-child(n+6) { animation-delay: .2s; }

/* ── STAT / KPI CARDS ── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); transition: transform var(--tx-spring), box-shadow var(--tx), border-color var(--tx);
  animation: fadeInUp .4s cubic-bezier(.4,0,.2,1) backwards;
}
.kpi-row .kpi-card:nth-child(1) { animation-delay: .02s; }
.kpi-row .kpi-card:nth-child(2) { animation-delay: .06s; }
.kpi-row .kpi-card:nth-child(3) { animation-delay: .10s; }
.kpi-row .kpi-card:nth-child(4) { animation-delay: .14s; }
.kpi-row .kpi-card:nth-child(5) { animation-delay: .18s; }
.kpi-row .kpi-card:nth-child(6) { animation-delay: .22s; }
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transform: scaleX(0); transform-origin: left; transition: transform var(--tx);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border2); }
.kpi-card:hover::before { transform: scaleX(1); }
.kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--txt); line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 11px; font-weight: 600; margin-top: 6px; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--txt3); }

/* ── SECTION ── */
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--txt); }
.section-sub { font-size: 11px; color: var(--txt3); margin-top: 2px; }

/* ── PANEL (settings block) ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.panel-title { font-size: 13px; font-weight: 700; color: var(--txt); }
.panel-desc { font-size: 12px; color: var(--txt3); margin-top: 3px; max-width: 480px; line-height: 1.5; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius-xs); transition: background var(--tx); }
.panel-row:hover { background: var(--surface2); }
.panel-row:last-child { border-bottom: none; }
.panel-row-label { font-size: 13px; font-weight: 600; color: var(--txt); }
.panel-row-sub { font-size: 11px; color: var(--txt3); margin-top: 2px; }

/* ── SPEC REFERENCE PANEL ── used for inline "here's what the empty/error state
   looks like" blocks embedded in an otherwise-live screen. Same .panel markup
   as real content, so without a distinct treatment it reads as a second,
   contradictory data state instead of documentation. */
.panel-reference {
  position: relative; background: repeating-linear-gradient(135deg, var(--surface2), var(--surface2) 8px, var(--surface3) 8px, var(--surface3) 16px);
  border: 1.5px dashed var(--border2); box-shadow: none; margin-top: 22px;
}
.panel-reference::before {
  content: 'Mockup reference — not live UI'; position: absolute; top: -9px; left: 16px;
  background: var(--bg2); color: var(--txt3); font-size: 9px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; padding: 2px 9px;
  border-radius: var(--radius-pill); border: 1px solid var(--border2);
}
.panel-reference .panel-title { color: var(--txt2); }
.panel-reference .card { background: var(--surface); }

/* ── EMPTY / LOGIN LAYOUT ── */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 32px 30px; animation: fadeInUp .5s cubic-bezier(.4,0,.2,1) backwards; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 18px; font-weight: 700; color: var(--txt); text-align: center; }
.auth-sub { font-size: 12px; color: var(--txt3); text-align: center; margin-top: 4px; }

/* ── CALL FLOW DIAGRAM ── */
.flow-wrap { display: flex; flex-direction: column; align-items: center; }
.flow-step {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 14px 18px; box-shadow: var(--shadow); text-align: center;
}
.flow-step.decision { border-color: var(--accent); background: var(--accent2); }
.flow-step.outcome-ok { border-color: var(--ok); background: var(--ok2); }
.flow-step.outcome-warn { border-color: var(--warn); background: var(--warn2); }
.flow-step.outcome-mute { border-color: var(--border2); background: var(--surface2); }
.flow-step-title { font-size: 13px; font-weight: 700; color: var(--txt); margin-bottom: 3px; }
.flow-step-sub { font-size: 11px; color: var(--txt3); }
.flow-step-req { display:inline-block; margin-top:6px; font-size: 9px; font-weight: 700; font-family: var(--mono); color: var(--accent); background: #fff; border: 1px solid rgba(37,99,235,.2); padding: 2px 7px; border-radius: 4px; }
.flow-arrow { color: var(--txt3); font-size: 16px; line-height: 1; margin: 4px 0; }
.flow-branch { display: flex; gap: 24px; width: 100%; max-width: 820px; justify-content: center; align-items: flex-start; margin: 4px 0; }
.flow-branch-col { flex: 1; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flow-branch-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: var(--radius-pill); margin-bottom: 4px; }
.flow-branch-label.yes { color: var(--ok); background: var(--ok2); }
.flow-branch-label.no { color: var(--danger); background: var(--danger2); }
.flow-loop-note { font-size: 11px; color: var(--txt3); text-align: center; max-width: 420px; margin: 6px 0; font-style: italic; }

/* ── CALL SIMULATION ── */
.call-sim-card { max-width: 640px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.call-sim-header { background: linear-gradient(135deg, var(--accent), var(--purple)); color: #fff; padding: 20px 22px; display: flex; align-items: center; gap: 14px; }
.call-sim-avatar { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.call-sim-title { font-size: 14px; font-weight: 700; }
.call-sim-sub { font-size: 11px; opacity: .85; margin-top: 2px; }
.call-sim-timer { margin-left: auto; font-family: var(--mono); font-size: 13px; font-weight: 600; }
.waveform { display: flex; align-items: center; gap: 2px; height: 18px; margin-top: 6px; }
.waveform span { width: 3px; background: rgba(255,255,255,.85); border-radius: 2px; animation: wf 1.1s ease-in-out infinite; }
.waveform span:nth-child(1) { height: 40%; animation-delay: 0s; }
.waveform span:nth-child(2) { height: 90%; animation-delay: .1s; }
.waveform span:nth-child(3) { height: 60%; animation-delay: .2s; }
.waveform span:nth-child(4) { height: 100%; animation-delay: .3s; }
.waveform span:nth-child(5) { height: 50%; animation-delay: .4s; }
.waveform span:nth-child(6) { height: 75%; animation-delay: .5s; }
.waveform span:nth-child(7) { height: 35%; animation-delay: .6s; }
@keyframes wf { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

.transcript { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; max-height: 560px; overflow-y: auto; }
.bubble-row { display: flex; }
.bubble-row.ai { justify-content: flex-start; }
.bubble-row.customer { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; }
.bubble-row.ai .bubble { background: var(--surface2); color: var(--txt); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.bubble-row.customer .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 2px; }
.bubble-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); margin-bottom: 4px; }
.bubble-row.customer .bubble-label { color: rgba(255,255,255,.75); }
.bubble-system { align-self: center; font-size: 10px; font-weight: 600; color: var(--txt3); background: var(--surface3); padding: 3px 10px; border-radius: var(--radius-pill); }

.call-sim-outcome { border-top: 1px solid var(--border); padding: 16px 22px; background: var(--surface2); display: flex; gap: 20px; flex-wrap: wrap; }
.outcome-item { }
.outcome-item-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--txt3); margin-bottom: 3px; }
.outcome-item-value { font-size: 13px; font-weight: 700; color: var(--txt); }

/* ── TENANT BRANDING (REQ-TENANT-008) ──
   [data-tenant-logo] / [data-tenant-name] are populated at runtime by
   shared/app-shell.js from shared/tenant-config.js — single source of
   truth, never hardcoded per screen. The .logo-mark markup already inside
   each slot IS the default-Agentika-mark fallback the requirement calls for. */
.tenant-logo-slot img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* ── SUPPORT CONTACT FOOTER (REQ-PLATFORM-001) ──
   [data-support-footer] populated at runtime, same mechanism as branding.
   Platform-wide constant — tenant PHP app only, never Ops Admin. */
.support-footer { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--txt3); text-align: center; }
.support-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.support-footer a:hover { text-decoration: underline; }
.auth-shell { position: relative; padding-bottom: 48px; }
.auth-shell .support-footer { position: absolute; bottom: 0; left: 0; right: 0; }

/* ── CATALOG LIST TOOLBAR (REQ-ASSET-006) ── */
.list-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.list-toolbar .search-input { flex: 1; min-width: 200px; max-width: 320px; }
.list-toolbar .field-select { width: auto; min-width: 140px; }
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th .sort-icon { display: inline-block; margin-left: 3px; font-size: 9px; color: var(--txt3); }
.sortable-th.sorted .sort-icon { color: var(--accent); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 11px; color: var(--txt3); }
.pagination .page-controls { display: flex; gap: 4px; }
.pagination .page-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--surface); color: var(--txt2); font-size: 11px; cursor: pointer; transition: background var(--tx), color var(--tx), border-color var(--tx), transform var(--tx-spring); }
.pagination .page-btn:not([disabled]):hover { background: var(--surface2); border-color: var(--border2); transform: translateY(-1px); }
.pagination .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.pagination .page-btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ── BOOKINGS CALENDAR / GANTT VIEW (REQ-RENTALTRACK-004) ── */
.view-toggle { display: inline-flex; border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { border: none; background: var(--surface); color: var(--txt2); font-size: 12px; font-weight: 600; padding: 7px 14px; cursor: pointer; transition: background var(--tx), color var(--tx); }
.view-toggle button:not(.active):hover { background: var(--surface2); color: var(--txt); }
.view-toggle button.active { background: var(--accent); color: #fff; }
.calendar-grid { table-layout: fixed; }
.calendar-grid th, .calendar-grid td { text-align: center; padding: 8px 2px; font-size: 11px; }
.calendar-grid th:first-child, .calendar-grid td:first-child { text-align: left; padding-left: 12px; width: 190px; }
.cal-cell-active { background: var(--ok2); }
.cal-cell-overdue { background: var(--danger2); }
.cal-cell-returned { background: var(--surface3); }
.audit-line { font-size: 10.5px; color: var(--txt3); margin-top: 3px; }

/* ── CALL AUDIO PLAYER (REQ-CALL-004, ops-only) ── */
.audio-player { display: flex; align-items: center; gap: 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; }
.audio-player .play-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; border: none; transition: transform var(--tx-spring), box-shadow var(--tx); }
.audio-player .play-btn:hover { transform: scale(1.08); box-shadow: 0 4px 14px var(--glow); }
.audio-player .play-btn svg { width: 14px; height: 14px; }
.audio-player .track { flex: 1; height: 5px; background: var(--border2); border-radius: var(--radius-pill); position: relative; }
.audio-player .track-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 28%; background: var(--accent); border-radius: var(--radius-pill); }
.audio-player .time { font-family: var(--mono); font-size: 11px; color: var(--txt3); white-space: nowrap; }

/* ── AUTH ERROR / EMPTY STATES (REQ-AUTH-003) ── */
.auth-error-banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 16px;
  background: var(--danger2); border: 1px solid rgba(220,38,38,.25); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--txt);
}
.auth-error-banner svg { width: 16px; height: 16px; color: var(--danger); flex-shrink: 0; margin-top: 1px; }
.auth-error-banner .auth-error-title { font-weight: 700; margin-bottom: 2px; }
.auth-error-banner .auth-error-body { color: var(--txt2); line-height: 1.5; }
