/* ============================================================
   Dashboard Styles — desktop-first, 1280px+ primary target
   Mobile polish comes later (v2)
   ============================================================ */

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

:root {
  --primary: #1e40af;
  --primary-light: #dbeafe;
  --primary-dark: #1e3a8a;
  --accent: #2563eb;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --radius: 10px;
  --sidebar-w: 220px;
}

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

/* ── Layout ─────────────────────────────────────────────── */

#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
}

#sidebar-logo {
  padding: 20px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

#sidebar-property {
  padding: 10px 16px 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.14); color: #fff; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

#sidebar-bottom {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ── Main content ─────────────────────────────────────────── */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

#topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Views ───────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ── Stat grid ───────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}

.empty-state .icon { font-size: 32px; margin-bottom: 12px; }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-lang {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-source-manual { background: #fef3c7; color: #92400e; }
.badge-source-scraped { background: #d1fae5; color: #065f46; }
.badge-source-docx { background: #ede9fe; color: #5b21b6; }
.badge-source-property_data { background: #fee2e2; color: #991b1b; }

.badge-booked { background: #fee2e2; color: #991b1b; }
.badge-free { background: #d1fae5; color: #065f46; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

textarea { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Conversation transcript ──────────────────────────────── */

.transcript { display: flex; flex-direction: column; gap: 12px; }

.msg-user, .msg-bot {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bot {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-900);
  border-bottom-left-radius: 4px;
}

/* ── Test bot panel ───────────────────────────────────────── */

#test-bot-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

#test-bot-frame {
  width: 380px;
  height: 540px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

/* ── Calendar grid ────────────────────────────────────────── */

.cal-table td, .cal-table th {
  text-align: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

/* ── Embed code box ───────────────────────────────────────── */

.code-box {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* ── Auth page ────────────────────────────────────────────── */

#auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
}

#auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

#auth-logo {
  font-size: 28px;
  text-align: center;
  margin-bottom: 8px;
}

#auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--gray-900);
  margin-bottom: 8px;
}

#auth-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 28px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ── Pagination ───────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  justify-content: flex-end;
  border-top: 1px solid var(--gray-100);
}

/* ── Toast ────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
  z-index: 9999;
  pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }

/* ── Misc ─────────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

hr.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 20px 0;
}

.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
