*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f0f0f;
  color: #e8e8e8;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Layout ── */
#app {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: #111;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
}

#sidebar-header {
  padding: 12px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

#new-chat-btn {
  width: 100%;
  background: #1e40af;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

#new-chat-btn:hover { background: #1d4ed8; }

#conversation-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 2px 6px;
  font-size: 0.82rem;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
}

.conv-item:hover { background: #1a1a1a; color: #e8e8e8; }
.conv-item.active { background: #1e3a5f; color: #dbeafe; }

.conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.1s;
}

.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: #f87171; background: #2a1a1a; }

/* ── Main ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

header {
  padding: 12px 16px;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

#sidebar-toggle:hover { background: #222; color: #e8e8e8; }

header h1 { font-size: 1rem; font-weight: 600; color: #fff; flex: 1; }

#status { color: #22c55e; font-size: 0.7rem; }
#status.loading { color: #f59e0b; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.9rem;
}

.message.user {
  align-self: flex-end;
  background: #1e3a5f;
  color: #dbeafe;
}

.message.assistant {
  align-self: flex-start;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
}

.message.briefing {
  align-self: stretch;
  max-width: 100%;
  background: #0f2a1a;
  border: 1px solid #14532d;
}

.message h2 { font-size: 1rem; margin-bottom: 8px; color: #86efac; }
.message h3 { font-size: 0.85rem; margin: 12px 0 4px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; }
.message p { margin: 4px 0; }
.message ul, .message ol { padding-left: 20px; }
.message li { margin: 2px 0; }
.message code { background: #2a2a2a; padding: 1px 4px; border-radius: 3px; font-size: 0.85em; }
.message pre { background: #2a2a2a; padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }

#chat-form {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #222;
  flex-shrink: 0;
  align-items: flex-end;
}

#input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e8e8e8;
  padding: 10px 14px;
  font-size: 0.9rem;
  resize: none;
  font-family: inherit;
}

#input:focus { outline: none; border-color: #555; }

button[type="submit"] {
  background: #1e40af;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

button[type="submit"]:hover { background: #1d4ed8; }
button[type="submit"]:disabled { background: #374151; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 640px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 100;
    width: 240px;
  }

  #sidebar.collapsed {
    width: 0;
  }

  /* When sidebar is open, float ☰ above it so it stays tappable */
  #sidebar-toggle.floating {
    position: fixed;
    top: 10px;
    left: 8px;
    z-index: 101;
    background: #111;
    border: 1px solid #333;
  }

  #main {
    max-width: 100%;
  }
}

/* ── Login screen ── */
#login-screen {
  position: fixed;
  inset: 0;
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#login-card {
  width: 100%;
  max-width: 320px;
  padding: 32px 24px;
  background: #111;
  border: 1px solid #222;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#login-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  letter-spacing: -0.02em;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#login-form input {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e8e8e8;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}

#login-form input:focus { border-color: #555; }

#login-form button[type="submit"] {
  margin-top: 4px;
  padding: 12px;
  font-size: 0.95rem;
}

#login-error {
  color: #f87171;
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}

/* ── Sign out button ── */
#signout-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}

#signout-btn:hover { color: #f87171; background: #1a1a1a; }

/* ── Image attach ── */
#attach-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 8px 4px;
  flex-shrink: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}

#attach-btn:hover { color: #e8e8e8; }

#input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#image-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #22c55e;
  padding: 2px 4px;
}

#image-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

#image-clear {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  line-height: 1;
}

#image-clear:hover { color: #f87171; }

/* ── Inline image in message bubble ── */
.msg-image {
  display: block;
  max-width: 240px;
  max-height: 180px;
  border-radius: 6px;
  margin-bottom: 8px;
  object-fit: cover;
}

/* ── Meeting Requests ── */
#meetings-section {
  background: #1a1a2a;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 12px 0;
}

#meetings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #a78bfa;
  margin-bottom: 10px;
}

#meetings-badge {
  background: #7c3aed;
  color: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
}

.meeting-card {
  background: #111;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.meeting-card .meeting-name { font-weight: 600; color: #e8e8e8; }
.meeting-card .meeting-meta { color: #888; margin-top: 4px; line-height: 1.6; white-space: pre-line; }
.meeting-card .meeting-actions { display: flex; gap: 8px; margin-top: 10px; }
.meeting-card .meeting-actions button { padding: 6px 14px; font-size: 0.8rem; border-radius: 6px; border: none; cursor: pointer; font-weight: 500; }
.meeting-card .approve-btn { background: #166534; color: #86efac; }
.meeting-card .reject-btn  { background: #3a1010; color: #f87171; }
.meeting-card .approve-btn:hover { background: #15803d; }
.meeting-card .reject-btn:hover { background: #4a1a1a; }

/* ── Approval Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-content {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 24px;
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 12px;
  margin: 0 16px;
}
.modal-content h2 { font-size: 1rem; color: #e8e8e8; }
.modal-content label { font-size: 0.85rem; color: #888; }
.modal-content #approve-meeting-details { font-size: 0.85rem; color: #aaa; line-height: 1.6; white-space: pre-line; }
.modal-content input[type="datetime-local"] {
  background: #111; border: 1px solid #333; border-radius: 6px;
  color: #e8e8e8; padding: 8px 10px; font-size: 0.875rem; width: 100%;
}
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-actions button { padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.875rem; font-weight: 500; }
.modal-actions button:not(.secondary) { background: #1d4ed8; color: #fff; }
.modal-actions button.secondary { background: #2a2a2a; color: #aaa; }
.modal-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
