/* ========== Reset / Base ========== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #ECE5DD;
  color: #1a1a1a;
  font-size: 15px;
  line-height: 1.4;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ========== Lomil Brand ========== */
:root {
  --lomil-blue: #0B2E6D;
  --lomil-blue-dark: #08245A;
  --lomil-blue-light: #1A4598;
  --whats-green: #25D366;
  --whats-green-dark: #128C7E;
  --whats-bg: #ECE5DD;
  --whats-msg-other: #ffffff;
  --whats-msg-me: #DCF8C6;
  --whats-msg-confirm: #d4ead0;
  --text-muted: #888;
  --text-soft: #555;
}

/* ========== Login ========== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--lomil-blue) 0%, var(--lomil-blue-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: white;
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 22px;
}
.login-logo .circle {
  width: 64px;
  height: 64px;
  background: var(--lomil-blue);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 10px;
}
.login-logo h1 {
  font-size: 18px;
  color: var(--lomil-blue);
  font-weight: 800;
  letter-spacing: 0.5px;
}
.login-logo p {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 4px;
}
.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  margin: 14px 0 6px;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}
.login-form input:focus { border-color: var(--lomil-blue); }
.login-form .btn {
  width: 100%;
  background: var(--lomil-blue);
  color: white;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(11,46,109,.25);
}
.login-form .btn:active { background: var(--lomil-blue-dark); }
.login-error {
  background: #FEF2F2;
  color: #B91C1C;
  border-left: 3px solid #DC2626;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.login-error.show { display: block; }
.login-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
  line-height: 1.5;
}

/* ========== App (chat layout - flexbox column) ========== */
html, body.app-page {
  height: 100vh;
  height: 100dvh; /* dynamic viewport - lida com barra do navegador mobile */
  overflow: hidden;
}
body.app-page {
  display: flex;
  flex-direction: column;
}
.app-header {
  background: var(--lomil-blue);
  color: white;
  padding: 12px 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  z-index: 10;
}
.app-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-avatar {
  width: 40px;
  height: 40px;
  background: white;
  color: var(--lomil-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.app-header-info .title { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; }
.app-header-info .status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-dot {
  width: 7px;
  height: 7px;
  background: var(--whats-green);
  border-radius: 50%;
  display: inline-block;
}
.app-header .counter {
  background: rgba(255,255,255,.15);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
}
.app-header .menu {
  background: transparent;
  border: none;
  color: white;
  font-size: 22px;
  padding: 0 6px;
  margin-left: 4px;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px;
  -webkit-overflow-scrolling: touch;
}

.bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,.13);
  font-size: 14.5px;
  line-height: 1.45;
  word-wrap: break-word;
}
.bubble.bot { background: var(--whats-msg-other); border-top-left-radius: 4px; }
.bubble.me { background: var(--whats-msg-me); margin-left: auto; border-top-right-radius: 4px; }
.bubble.confirm { background: var(--whats-msg-confirm); border-left: 3px solid var(--whats-green); }
.bubble .time {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.quick-replies {
  display: flex;
  gap: 8px;
  padding: 0 0 12px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply {
  background: white;
  color: var(--lomil-blue);
  border: 1px solid #d0d7e3;
  padding: 9px 15px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .1s;
}
.quick-reply:active { transform: scale(0.96); }
.quick-reply.primary {
  background: var(--lomil-blue);
  color: white;
  border-color: var(--lomil-blue);
}
.quick-reply.send {
  background: var(--whats-green);
  color: white;
  border-color: var(--whats-green);
  box-shadow: 0 2px 6px rgba(37,211,102,.3);
}

.product-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  max-width: 82%;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.13);
}
.product-img-wrap { position: relative; height: 110px; }
.product-img { width: 100%; height: 100%; background-position: center; background-size: cover; }
.view-photo-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(11,46,109,.85);
  color: white;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
}
.product-body { padding: 9px 11px 11px; }
.product-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; line-height: 1.3; }
.product-meta { font-size: 11px; color: var(--text-muted); }
.product-price {
  font-size: 17px;
  font-weight: 800;
  color: var(--lomil-blue);
  margin-top: 6px;
}
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--lomil-blue);
  background: white;
  color: var(--lomil-blue);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-value {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}
.insert-btn {
  display: block;
  background: var(--lomil-blue);
  color: white;
  border: none;
  padding: 11px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  margin-top: 8px;
  width: 100%;
}
.insert-btn:active { background: var(--lomil-blue-dark); }

.input-bar {
  background: #f0f0f0;
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
  z-index: 20;
}
.input-field {
  flex: 1;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 15px;
  outline: none;
}
.input-field:focus { border-color: var(--lomil-blue); }
.input-btn {
  width: 44px;
  height: 44px;
  background: var(--whats-green);
  color: white;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Modals ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 100%;
  width: 420px;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
}
.modal-img { width: 100%; height: 220px; background-position: center; background-size: cover; }
.modal-info { padding: 18px; }
.modal-info h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--lomil-blue); }
.modal-info p { color: var(--text-soft); font-size: 14px; line-height: 1.5; }
.modal-info pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 8px;
  font-size: 11px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'SF Mono', Consolas, 'Courier New', monospace;
  margin-top: 10px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.2);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  z-index: 2;
}
/* Campos extras no modal de pedido (pagamento, entrega, obs) */
.campo-group { margin-top: 14px; }
.campo-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-option {
  background: white;
  border: 1.5px solid #d0d7e3;
  color: var(--text-soft);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.chip-option:active { transform: scale(0.96); }
.chip-option.selected {
  background: var(--lomil-blue);
  border-color: var(--lomil-blue);
  color: white;
}
.campo-textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1.5px solid #d0d7e3;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.campo-textarea:focus { border-color: var(--lomil-blue); }
.modal-btns { display: flex; gap: 8px; padding: 14px 18px 18px; }
.modal-btn {
  flex: 1;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}
.modal-btn.primary { background: var(--whats-green); color: white; }
.modal-btn.cancel { background: #999; color: white; }

/* ========== Dashboard ========== */
.dash-page {
  background: #F5F5F7;
  min-height: 100vh;
  padding-bottom: 30px;
}
.dash-header {
  background: var(--lomil-blue);
  color: white;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-header h1 { font-size: 18px; font-weight: 700; }
.dash-header .logout {
  background: rgba(255,255,255,.2);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 600;
}
.dash-body { padding: 16px; max-width: 980px; margin: 0 auto; }
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.metric-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.metric-card .value {
  font-size: 24px;
  font-weight: 800;
  color: var(--lomil-blue);
  margin-top: 4px;
}
.metric-card .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dash-section {
  background: white;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.dash-section h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pedido-row {
  border-top: 1px solid #f0f0f0;
  padding: 12px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.pedido-row:first-of-type { border-top: none; padding-top: 0; }
.pedido-when { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.pedido-cli { font-size: 14px; font-weight: 600; }
.pedido-itens { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pedido-total { font-size: 15px; font-weight: 800; color: var(--lomil-blue); white-space: nowrap; }
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
