/* ============================================================
   CEO Command Center Dashboard Styles
   ============================================================ */

/* ---- Dashboard Layout ---- */
.dashboard-page {
  min-height: 100vh;
  background: var(--body-gradient);
}

.dashboard-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  backdrop-filter: blur(18px);
  padding: 0.875rem 1.5rem;
}

.dashboard-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-brand-mark {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-primary-20);
  background: var(--color-primary-10);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary);
}

.dashboard-brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-primary);
}

.dashboard-brand-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-text-muted);
}

/* ---- Live dot pulse ---- */
.live-dot {
  display: inline-flex;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--color-success);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.42), 0 0 18px rgba(74, 222, 128, 0.52);
  animation: livePulse 2.4s ease-out infinite;
}

.live-dot.warn {
  background: #FBBF24;
  box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.42), 0 0 18px rgba(251, 191, 36, 0.52);
}

.live-dot.critical {
  background: var(--color-alert);
  box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.42), 0 0 18px rgba(255, 107, 107, 0.52);
}

@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.42), 0 0 18px rgba(74, 222, 128, 0.52); }
  70%  { box-shadow: 0 0 0 0.45rem rgba(74, 222, 128, 0), 0 0 18px rgba(74, 222, 128, 0.40); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0), 0 0 18px rgba(74, 222, 128, 0.52); }
}

/* ---- Top stats bar ---- */
.stats-bar {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.stat-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px var(--color-shadow);
  border-color: var(--color-primary-30);
}

.stat-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-text-muted);
}

.stat-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1;
}

.stat-value.critical { color: var(--color-alert); }
.stat-value.warn     { color: #FBBF24; }
.stat-value.success  { color: var(--color-success); }

/* ---- Budget gauge ---- */
.budget-gauge-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
}

.budget-gauge-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.budget-gauge-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-text-muted);
}

.budget-gauge-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--color-bg-hover);
  overflow: hidden;
}

.budget-gauge-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

.budget-gauge-fill.safe    { background: var(--color-success); }
.budget-gauge-fill.warn    { background: #FBBF24; }
.budget-gauge-fill.critical { background: var(--color-alert); }

.budget-gauge-ticks {
  position: relative;
  height: 8px;
}

.budget-gauge-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--color-border-strong);
}

.budget-gauge-tick-label {
  position: absolute;
  top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  color: var(--color-text-muted);
  transform: translateX(-50%);
}

/* ---- Agent cards ---- */
.agent-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.agent-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  padding: 1.25rem;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.agent-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px var(--color-shadow);
  border-color: var(--color-primary-30);
}

.agent-card.running { border-left: 3px solid var(--color-success); }
.agent-card.idle    { border-left: 3px solid var(--color-text-muted); }
.agent-card.paused  { border-left: 3px solid #FBBF24; }
.agent-card.error   { border-left: 3px solid var(--color-alert); }

.agent-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.agent-card-name {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-primary);
}

.agent-card-role {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
}

.agent-card-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--color-border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
  background: var(--color-bg-hover);
}

.agent-card-status.running { border-color: rgba(74, 222, 128, 0.3); color: var(--color-success); background: rgba(74, 222, 128, 0.08); }
.agent-card-status.idle    { border-color: var(--color-border); color: var(--color-text-muted); }

.agent-card-body {
  display: grid;
  gap: 0.5rem;
}

.agent-card-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.agent-card-metric:last-child {
  border-bottom: none;
}

.agent-card-metric-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.agent-card-metric-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.agent-card-meters {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.agent-card-meter {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.agent-card-meter-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--color-bg-hover);
  overflow: hidden;
}

.agent-card-meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* ---- Section headings ---- */
.dashboard-section {
  margin-top: 2rem;
}

.dashboard-section-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--color-text-muted);
}

.dashboard-section-title::before {
  content: "";
  width: 1.5rem;
  height: 1px;
  background: var(--color-primary-30);
}

/* ---- Task funnel ---- */
.funnel-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.funnel-card {
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  transition: all 0.3s ease;
}

.funnel-card:hover {
  border-color: var(--color-primary-30);
  box-shadow: 0 8px 20px var(--color-shadow);
}

.funnel-card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
}

.funnel-card-value {
  margin-top: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.funnel-card.todo      { border-left: 3px solid var(--color-primary); }
.funnel-card.inprogress { border-left: 3px solid #60A5FA; }
.funnel-card.blocked   { border-left: 3px solid var(--color-alert); }
.funnel-card.done      { border-left: 3px solid var(--color-success); }
.funnel-card.review    { border-left: 3px solid #A78BFA; }

/* ---- Session table ---- */
.dash-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  -webkit-overflow-scrolling: touch;
}

.dash-table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
}

.dash-table th,
.dash-table td {
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 0.875rem 1.25rem;
  text-align: left;
  vertical-align: middle;
}

.dash-table th {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
  background: var(--color-bg-elevated);
}

.dash-table tbody tr:last-child td {
  border-bottom: none;
}

.dash-table tbody tr:hover td {
  background: var(--color-bg-hover);
}

.dash-table .col-agent { width: 25%; }
.dash-table .col-status { width: 18%; }
.dash-table .col-issue { width: 35%; }
.dash-table .col-action { width: 22%; }

/* ---- Buttons ---- */
.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sm:hover {
  border-color: var(--color-alert);
  color: var(--color-alert);
}

.btn-sm.primary {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-sm.primary:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ---- Refresh bar ---- */
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  margin-bottom: 1.5rem;
}

.refresh-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6rem;
  color: var(--color-text-muted);
}

/* ---- Loading shimmer ---- */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmerMove 1.5s ease infinite;
  pointer-events: none;
}

/* ---- Empty state ---- */
.empty-state {
  padding: 3rem 2rem;
  text-align: center;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ---- Toast ---- */
.dash-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  box-shadow: 0 16px 36px var(--color-shadow-heavy);
  font-size: 0.82rem;
  color: var(--color-text-primary);
  transform: translateY(120%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.dash-toast.show {
  transform: translateY(0);
}

.dash-toast.success { border-left: 3px solid var(--color-success); }
.dash-toast.error   { border-left: 3px solid var(--color-alert); }

/* ---- Responsive ---- */
@media (min-width: 640px) {
  .stats-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .funnel-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
  .agent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .agent-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .shimmer::after, .budget-gauge-fill, .agent-card-meter-fill {
    animation: none;
    transition: none;
  }
}
