/* EzQanoon Statute Bot — frontend styles (no external dependencies) */

:root {
  --sidebar-bg: #16202e;
  --sidebar-bg-hover: #1f2c3d;
  --sidebar-fg: #c8d3e0;
  --sidebar-fg-dim: #7f8ea3;
  --sidebar-border: #26364a;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e5ea;
  --fg: #1c2430;
  --fg-dim: #6b7683;

  --accent: #1f6f5c;
  --accent-hover: #195a4b;
  --accent-soft: #e8f2ef;

  --danger: #b4342c;
  --danger-soft: #fdeceb;

  --radius: 10px;
  --sidebar-w: 270px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

/* ---------- Name overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--sidebar-bg);
}

.overlay-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.overlay-title {
  margin: 0;
  font-size: 26px;
  letter-spacing: -.4px;
  color: var(--accent);
}

.overlay-sub {
  margin: 2px 0 26px;
  font-size: 13px;
  color: var(--fg-dim);
}

.overlay-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.overlay-input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}

.overlay-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.overlay-hint {
  margin: 12px 0 22px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-dim);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
}

.btn-primary:hover { background: var(--accent-hover); }

/* ---------- Layout ---------- */

.app {
  display: flex;
  height: 100%;
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
}

.sidebar-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}

.brand-mark { font-size: 19px; }

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: #fff;
}

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
}

.btn-new:hover { background: var(--accent-hover); }

.chat-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 10px;
}

.list-label,
.list-empty {
  margin: 0 0 8px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--sidebar-fg-dim);
}

.list-empty {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 11px;
  margin-bottom: 2px;
  border-radius: 8px;
  cursor: pointer;
}

.chat-item:hover { background: var(--sidebar-bg-hover); }

.chat-item.active {
  background: var(--sidebar-bg-hover);
  box-shadow: inset 2px 0 0 var(--accent);
}

.chat-item-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--sidebar-fg-dim);
  background: none;
  border: none;
  border-radius: 5px;
  opacity: 0;
}

.chat-item:hover .chat-item-del,
.chat-item.active .chat-item-del { opacity: 1; }

.chat-item-del:hover {
  color: #fff;
  background: var(--danger);
}

.sidebar-foot {
  padding: 13px 16px;
  border-top: 1px solid var(--sidebar-border);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 27px;
  height: 27px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  background: var(--accent);
  border-radius: 50%;
}

.user-name {
  min-width: 0;
  font-size: 13.5px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-link {
  padding: 0;
  font-size: 12px;
  color: var(--sidebar-fg-dim);
  background: none;
  border: none;
  text-decoration: underline;
}

.btn-link:hover { color: var(--sidebar-fg); }

.sidebar-scrim { display: none; }

/* ---------- Main pane ---------- */

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 0 20px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.chat-title {
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  padding: 4px 8px;
  font-size: 17px;
  color: var(--fg);
  background: none;
  border: none;
  border-radius: 6px;
}

.btn-icon:hover { background: var(--bg); }

.menu-btn { display: none; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 20px;
}

/* ---------- Empty state ---------- */

.empty-state {
  max-width: 620px;
  margin: 6vh auto 0;
  text-align: center;
}

.empty-mark {
  font-size: 34px;
  color: var(--accent);
}

.empty-state h3 {
  margin: 10px 0 4px;
  font-size: 21px;
  letter-spacing: -.3px;
}

.empty-state p {
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--fg-dim);
}

.examples {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.example {
  padding: 12px 14px;
  font-size: 13.5px;
  text-align: left;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.example:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Messages ---------- */

.msg {
  display: flex;
  max-width: 780px;
  margin: 0 auto 18px;
}

.msg-user { justify-content: flex-end; }

.bubble {
  max-width: 84%;
  padding: 12px 15px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-user .bubble {
  color: #fff;
  background: var(--accent);
  border-bottom-right-radius: 4px;
}

.msg-assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-error .bubble {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f2c9c6;
  border-bottom-left-radius: 4px;
}

.bubble a {
  color: inherit;
  overflow-wrap: anywhere;
}

.msg-assistant .bubble a { color: var(--accent); }

/* Thinking indicator */

.dots {
  display: flex;
  gap: 5px;
  padding: 4px 2px;
}

.dots span {
  width: 7px;
  height: 7px;
  background: var(--fg-dim);
  border-radius: 50%;
  animation: bounce 1.3s infinite ease-in-out;
}

.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }

@keyframes bounce {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .dots span { animation: none; opacity: .5; }
}

/* ---------- Composer ---------- */

.composer-wrap {
  flex-shrink: 0;
  padding: 14px 20px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: 780px;
  margin: 0 auto;
  padding: 7px 7px 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-input {
  flex: 1;
  max-height: 180px;
  padding: 7px 0;
  font: inherit;
  color: var(--fg);
  background: none;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
}

.btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 9px;
}

.btn-send:hover:not(:disabled) { background: var(--accent-hover); }

.btn-send:disabled {
  background: #b6bfc9;
  cursor: not-allowed;
}

.disclaimer {
  max-width: 780px;
  margin: 8px auto 0;
  font-size: 11.5px;
  text-align: center;
  color: var(--fg-dim);
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {
  .menu-btn { display: block; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, .45);
  }

  .bubble { max-width: 92%; }

  .messages { padding: 18px 14px; }

  .composer-wrap { padding: 10px 14px; }
}
