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

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

:root {
  --primary: #8CCDEA;
  --primary-dark: #6ab8dc;
  --text: #2b2b2b;
  --text-light: #666;
  --border: #d9d9d9;
  --bg: #f5f7fa;
  --white: #fff;
  --sidebar-w: 220px;
  --radius: 9px;
  --radius-card: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── LOGIN ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
}

.login-sub {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 13px;
}

/* ── LAYOUT ──────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: #f0f9fd;
  color: var(--primary-dark);
}

.sidebar-nav a.active {
  border-right: 3px solid var(--primary);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

/* ── MAIN CONTENT ────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── CARDS ───────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.card-value.warn { color: #e67e22; }
.card-value.danger { color: #e74c3c; }

/* ── FORMS & INPUTS ──────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  background: var(--white);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}

.btn:hover { opacity: .85; }

.btn-primary { background: var(--primary); color: #000; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fdecea; color: #c0392b; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary-dark); }

/* ── TABLE ───────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-header h2 { font-size: 16px; font-weight: 700; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-pendente   { background: #fff3cd; color: #856404; }
.badge-processando{ background: #cff4fc; color: #0c5460; }
.badge-enviado    { background: #d1ecf1; color: #0c5460; }
.badge-entregue   { background: #d4edda; color: #155724; }
.badge-cancelado  { background: #f8d7da; color: #721c24; }
.badge-ok         { background: #d4edda; color: #155724; }
.badge-baixo      { background: #fff3cd; color: #856404; }
.badge-zerado     { background: #f8d7da; color: #721c24; }

/* ── MODAL ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── ERRO ────────────────────────────────────────── */
.erro {
  display: none;
  background: #fdecea;
  color: #c0392b;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

/* ── COMBO ITENS ─────────────────────────────────── */
.combo-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.combo-item-row select { flex: 2; }
.combo-item-row input  { flex: 1; }

/* ── DETALHE CLIENTE ─────────────────────────────── */
.detail-panel {
  background: var(--white);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 24px;
}

.detail-panel h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* ── TOOLBAR ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.toolbar input[type="text"] { max-width: 260px; }

/* ── FILTROS ─────────────────────────────────────── */
.filtros-pedidos,
.filtros-clientes {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.filtros-pedidos select,
.filtros-pedidos input[type="date"],
.filtros-clientes select {
  width: auto;
  min-width: 160px;
}

/* ── MODAL HISTORICO ─────────────────────────────── */
.modal-overlay-historico {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content-historico {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content-historico h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.modal-content-historico h3 { font-size: 14px; font-weight: 700; margin: 20px 0 12px; }

.modal-close-historico {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  color: var(--text-light);
}

.historico-item {
  padding: 12px 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ── MOBILE MENU TOGGLE ──────────────────────────── */
.mobile-menu-toggle {
  display: none;
}

/* ── RESPONSIVIDADE MOBILE ───────────────────────── */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  /* Botão hamburguer */
  .mobile-menu-toggle {
    display: block;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
  }

  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    position: fixed;
    height: 100vh;
    z-index: 999;
  }

  .sidebar.aberta {
    transform: translateX(0);
  }

  /* Conteúdo principal */
  .main {
    margin-left: 0;
    padding: 70px 16px 24px 16px;
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden;
  }

  .page-title {
    font-size: 18px;
  }

  /* Cards do dashboard */
  .cards-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }

  .cards-grid .card {
    width: 100%;
    box-sizing: border-box;
  }

  /* Filtros em coluna */
  .filtros-pedidos,
  .filtros-clientes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .filtros-pedidos select,
  .filtros-pedidos input,
  .filtros-pedidos button,
  .filtros-clientes select {
    width: 100%;
    box-sizing: border-box;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar input[type="text"] {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  /* Tabelas → cards empilhados */
  .table-wrap {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  table thead {
    display: none;
  }

  table,
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }

  table tr {
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  }

  table td {
    padding: 6px 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    gap: 8px;
  }

  table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-light);
    flex-shrink: 0;
  }

  /* Impede que inline styles de largura máxima quebrem layout */
  table td[style*="max-width"] {
    max-width: 100% !important;
    white-space: normal !important;
  }

  /* Modal histórico */
  .modal-content-historico {
    width: 95%;
    padding: 20px;
    max-height: 85vh;
  }
}
