@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ---------- Branding Colors (Teckentrup / CarTeck) ---------- */
:root {
  --brand: black;
  --brand-dark: black;
  --brand-light: black;

  --bg: #f0f0ed;
  --card: #ffffff;
  --text: #0a0a0a;
  --muted: #6b7280;
  --border: #e2e2dd;

  --sidebar-bg: #0a0a0a;
  --sidebar-text: #ffffff;
  --sidebar-muted: #888;

  --avatar-bg: #1f2933;
  --avatar-fg: #ffffff;

  /* --accent-line: rgba(255,255,255,0.08); */
  --accent-line: rgba(255,255,255,0.08);
  --glow: 0 0 0 1px rgba(255,255,255,0.06);
}

/* ---------- Global ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- App Layout ---------- */
.app {
  height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
  gap: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Subtle grid texture on sidebar */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 24px;
  border-bottom: 3px solid var(--accent-line);
  position: relative;
  z-index: 1;
}

.logo {
  width: 140px;
  height: auto;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ---------- Sidebar Nav ---------- */
.sidebar-nav {
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 0 12px;
  margin: 0 0 8px;
}

.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0.1px;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: left;
  width: 100%;
  min-height: 44px;
}

.sidebar-nav button:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.nav-icon {
  font-size: 12px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: rgba(255,255,255,0.35);
  transition: color 0.15s ease;
}

.sidebar-nav button:hover .nav-icon {
  color: rgba(255,255,255,0.7);
}

.user-info {
  margin: 24px 16px 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-info-label {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.user-email {
  font-size: 12.5px;
  color: rgba(255,255,255,0.8) !important;
  word-break: break-all;
  font-weight: 500;
  font-family: 'DM Mono', monospace;
  line-height: 1.4;
}

.logout-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s ease;
  letter-spacing: 0.2px;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px 24px;
  border-top: 3px solid var(--accent-line);
  font-size: 11px;
  color: white;
  line-height: 1.5;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.3px;
  position: relative;
  z-index: 1;
}

/* ---------- Chat Panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.title {
  font-weight: 700;
  color: var(--text);
  font-size: 20px;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.5px;
}

#status {
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  background: #f0f0ed;
  color: #0a0a0a;
  border: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.5px;
}

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #d4d4cf transparent;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #d4d4cf; border-radius: 4px; }

.bubble {
  max-width: 72%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: bubbleIn 0.2s ease forwards;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  background: #0a0a0a;
  color: rgba(255,255,255,0.9);
  border-bottom-right-radius: 4px;
  font-weight: 400;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.bubble .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0ed;
}

.bubble .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Thinking indicator ---------- */
.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  font-size: 13px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.3px;
}

.dots {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0a0a0a;
  animation: pulse 1.2s ease-in-out infinite;
}

.dots:nth-child(2) { animation-delay: 0.2s; }
.dots:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
  40%            { opacity: 1;   transform: scale(1); }
}

/* ---------- Composer ---------- */
.composer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: var(--card);
}

.composer input {
  flex: 1;
  padding: 13px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.18s ease;
}

.composer input:focus {
  outline: none;
  border-color: #0a0a0a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(10,10,10,0.06);
}

.composer input::placeholder { color: #b0b0aa; }

.composer button {
  padding: 13px 26px;
  border-radius: 10px;
  border: none;
  background: #0a0a0a;
  color: white;
  font-weight: 600;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 44px;
  letter-spacing: 0.2px;
}

.composer button:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.composer button:active { transform: translateY(0); }

/* ---------- Modals ---------- */
#reportModal,
#summariseModal {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#adminModal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.modal-content {
  background: #0a0a0a;
  color: white;
  padding: 28px;
  border-radius: 16px;
  width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#report-title,
#summary-title,
#admin-title {
  color: white;
  text-align: center;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  padding: 0 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  letter-spacing: -0.2px;
}

.modal-content textarea,
.modal-content input[type="email"],
.modal-content input[type="password"] {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.18s;
  width: 100%;
}

.modal-content textarea { min-height: 110px; resize: vertical; }

.modal-content textarea::placeholder,
.modal-content input::placeholder { color: rgba(255,255,255,0.3); }

.modal-content textarea:focus,
.modal-content input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.3);
}

.admin-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  padding: 2px 0;
}

.admin-toggle-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: white;
  cursor: pointer;
  flex-shrink: 0;
}

.report-buttons,
.summary-buttons,
.admin-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}

#closeReport, #submitReport,
#closeSummary, #sendSummary,
#createUserBtn, #closeAdminModal {
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
}

#submitReport, #sendSummary, #createUserBtn {
  background: white;
  color: #0a0a0a;
  border-color: white;
}

#closeReport:hover, #closeSummary:hover, #closeAdminModal:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

#submitReport:hover, #sendSummary:hover, #createUserBtn:hover {
  background: #e8e8e3;
  transform: translateY(-1px);
}

/* ---------- Admin button ---------- */
#adminBtn { display: none; }

/* ---------- LOGIN PAGE ---------- */
body.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}

/* Grid background for login */
body.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

body.login-body::after {
  content: '';
  position: fixed;
  top: -40%;
  left: -20%;
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.login-container {
  width: 100%;
  max-width: 360px;
  background: #161616;
  padding: 40px 36px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  text-align: center;
  position: relative;
  z-index: 1;
  animation: loginIn 0.3s ease;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-title { margin-bottom: 28px; }

.login-container h1,
.login-container .login-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
  border: none;
  padding: 0;
}

#title {
  border-bottom: none !important;
  color: white;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-container input {
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 14px;
  color: white;
  background: rgba(255,255,255,0.06);
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.login-container input::placeholder { color: rgba(255,255,255,0.3); }

.login-container input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.05);
}

#loginBtn {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: white;
  color: #0a0a0a;
  font-size: 14px;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.18s ease;
  letter-spacing: 0.2px;
}

#loginBtn:hover {
  background: #e8e8e3;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#loginBtn:active { transform: translateY(0); }

#error {
  margin-top: 14px;
  font-size: 13px;
  color: #ff6b6b;
  font-weight: 500;
  min-height: 18px;
  font-family: 'DM Mono', monospace;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }
  .sidebar { order: 2; max-height: 50vh; }
  .panel   { order: 1; min-height: 50vh; }
}

@media (max-width: 480px) {
  .panel-header { padding: 14px 18px; }
  .title { font-size: 17px; }
  .subtitle { font-size: 11px; }
  .messages { padding: 16px; gap: 14px; }
  .bubble { font-size: 14px; max-width: 88%; }
  .composer { padding: 14px; gap: 8px; }
  .modal-content { width: 90%; max-width: 380px; }
  .login-container { padding: 28px 24px; margin: 16px; }
}