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

:root {
  --brand:        #1a56db;
  --brand-dark:   #1340a8;
  --brand-light:  #e8f0fe;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --danger:       #dc2626;
  --danger-bg:    #fee2e2;
  --warn-bg:      #fef9c3;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-400:     #9ca3af;
  --gray-600:     #4b5563;
  --gray-700:     #374151;
  --gray-900:     #111827;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 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,.05);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Utility ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--gray-600); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300,#d1d5db); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ── Form elements ──────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 15px;
  background: #fff;
  color: var(--gray-900);
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.form-group { margin-bottom: 14px; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--danger-bg);  color: #991b1b; border-color: #fca5a5; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #86efac; }
.alert-info    { background: var(--brand-light); color: #1e40af; border-color: #93c5fd; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ══════════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1a56db 0%, #0d3a8a 100%);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-mark {
  width: 52px;
  height: 52px;
  background: var(--brand);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -.5px;
  margin-bottom: 10px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.login-logo p  { font-size: 13px; color: var(--gray-600); margin-top: 2px; }
.login-box .btn-primary { width: 100%; margin-top: 4px; padding: 12px; font-size: 15px; }

/* ══════════════════════════════════════════════════════════════════
   ADMIN PANEL
══════════════════════════════════════════════════════════════════ */
.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--brand);
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.topbar .logo { font-weight: 800; font-size: 17px; letter-spacing: -.3px; }
.topbar .spacer { flex: 1; }
.topbar .user-info { font-size: 13px; opacity: .85; }
.topbar .btn-logout {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.topbar .btn-logout:hover { background: rgba(255,255,255,.25); }

.admin-main { flex: 1; padding: 24px 20px; max-width: 1100px; margin: 0 auto; width: 100%; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-header h2 { font-size: 20px; font-weight: 700; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 700;
     text-transform: uppercase; letter-spacing: .5px; color: var(--gray-600); border-bottom: 1px solid var(--gray-200); }
td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-active   { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--gray-200);   color: var(--gray-600); }

.tech-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tech-tag {
  background: var(--brand-light); color: var(--brand); border-radius: 6px;
  font-size: 11px; font-weight: 600; padding: 2px 7px;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 16px; box-shadow: 0 25px 80px rgba(0,0,0,.25);
  width: 100%; max-width: 540px; padding: 28px; margin: auto;
  position: relative;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: var(--gray-100); border: none; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 18px; color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* Tech checkboxes */
.tech-checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tech-check-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1.5px solid var(--gray-200); border-radius: 8px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tech-check-item:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.tech-check-item input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; }
.tech-check-item span { font-size: 13px; font-weight: 500; }

/* ══════════════════════════════════════════════════════════════════
   CHAT PAGE
══════════════════════════════════════════════════════════════════ */
.chat-layout {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.chat-header {
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.chat-header .logo { font-weight: 800; font-size: 16px; }
.chat-header .partner-name { font-size: 13px; opacity: .8; }
.chat-header .spacer { flex: 1; }
.chat-header .btn-new {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.chat-header .btn-new:hover { background: rgba(255,255,255,.25); }
.chat-header .btn-logout-sm {
  background: transparent; color: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.3);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; cursor: pointer; transition: all .15s;
}
.chat-header .btn-logout-sm:hover { color: #fff; border-color: rgba(255,255,255,.6); }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--gray-50);
}

.msg {
  display: flex;
  gap: 8px;
  max-width: 80%;
  animation: fadeUp .2s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user  { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.msg.user .msg-avatar     { background: var(--brand); color: #fff; }
.msg.assistant .msg-avatar { background: var(--gray-200); color: var(--gray-700); }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  max-width: calc(100% - 44px);
  word-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant .msg-bubble {
  background: #fff; color: var(--gray-900);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

/* Markdown-like formatting in bubbles */
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble table { border-collapse: collapse; font-size: 13px; width: 100%; margin: 6px 0; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--gray-200); padding: 5px 9px; text-align: left; }
.msg-bubble th { background: var(--gray-100); font-weight: 700; }
.msg-bubble code { background: var(--gray-100); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.msg.user .msg-bubble code { background: rgba(255,255,255,.2); }

/* Typing indicator */
.typing-indicator .msg-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gray-400);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Order confirmed banner */
.order-confirmed-banner {
  background: var(--success-bg);
  border: 1.5px solid #86efac;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 16px;
  animation: fadeUp .3s ease-out;
}
.order-confirmed-banner h4 { color: var(--success); font-size: 15px; margin-bottom: 6px; }
.order-confirmed-banner .order-items { font-size: 13px; color: var(--gray-700); }
.order-confirmed-banner .order-total { font-size: 16px; font-weight: 700; color: var(--gray-900); margin-top: 8px; }

/* Input area */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  max-height: 120px;
  min-height: 44px;
  outline: none;
  transition: border-color .15s;
  line-height: 1.45;
}
.chat-input:focus { border-color: var(--brand); }
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.chat-send-btn:hover:not(:disabled) { background: var(--brand-dark); }
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }
.chat-send-btn svg { width: 20px; height: 20px; }

/* Welcome message */
.welcome-msg {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray-600);
}
.welcome-msg .welcome-icon {
  font-size: 40px; margin-bottom: 10px;
}
.welcome-msg h3 { font-size: 18px; color: var(--gray-800); margin-bottom: 6px; }
.welcome-msg p  { font-size: 14px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .admin-main { padding: 16px 12px; }
  .modal { padding: 20px 16px; }
  .tech-checkboxes { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
  .topbar .user-info { display: none; }
  th:nth-child(3), td:nth-child(3) { display: none; }
  th:nth-child(5), td:nth-child(5) { display: none; }
}
