:root {
  --colorbasic: #1f3a5f;
  --colorbasic2: #2e5a8f;
  --colortext: #ffffff;
  --coraccent: #f4d85d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: #f4f6f9;
  color: #2b2b2b;
}

a { text-decoration: none; }

/* ---------- Layout wrapper ---------- */
.wrapper {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  border-top: 5px solid var(--coraccent);
}

/* ---------- Sidebar ---------- */
#sidebar {
  min-width: 250px;
  max-width: 250px;
  background: var(--colorbasic);
  color: var(--colortext);
  transition: margin-left .3s ease;
  display: flex;
  flex-direction: column;
}
#sidebar.collapsed { margin-left: -250px; }

#sidebar .brand {
  padding: 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.12);
  color: #fff;
}
#sidebar .brand .brand-logo {
  width: 100%;
  max-width: 132px;
  height: auto;
  display: block;
  margin: 0 auto 8px;
  background: #fff;
  padding: 10px;
  border-radius: 16px;
}
#sidebar .brand small { display: block; font-size: .75rem; font-weight: 400; opacity: .85; }

#sidebar ul.menu { list-style: none; margin: 0; padding: 12px 0; flex: 1; }
#sidebar ul.menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  color: #dce4ef;
  font-size: .98rem;
}
#sidebar ul.menu li a:hover { background: #fff; color: var(--colorbasic); }
#sidebar ul.menu li a.active { background: var(--colorbasic2); color: #fff; }
#sidebar .menu-section {
  padding: 14px 18px 6px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: .6;
}
#sidebar .sair { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.12); }
#sidebar .sair button {
  width: 100%;
  background: var(--coraccent);
  color: #1a1a1a;
  border: none;
  padding: 10px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

/* ---------- Content ---------- */
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  padding: 12px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.topbar .toggle {
  background: var(--coraccent);
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}
.topbar .inst { text-align: center; flex: 1; font-weight: 600; color: var(--colorbasic); }
.topbar .user { color: #555; font-size: .9rem; }

.main { padding: 24px; }

/* ---------- Components ---------- */
.card-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  padding: 20px;
  margin-bottom: 20px;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--colorbasic); margin: 0 0 18px; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 10px 12px; border-bottom: 1px solid #eaeaea; text-align: left; }
table.grid th { background: #f0f3f8; color: #36506f; font-size: .85rem; text-transform: uppercase; letter-spacing: .4px; }
table.grid tr:hover td { background: #fafbfd; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
}
.btn-primary { background: var(--colorbasic2); color: #fff; }
.btn-primary:hover { background: var(--colorbasic); }
.btn-light { background: #e9eef5; color: #36506f; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--colorbasic2); }
.stat .lbl { color: #777; font-size: .9rem; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-rascunho { background: #e0e0e0; color: #555; }
.badge-aberto { background: #d4edda; color: #1e7e34; }
.badge-finalizado { background: #cfe2ff; color: #0a58ca; }
.badge-cancelado { background: #f8d7da; color: #b02a37; }
.badge-valido { background: #d1e7dd; color: #0f5132; }
.badge-agendado { background: #fff3cd; color: #997404; }

/* Grid de formulário (estilo Bootstrap) — vários campos por linha */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0 16px; }
.form-grid .field { margin-bottom: 14px; }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
@media (max-width: 760px) {
  .col-12, .col-8, .col-6, .col-4, .col-3 { grid-column: span 12; }
}

form .field { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 5px; color: #36506f; }
form input[type=text], form input[type=email], form input[type=password],
form input[type=number], form input[type=datetime-local], form textarea, form select {
  width: 100%; padding: 9px 11px; border: 1px solid #cdd6e0; border-radius: 6px; font-size: .95rem;
}
form textarea { min-height: 90px; }

.flash { padding: 12px 18px; border-radius: 8px; margin-bottom: 16px; }
.flash.notice { background: #d4edda; color: #1e7e34; }
.flash.alert { background: #f8d7da; color: #b02a37; }

.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.alert-destaque { background: #fff3cd; border-left: 5px solid var(--coraccent); padding: 14px 18px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- Mapa de menor preço (feedback de atualização) ---------- */
#mapa_pedido.mapa-carregando { opacity: .45; transition: opacity .15s ease; pointer-events: none; }
@keyframes mapaFlash {
  0%   { background-color: #fff3b0; }
  100% { background-color: transparent; }
}
.mapa-flash { animation: mapaFlash 1.1s ease; border-radius: 8px; }

/* ---------- Paginação (Kaminari) ---------- */
.paginacao { margin-top: 16px; }
.paginacao .pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.paginacao .pagination a, .paginacao .pagination span {
  display: inline-block; padding: 6px 11px; border-radius: 6px; border: 1px solid #d8dee6;
  color: var(--colorbasic2); font-size: .88rem; text-decoration: none; background: #fff;
}
.paginacao .pagination .current { background: var(--colorbasic2); color: #fff; border-color: var(--colorbasic2); }
.paginacao .pagination a:hover { background: #eef2f7; }
.paginacao .pagination .disabled span { color: #bbb; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--colorbasic) 0%, #16293f 60%, #0f1d2e 100%);
  padding: 20px;
}
/* Card em duas colunas: marca à esquerda, formulário à direita */
.login-card {
  display: flex;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  min-height: 460px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  animation: loginIn .4s ease;
}
@keyframes loginIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Coluna da marca */
.login-side {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  background: linear-gradient(150deg, #eef3f9 0%, #dbe6f3 100%);
  border-right: 1px solid #e3e9f1;
}
.login-logo { width: 100%; max-width: 320px; height: auto; display: block; }
.login-inst {
  display: inline-block; padding: 4px 14px; border-radius: 20px;
  background: #fff; color: #36506f; font-size: .85rem; font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Coluna do formulário */
.login-main {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 44px 40px;
  border-top: 6px solid var(--coraccent);
}

.login-title { font-size: 1.4rem; color: var(--colorbasic); margin: 0 0 4px; }
.login-sub { margin: 0 0 24px; color: #9aa3ad; font-size: .88rem; }

.login-form .field { margin-bottom: 16px; }
.login-form label { font-size: .85rem; }
.login-form input[type=email], .login-form input[type=password] {
  padding: 12px 13px; border-radius: 9px; border: 1px solid #d8dee6; background: #f9fafc;
}
.login-form input:focus { outline: none; border-color: var(--colorbasic2); background: #fff; box-shadow: 0 0 0 3px rgba(46,90,143,.12); }

.login-remember { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: #5a6573; margin-bottom: 20px; }

.btn-block { width: 100%; padding: 12px; font-size: 1rem; border-radius: 9px; }

.login-link { margin-top: 18px; font-size: .88rem; }
.login-link a { color: var(--colorbasic2); }
.login-footer { color: #b3bcc7; font-size: .78rem; margin: 24px 0 0; }

/* Alternância entre os dois acessos (admin <-> credenciado) */
.login-switch {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid #e8ecf2;
  position: relative;
}
.login-switch-sep {
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: #fff; padding: 0 12px;
  color: #aab2bd; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
}
.login-switch-card {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px;
  border: 1px solid #e3e9f1; border-radius: 11px;
  background: #f9fafc;
  color: var(--colorbasic);
  text-decoration: none;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.login-switch-card:hover {
  border-color: var(--colorbasic2);
  background: #fff;
  box-shadow: 0 6px 18px rgba(31,58,95,.10);
  transform: translateY(-1px);
}
.login-switch-ico {
  flex: 0 0 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(46,90,143,.10);
  color: var(--colorbasic2);
}
.login-switch-card:hover .login-switch-ico { background: var(--colorbasic2); color: #fff; }
.login-switch-txt { display: flex; flex-direction: column; line-height: 1.3; font-size: .85rem; color: #6b7785; }
.login-switch-txt strong { color: var(--colorbasic); font-size: .92rem; font-weight: 600; }
.login-switch-arrow { margin-left: auto; color: #c2cad4; font-size: 1.15rem; transition: color .15s, transform .15s; }
.login-switch-card:hover .login-switch-arrow { color: var(--colorbasic2); transform: translateX(3px); }

@media (max-width: 760px) {
  .login-card { flex-direction: column; max-width: 420px; min-height: 0; }
  .login-side { border-right: none; border-bottom: 1px solid #e3e9f1; padding: 30px; }
  .login-logo { max-width: 240px; }
  .login-main { border-top: none; padding: 34px 28px; }
}

@media (max-width: 768px) {
  #sidebar { margin-left: -250px; position: fixed; height: 100%; z-index: 1000; }
  #sidebar.collapsed { margin-left: 0; }
}
