/* ============================================================
   FAZENDEIRO — Design System CSS
   Abordagem: Minimalismo Corporativo Moderno
   Font: Roboto (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --color-primary:     #10B981;
  --color-primary-dk:  #059669;
  --color-primary-lt:  #D1FAE5;
  --color-bg:          #FFFFFF;
  --color-bg-soft:     #F9FAFB;
  --color-border:      #E5E7EB;
  --color-text:        #1F2937;
  --color-text-soft:   #6B7280;
  --color-warn:        #FBBF24;
  --color-warn-lt:     #FEF3C7;
  --color-error:       #EF4444;
  --color-error-lt:    #FEE2E2;
  --color-info:        #3B82F6;
  --color-info-lt:     #DBEAFE;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,.10), 0 10px 10px rgba(0,0,0,.04);

  --transition-fast: 150ms ease;
  --transition-md:   250ms ease;
  --transition-slow: 350ms cubic-bezier(0.4,0,0.2,1);
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Roboto', sans-serif;
  background: var(--color-bg-soft);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── TIPOGRAFIA ──────────────────────────────────────────── */
h1 { font-size: 2rem;   font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.25rem;font-weight: 500; line-height: 1.3; }
h4 { font-size: 1rem;   font-weight: 500; }
p  { color: var(--color-text-soft); }

/* ── BOTÕES ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Roboto', sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast),
              background var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}
.btn:hover  { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dk); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-lt); }

.btn-ghost { background: transparent; color: var(--color-text-soft); }
.btn-ghost:hover { background: var(--color-bg); box-shadow: var(--shadow-sm); }

.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.btn-warn { background: var(--color-warn); color: var(--color-text); }

.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .85rem 1.8rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── INPUTS ──────────────────────────────────────────────── */
.input, .select, .textarea {
  width: 100%;
  padding: .65rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: 'Roboto', sans-serif;
  font-size: .875rem;
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.input::placeholder { color: var(--color-text-soft); }
.textarea { resize: vertical; min-height: 80px; }

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-md), transform var(--transition-md);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green  { background: var(--color-primary-lt); color: var(--color-primary-dk); }
.badge-warn   { background: var(--color-warn-lt);    color: #92400E; }
.badge-error  { background: var(--color-error-lt);   color: #991B1B; }
.badge-info   { background: var(--color-info-lt);    color: #1D4ED8; }
.badge-gray   { background: var(--color-border);     color: var(--color-text-soft); }

/* ── STATUS MAP ──────────────────────────────────────────── */
.status-aguardando_pix  { background: var(--color-warn-lt); color: #92400E; }
.status-pix_confirmado  { background: var(--color-info-lt); color: #1D4ED8; }
.status-em_preparo      { background: #EDE9FE; color: #5B21B6; }
.status-despachado      { background: #E0F2FE; color: #0369A1; }
.status-em_entrega      { background: var(--color-primary-lt); color: var(--color-primary-dk); }
.status-entregue        { background: #D1FAE5; color: #065F46; }
.status-cliente_ausente { background: var(--color-warn-lt); color: #92400E; }
.status-falha           { background: var(--color-error-lt); color: #991B1B; }
.status-cancelado       { background: var(--color-border); color: var(--color-text-soft); }

/* ── HEADER / NAV ────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.app-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}
.app-logo span { color: var(--color-primary); }

/* ── LAYOUT ──────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.page { padding: 2rem 0; min-height: calc(100vh - 64px); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app-header { padding: 0 1rem; }
}

/* ── KPI CARDS ───────────────────────────────────────────── */
.kpi-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: .75rem; font-weight: 500; color: var(--color-text-soft); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--color-text); margin: .25rem 0 .1rem; }
.kpi-sub   { font-size: .8rem; color: var(--color-text-soft); }

/* ── TOASTS ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  animation: toastIn 200ms ease forwards;
  min-width: 280px;
  max-width: 380px;
}
.toast.success { background: var(--color-primary-dk); }
.toast.error   { background: var(--color-error); }
.toast.warn    { background: var(--color-warn); color: var(--color-text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease;
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: min(520px, 95vw);
  box-shadow: var(--shadow-xl);
  animation: slideUp 250ms ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ── DRAWER ──────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 150;
  animation: fadeIn 200ms ease;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 95vw);
  background: var(--color-bg);
  box-shadow: var(--shadow-xl);
  z-index: 151;
  display: flex;
  flex-direction: column;
  animation: slideLeft 300ms cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
}

/* ── TABELA ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 500;
  color: var(--color-text-soft);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--color-border);
}
tbody td { padding: .9rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-bg-soft); }

/* ── TIMELINE ────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 1rem;
  position: relative;
  padding-bottom: 1.25rem;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-border);
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-border);
  flex-shrink: 0;
  margin-top: 4px;
}
.timeline-item.done .timeline-dot { background: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-lt); }
.timeline-item.active .timeline-dot { background: var(--color-info); box-shadow: 0 0 0 2px var(--color-info-lt); animation: pulse 1.5s infinite; }
.timeline-line {
  position: absolute;
  left: 7px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--color-border);
}
.timeline-item.done .timeline-line { background: var(--color-primary-lt); }

/* ── HERO (Cliente) ──────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dk) 100%);
  color: #fff;
  padding: 3rem 0;
  margin-bottom: 2rem;
}
.hero h1 { color: #fff; }
.hero p  { color: rgba(255,255,255,.85); font-size: 1.1rem; }

/* ── UTILITÁRIOS ─────────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1      { gap: .25rem; }
.gap-2      { gap: .5rem; }
.gap-4      { gap: 1rem; }
.gap-6      { gap: 1.5rem; }
.mt-1       { margin-top: .25rem; }
.mt-2       { margin-top: .5rem; }
.mt-4       { margin-top: 1rem; }
.mt-6       { margin-top: 1.5rem; }
.mb-2       { margin-bottom: .5rem; }
.mb-4       { margin-bottom: 1rem; }
.mb-6       { margin-bottom: 1.5rem; }
.p-4        { padding: 1rem; }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--color-text-soft); }
.text-green { color: var(--color-primary); }
.text-error { color: var(--color-error); }
.font-bold  { font-weight: 700; }
.font-medium{ font-weight: 500; }
.hidden     { display: none !important; }
.w-full     { width: 100%; }
.text-center{ text-align: center; }
.rounded    { border-radius: var(--radius-md); }
.divider    { border: none; border-top: 1px solid var(--color-border); margin: 1rem 0; }

/* ── ANIMAÇÕES ───────────────────────────────────────────── */
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp     { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideLeft   { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pulse       { 0%,100% { box-shadow: 0 0 0 2px var(--color-info-lt); } 50% { box-shadow: 0 0 0 6px rgba(59,130,246,.2); } }
@keyframes spin        { to { transform: rotate(360deg); } }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 2rem auto;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-soft);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--color-text); margin-bottom: .5rem; }
