:root {
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50); color: var(--gray-900);
  line-height: 1.5; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary); color: white;
  padding: 12px 16px; display: flex;
  align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header h1 { font-size: 17px; font-weight: 700; }
.header .user-info { font-size: 13px; opacity: 0.85; }
.header .btn-logout {
  background: rgba(255,255,255,0.2); border: none; color: white;
  padding: 6px 14px; border-radius: 8px; font-size: 13px;
  cursor: pointer; font-weight: 600;
}
.header .btn-logout:hover { background: rgba(255,255,255,0.3); }

/* Login */
.login-container {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.login-card {
  background: white; border-radius: var(--radius); padding: 32px;
  box-shadow: var(--shadow); width: 100%; max-width: 400px;
}
.login-card h1 { text-align: center; margin-bottom: 8px; color: var(--primary); }
.login-card .subtitle { text-align: center; color: var(--gray-500); font-size: 14px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.form-group input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 15px; outline: none; transition: border 0.2s;
}
.form-group input:focus { border-color: var(--primary); }
.btn {
  display: block; width: 100%; padding: 12px; border: none;
  border-radius: 8px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 13px; width: auto; display: inline-block; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; display: none; }
.alert-error { background: var(--danger-light); color: var(--danger); }

/* Dashboard */
.container { padding: 16px; max-width: 800px; margin: 0 auto; }
.order-card {
  background: white; border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow 0.2s; border-left: 4px solid var(--warning);
}
.order-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.order-card .order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-card .order-id { font-weight: 700; font-size: 15px; }
.order-card .order-status {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  font-weight: 600; text-transform: uppercase;
}
.status-pending { background: var(--warning-light); color: var(--warning); }
.order-card .order-customer { font-size: 14px; color: var(--gray-700); }
.order-card .order-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--gray-500); margin-top: 8px; }
.badge-unread {
  background: var(--danger); color: white; font-size: 11px;
  padding: 2px 8px; border-radius: 12px; font-weight: 700;
  display: inline-block; margin-left: 8px;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* Chat */
.chat-layout { display: flex; flex-direction: column; height: calc(100vh - 52px); }
.order-panel {
  background: white; border-bottom: 1px solid var(--gray-200);
  padding: 12px 16px; max-height: 40vh; overflow-y: auto;
}
.order-panel h2 { font-size: 15px; margin-bottom: 8px; }
.item-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--gray-100); font-size: 14px;
}
.item-row:last-child { border-bottom: none; }
.item-desc { flex: 1; }
.item-qty { width: 50px; text-align: center; padding: 4px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 14px; }
.item-price { min-width: 60px; text-align: right; font-weight: 600; }
.item-btn { border: none; background: none; cursor: pointer; font-size: 16px; padding: 4px; }
.item-btn:hover { opacity: 0.7; }
.order-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; padding: 10px 0 4px; border-top: 2px solid var(--gray-200); margin-top: 8px; }

.chat-panel { flex: 1; overflow-y: auto; padding: 12px 16px; background: var(--gray-50); }
.msg {
  max-width: 80%; padding: 10px 14px; border-radius: 14px;
  margin-bottom: 8px; font-size: 14px; line-height: 1.4; word-wrap: break-word;
}
.msg-cliente { background: white; border: 1px solid var(--gray-200); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-ps { background: var(--primary); color: white; margin-left: auto; border-bottom-right-radius: 4px; }
.msg-time { font-size: 11px; opacity: 0.6; margin-top: 4px; }
.chat-messages { display: flex; flex-direction: column; }

.chat-input {
  display: flex; gap: 8px; padding: 10px 16px;
  background: white; border-top: 1px solid var(--gray-200);
}
.chat-input input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 20px; font-size: 14px; outline: none;
}
.chat-input input:focus { border-color: var(--primary); }
.chat-input button {
  background: var(--primary); color: white; border: none;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
}

.action-bar {
  display: flex; gap: 8px; padding: 10px 16px;
  background: white; border-top: 1px solid var(--gray-200);
}
.action-bar .btn { flex: 1; font-size: 13px; padding: 10px; }

/* Responsive */
@media (min-width: 768px) {
  .chat-layout { flex-direction: row; }
  .order-panel { width: 350px; max-height: none; border-right: 1px solid var(--gray-200); border-bottom: none; overflow-y: auto; }
  .chat-section { flex: 1; display: flex; flex-direction: column; }
}

/* Loading */
.loading { text-align: center; padding: 20px; color: var(--gray-500); }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
