/* =========================================================
   GROK BOT — OFFICIAL TEAMMATES DESIGN SYSTEM
   Exact 1-on-1 replica of Grok Bot (macOS & Mobile Companion)
========================================================= */

:root {
  --bg-app: #f5f6f9;
  --bg-sidebar: #f8f9fb;
  --bg-chat: #ffffff;
  --bg-screen-panel: #ffffff;
  
  --bg-user-bubble: #000000;
  --text-user-bubble: #ffffff;
  --bg-bot-bubble: #f1f2f5;
  --text-bot-bubble: #111113;
  
  --border-light: #e6e8ec;
  --border-subtle: #eeeff3;
  --border-active: #000000;
  
  --text-primary: #111113;
  --text-secondary: #636875;
  --text-muted: #8d929f;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Master App Container */
#app {
  display: flex;
  width: 100%;
  height: 100dvh;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}

/* 1. SIDEBAR (Teammates Directory) */
.grok-sidebar {
  width: 290px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  z-index: 10;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: calc(14px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mac Window Controls */
.mac-traffic-lights {
  display: flex;
  align-items: center;
  gap: 7px;
}

.traffic-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.traffic-dot.red { background: #ff5f56; border: 1px solid #e0443e; }
.traffic-dot.yellow { background: #ffbd2e; border: 1px solid #dea123; }
.traffic-dot.green { background: #27c93f; border: 1px solid #1aab29; }

.btn-add-bot {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.btn-add-bot:hover { background: rgba(0, 0, 0, 0.05); color: #000; }

.sidebar-search-box {
  padding: 0 14px 10px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.search-input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  color: var(--text-primary);
}

.sidebar-bots-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.bot-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.bot-item.active {
  background: #ebecee;
}

.bot-avatar-wrap {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.bot-avatar-wrap svg {
  width: 34px;
  height: 34px;
}

.bot-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bot-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-time {
  font-size: 11px;
  color: var(--text-muted);
}

.bot-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  width: 7px;
  height: 7px;
  background: #3b82f6;
  border-radius: 50%;
  margin-left: 6px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 14px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.footer-nav-item:hover { background: rgba(0,0,0,0.04); color: #000; }

.user-profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
}

.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #111113;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 2. CHAT CANVAS (Center Column) */
.grok-main-chat {
  flex: 1;
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  min-width: 0;
}

.chat-top-bar {
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 16px;
  padding-right: 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  z-index: 5;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.chat-active-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.top-action-btn:hover { background: rgba(0, 0, 0, 0.05); color: #000; }

.chat-scroll-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-time-divider {
  text-align: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 6px 0 10px;
}

/* User & Bot Message Bubbles */
.message-bubble-row {
  display: flex;
  width: 100%;
}

.message-bubble-row.user-side {
  justify-content: flex-end;
}

.message-bubble-row.bot-side {
  justify-content: flex-start;
}

.bubble-user {
  max-width: 82%;
  background: var(--bg-user-bubble);
  color: var(--text-user-bubble);
  padding: 12px 18px;
  border-radius: 20px 20px 6px 20px;
  font-size: 14.5px;
  line-height: 1.48;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bubble-bot {
  max-width: 86%;
  background: var(--bg-bot-bubble);
  color: var(--text-bot-bubble);
  padding: 12px 18px;
  border-radius: 20px 20px 20px 6px;
  font-size: 14.5px;
  line-height: 1.52;
  word-break: break-word;
}

/* Document & PDF Attachment Card */
.attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 4px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  max-width: 320px;
}

.pdf-icon-badge {
  width: 34px;
  height: 38px;
  background: #fee2e2;
  border-radius: 6px;
  color: #ef4444;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.attachment-meta {
  flex: 1;
  min-width: 0;
}

.attachment-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Chat Input Dock */
.chat-dock {
  padding: 10px 20px calc(14px + var(--safe-bottom));
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
}

.floating-pill-input {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 28px;
  padding: 6px 8px 6px 14px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.floating-pill-input:focus-within {
  border-color: #000000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.btn-input-add {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: #f4f5f8;
  color: var(--text-secondary);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--text-primary);
  max-height: 120px;
  resize: none;
  padding: 4px 0;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.btn-black-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #000000;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-black-circle:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.btn-black-circle:not(:disabled):active {
  transform: scale(0.92);
}

/* 3. RIGHT PANEL (Screen & Routines) */
.grok-screen-panel {
  width: 360px;
  background: var(--bg-screen-panel);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.screen-panel-header {
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 14px;
  padding-right: 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.screen-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen-box-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.screen-frame {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #1e1e24;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  position: relative;
}

.mock-browser-bar {
  height: 22px;
  background: #2b2b36;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
}
.mock-dot { width: 6px; height: 6px; border-radius: 50%; background: #555566; }

.mock-screen-content {
  width: 100%;
  height: calc(100% - 22px);
  background: #ffffff;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  position: relative;
}

.mock-cal-block {
  border-radius: 4px;
  background: #e0f2fe;
}
.mock-cal-block.blue { background: #0284c7; }
.mock-cal-block.green { background: #16a34a; }
.mock-cal-block.red { background: #dc2626; }

.mock-cursor-pointer {
  position: absolute;
  top: 45%;
  left: 70%;
  width: 14px;
  height: 14px;
}

.screen-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.routines-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.routines-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.routine-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8f9fb;
}

.routine-status-icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.routine-details {
  display: flex;
  flex-direction: column;
}

.routine-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.routine-schedule {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Mobile Responsive Adjustments */
@media (max-width: 900px) {
  .grok-screen-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .grok-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  }
  
  .grok-sidebar.open {
    transform: translateX(0);
  }

  .mobile-sidebar-toggle {
    display: flex;
  }
}
