/* admin.css — Painel de Expedição & CRM Farma Popular (Design System Executivo) */

:root {
  --admin-bg: #F4F1EA;
  --admin-sidebar-bg: #14100D;
  --admin-sidebar-hover: #221C17;
  --admin-sidebar-active: rgba(200, 30, 30, 0.2);
  --admin-card-bg: #FFFFFF;
  --admin-border: rgba(28, 23, 18, 0.08);
  --admin-border-dark: rgba(240, 185, 11, 0.15);
  --admin-text-main: #1C1712;
  --admin-text-muted: #6B6258;
}

body.admin-body {
  margin: 0;
  padding: 0;
  background: var(--admin-bg);
  color: var(--admin-text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
}

/* Shell do App: Sidebar Fixa + Main Area */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* SIDEBAR EXECUTIVA FIXA */
.admin-sidebar {
  width: 280px;
  min-width: 280px;
  background: linear-gradient(180deg, #16110D 0%, #0E0A08 100%);
  color: #F7F2E9;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--admin-border-dark);
  position: relative;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(200, 30, 30, 0.4);
}
.sidebar-brand-mark .cross { width: 18px; height: 18px; }
.sidebar-brand-text h2 {
  font-family: var(--font-serif);
  font-size: 19px;
  color: #FFFFFF;
  margin: 0;
  line-height: 1.1;
}
.sidebar-brand-text h2 span { color: var(--gold); }
.sidebar-brand-text .sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold-soft);
  opacity: 0.8;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Seção de Navegação da Sidebar */
.sidebar-nav {
  padding: 20px 14px;
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-group-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(247, 242, 233, 0.4);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 10px 12px 4px;
  font-weight: 700;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(247, 242, 233, 0.8);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s ease;
  text-decoration: none;
}
.sidebar-nav-item:hover {
  background: var(--admin-sidebar-hover);
  color: #FFFFFF;
  transform: translateX(2px);
}
.sidebar-nav-item.active {
  background: rgba(200, 30, 30, 0.25);
  border-color: rgba(200, 30, 30, 0.5);
  color: #FFFFFF;
}
.sidebar-nav-item .left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav-item .counter-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold);
}
.sidebar-nav-item.active .counter-badge {
  background: var(--gold);
  color: var(--ink);
}

/* Card Interativo na Sidebar */
.sidebar-footer-widget {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #79D2A6;
  background: rgba(47, 111, 82, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(47, 111, 82, 0.4);
}
.connection-pill .pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #39D353;
  box-shadow: 0 0 8px #39D353;
  animation: pulse-anim 1.6s infinite;
}

/* ÁREA PRINCIPAL DO DASHBOARD */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--admin-bg);
}

/* CANVAS DE CONSTELAÇÃO / NEURAL MESH */
#constellationCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.35;
}

/* TOP COMMAND BAR */
.top-command-bar {
  height: 64px;
  min-height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: relative;
  z-index: 20;
}
.command-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.command-left h1 {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--ink);
  margin: 0;
}
.command-left .subtitle-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--sage);
  background: rgba(47, 111, 82, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.command-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* CONTEÚDO SCROLLÁVEL */
.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 48px;
  position: relative;
  z-index: 10;
}

/* CARDS INTERATIVOS DE KPIS NO TOPO */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-color: rgba(200, 30, 30, 0.3);
}
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.kpi-title {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.kpi-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.kpi-value {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 4px;
}
.kpi-sub {
  font-size: 12px;
  color: var(--admin-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-tag-good {
  color: var(--sage);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* KANBAN EXECUTIVO */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1200px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
  .kanban-board { grid-template-columns: 1fr; }
}

.kanban-column {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
}
.column-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--admin-border);
  background: #FFFFFF;
  border-radius: 12px 12px 0 0;
}
.column-head h3 {
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0;
}
.column-badge {
  background: var(--admin-bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
}

.column-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Cards de Pedidos no Kanban */
.order-card {
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 16px;
  transition: all .18s ease;
  position: relative;
}
.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  border-color: rgba(200, 30, 30, 0.3);
}

.order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.order-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--red);
  background: rgba(200, 30, 30, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}
.order-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--admin-text-muted);
}

.order-customer {
  margin-bottom: 10px;
}
.order-customer .name {
  font-weight: 700;
  font-size: 14.5px;
  display: block;
  color: var(--ink);
}
.order-customer .phone {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--sage);
  text-decoration: none;
}
.order-customer .phone:hover { text-decoration: underline; }

.order-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-weight: 600;
}
.order-type-badge.delivery {
  background: rgba(47, 111, 82, 0.12);
  color: var(--sage);
}
.order-type-badge.pickup {
  background: rgba(240, 185, 11, 0.2);
  color: #7A5800;
}

.order-items-summary {
  background: var(--paper);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--admin-border);
}
.order-items-summary ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  margin: 0;
}

.order-footer-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--admin-border);
}
.order-footer-row .pagto {
  font-size: 11.5px;
  color: var(--admin-text-muted);
}
.order-footer-row .total {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--red-dark);
}

.order-btn-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-action-row {
  display: flex;
  gap: 6px;
}

/* Modais de Impressão */
@media print {
  body * { visibility: hidden; }
  #receipt-modal, #receipt-modal * { visibility: visible; }
  #receipt-modal {
    position: absolute;
    left: 0; top: 0;
    width: 80mm;
    margin: 0;
    padding: 0;
    background: #FFF;
    color: #000;
  }
  .no-print { display: none !important; }
}

.receipt-sheet {
  max-width: 380px;
  margin: 0 auto;
  background: #FFF;
  border: 1px dashed #999;
  padding: 24px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #000;
}
.receipt-sheet h2 {
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.receipt-sheet .divider {
  border-bottom: 1px dashed #000;
  margin: 10px 0;
}
