/* ─── OLN Command Centre — App Styles ─────────────────────── */

:root {
  --bg:          #0F0F1A;
  --bg2:         #161626;
  --bg3:         #1E1E32;
  --border:      #2A2A42;
  --border2:     #3A3A55;
  --text:        #E8E8F0;
  --text2:       #9999BB;
  --text3:       #6666AA;
  --accent:      #6C63FF;
  --accent2:     #4F46E5;
  --accent-glow: rgba(108,99,255,0.25);
  --green:       #10B981;
  --yellow:      #F59E0B;
  --blue:        #3B82F6;
  --purple:      #8B5CF6;
  --red:         #EF4444;
  --sidebar-w:   220px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Login ─────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, rgba(108,99,255,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 60%, rgba(79,70,229,0.08) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  box-shadow: var(--shadow), 0 0 60px rgba(108,99,255,0.08);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 10px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-title  { font-size: 18px; font-weight: 700; color: var(--text); }
.logo-sub    { font-size: 12px; color: var(--text2); margin-top: 2px; }
.logo-icon-sm { font-size: 20px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.field-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.login-error {
  color: var(--red);
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
}

.login-footer { text-align: center; color: var(--text3); font-size: 11px; margin-top: 20px; }

/* ─── App Layout ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.2s;
}

.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-sites,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .site-link span:last-child { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title { font-size: 15px; font-weight: 700; flex: 1; }
.sidebar-toggle { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 4px; }
.sidebar-toggle:hover { color: var(--text); background: var(--bg3); }

.sidebar-nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; }

.badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  padding: 12px 12px 4px;
}

.sidebar-sites { padding: 0 8px 8px; }
.site-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.site-link:hover { background: var(--bg3); color: var(--text); }
.site-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

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

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.tab-panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}

.panel-title { font-size: 18px; font-weight: 700; }
.panel-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Chat ───────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  flex: 1;
  gap: 12px;
}
.welcome-icon { font-size: 48px; }
.chat-welcome h2 { font-size: 22px; font-weight: 700; color: var(--text); }
.chat-welcome p { color: var(--text2); max-width: 480px; line-height: 1.6; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.quick-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 8px 16px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.quick-btn:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* Chat messages */
.msg {
  display: flex;
  gap: 12px;
  max-width: 800px;
  animation: fadeIn 0.2s ease;
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.agent { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; font-weight: 700;
}
.msg.user .msg-avatar { background: var(--accent); color: white; }
.msg.agent .msg-avatar { background: var(--bg3); border: 1px solid var(--border); }

.msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg.user .msg-body { align-items: flex-end; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 14px;
  max-width: 600px;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg.agent .msg-bubble {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-meta { font-size: 11px; color: var(--text3); padding: 0 4px; }

.msg-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--bg3);
}
.msg-status.running { border-color: var(--accent); color: var(--accent); animation: pulse 1.5s infinite; }
.msg-status.done    { border-color: var(--green);  color: var(--green); }
.msg-status.error   { border-color: var(--red);    color: var(--red); }

.typing-dots { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3);
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Chat Input */
.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.site-selector select { }

.chat-textarea {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chat-textarea::placeholder { color: var(--text3); }

.chat-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text3);
}

kbd {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
}

.char-count { }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-send {
  width: 44px; height: 44px;
  padding: 0; border-radius: var(--radius);
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.btn-arrow { font-size: 16px; }
.btn-danger { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }
.btn-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: var(--green); }

/* ─── Status Badges ───────────────────────────────────────── */
.status-badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-idle    { background: rgba(153,153,187,0.1); color: var(--text3); border: 1px solid var(--border); }
.status-running { background: rgba(108,99,255,0.15); color: var(--accent); border: 1px solid var(--accent); animation: pulse 1.5s infinite; }
.status-done    { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.status-error   { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ─── Logs ────────────────────────────────────────────────── */
.logs-filters {
  display: flex;
  gap: 6px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-btn {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

.logs-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-run {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.log-run:hover { border-color: var(--border2); }

.log-run-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.log-run-header:hover { background: var(--bg3); }

.log-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.log-status-dot.success { background: var(--green); }
.log-status-dot.failure { background: var(--red); }
.log-status-dot.running { background: var(--accent); animation: pulse 1s infinite; }
.log-status-dot.skipped,
.log-status-dot.cancelled { background: var(--text3); }

.log-run-name { font-size: 13px; font-weight: 600; flex: 1; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-run-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.log-run-date { font-size: 11px; color: var(--text); white-space: nowrap; font-weight: 500; }
.log-run-time { font-size: 10px; color: var(--text3); white-space: nowrap; }
.log-run-site { font-size: 11px; color: var(--text2); flex-shrink: 0; }
.log-expand   { color: var(--text3); font-size: 10px; flex-shrink: 0; transition: transform 0.2s ease; display: inline-block; margin-left: 8px; }

.log-run-steps {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: none;
}
.log-run-steps.open { display: block; }

.log-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.log-step:last-child { border-bottom: none; }
.log-step-icon { font-size: 13px; flex-shrink: 0; }
.log-step-name { flex: 1; }
.log-step-dur  { color: var(--text3); font-size: 11px; flex-shrink: 0; }

.log-commit-msg {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
}

.log-run-detail {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text3);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.log-run-detail code {
  background: var(--bg3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text2);
}

.log-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  padding: 4px 0;
}
.log-view-btn:hover { text-decoration: underline; }

/* ─── Approvals ───────────────────────────────────────────── */
.approvals-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.approval-type-badge {
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.approval-type-fix    { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.approval-type-blog   { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.approval-type-seo    { background: rgba(59,130,246,0.1); color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }

.approval-title { font-size: 14px; font-weight: 600; flex: 1; }
.approval-site  { font-size: 12px; color: var(--text2); }
.approval-prompt {
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.6;
}
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Gmail ───────────────────────────────────────────────── */
.gmail-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.gmail-item {
  display: flex;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  align-items: center;
}
.gmail-item:hover { background: var(--bg2); }
.gmail-item.unread .gmail-subject { font-weight: 700; color: var(--text); }
.gmail-item.unread { background: rgba(108,99,255,0.03); }

.gmail-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.gmail-dot.read { background: transparent; }

.gmail-from    { font-size: 13px; font-weight: 600; min-width: 160px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gmail-subject { font-size: 13px; flex: 1; color: var(--text2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gmail-date    { font-size: 11px; color: var(--text3); flex-shrink: 0; }

.gmail-thread {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gmail-thread-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 680px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.gmail-thread-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.gmail-thread-subject { font-size: 17px; font-weight: 700; }
.gmail-thread-meta    { font-size: 12px; color: var(--text2); margin-top: 4px; }
.gmail-thread-body    { font-size: 14px; line-height: 1.8; color: var(--text2); white-space: pre-wrap; border-top: 1px solid var(--border); padding-top: 16px; }
.close-btn { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.close-btn:hover { color: var(--text); background: var(--bg3); }

/* ─── Sites ───────────────────────────────────────────────── */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
  align-content: start;
}

.site-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.site-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-dot-lg { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.site-card-name { font-size: 14px; font-weight: 700; }
.site-card-url  { font-size: 12px; color: var(--accent); text-decoration: none; }
.site-card-url:hover { text-decoration: underline; }
.site-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.site-status-badge {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.site-status-badge.ok      { background: rgba(16,185,129,0.1); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.site-status-badge.down    { background: rgba(239,68,68,0.1);  color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.site-status-badge.checking { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

/* ─── Workflows ───────────────────────────────────────────── */
.workflows-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workflow-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.workflow-name  { font-size: 14px; font-weight: 600; flex: 1; }
.workflow-sched { font-size: 12px; color: var(--text2); }
.workflow-last  { font-size: 12px; color: var(--text3); }

/* ─── Selects ─────────────────────────────────────────────── */
.select-sm {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}
.select-sm:focus { border-color: var(--accent); }

/* ─── Toggle ──────────────────────────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
}
.toggle-label input[type=checkbox] { accent-color: var(--accent); }

/* ─── Empty / Utility ─────────────────────────────────────── */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text3);
  font-size: 14px;
}

.logs-empty {
  padding: 40px;
  text-align: center;
  color: var(--text3);
}

.hidden { display: none !important; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .nav-label, .sidebar-title, .sidebar-sites, .sidebar-section-label { display: none; }
  .sites-grid { grid-template-columns: 1fr; }
  .chat-messages { padding: 16px; }
  .panel-header { padding: 14px 16px; }
}

/* ─── Mobile / Responsive ──────────────────────────────────── */

/* ── Bottom Nav Bar (mobile only) ── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 300;
  align-items: stretch;
  justify-content: space-around;
  padding: 0 4px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.mob-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 6px 2px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mob-nav-btn .mob-nav-icon { font-size: 20px; line-height: 1; }
.mob-nav-btn.active { color: var(--accent); }
.mob-nav-btn.active .mob-nav-icon { transform: scale(1.1); }

/* Badge on bottom nav */
.mob-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.mob-nav-btn { position: relative; }

/* Mobile "More" slide-up drawer */
.mob-more-drawer {
  display: none;
  position: fixed;
  bottom: 60px; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 299;
  padding: 12px 16px 8px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.mob-more-drawer.open {
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateY(0);
}
.mob-drawer-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.mob-drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.mob-drawer-item:active { background: var(--bg3); }
.mob-drawer-item .mob-di-icon { font-size: 20px; width: 28px; text-align: center; }

/* Drawer backdrop */
.mob-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 298;
}
.mob-drawer-backdrop.active { display: block; }

@media (max-width: 768px) {
  /* Show bottom nav */
  .mobile-bottom-nav { display: flex; }

  /* Hide desktop sidebar entirely */
  .sidebar { display: none !important; }

  /* Main content full width, with bottom padding for nav bar */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: 60px;
  }

  /* Panels comfortable on mobile */
  .panel-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .panel-title { font-size: 16px; }
  .panel-actions { gap: 6px; }

  /* Chat */
  .chat-messages { padding: 12px 12px 0; gap: 12px; }
  .chat-input-area { padding: 8px 12px 10px; }
  .chat-input-row { gap: 8px; }
  .chat-textarea {
    font-size: 15px;
    min-height: 42px;
    padding: 10px 12px;
  }
  .chat-send-btn, .btn.btn-primary.btn-send {
    width: 42px;
    height: 42px;
    font-size: 18px;
    flex-shrink: 0;
    padding: 0;
  }
  .btn-attach { width: 42px; height: 42px; }

  /* Quick action chips wrap */
  .quick-actions { gap: 8px; flex-wrap: wrap; justify-content: center; }
  .quick-btn { font-size: 13px; padding: 8px 12px; }

  /* Welcome screen */
  .chat-welcome { padding: 24px 16px; }
  .welcome-icon { font-size: 36px; }
  .chat-welcome h2 { font-size: 18px; }
  .chat-welcome p { font-size: 13px; }

  /* Bubbles */
  .msg-user { max-width: 88%; }
  .msg-agent { max-width: 96%; }
  .msg-bubble { font-size: 14px; line-height: 1.55; }

  /* Site selector full width above textarea on mobile */
  .chat-input-row { flex-wrap: wrap; }
  .site-selector { width: 100%; order: -1; }
  .site-selector .select-sm { width: 100%; font-size: 14px; padding: 8px 10px; }

  /* Hints smaller */
  .chat-hints { font-size: 11px; }

  /* Grids single column */
  .sites-grid,
  .workflows-grid,
  .log-grid,
  .approvals-grid { grid-template-columns: 1fr !important; }

  /* Cards */
  .approval-card,
  .log-entry,
  .workflow-card,
  .site-card { padding: 14px 12px; }

  /* Panel content */
  .panel-content { padding: 12px; }

  /* Settings page */
  .login-card { width: 92vw; padding: 28px 20px; }

  /* Status bar */
  .status-bar { flex-wrap: wrap; gap: 6px; font-size: 11px; padding: 6px 12px; }

  /* File chips */
  .file-chip { max-width: 160px; }
  .file-preview-strip { padding: 6px 0 4px; }

  /* Logs filters scroll horizontally */
  .logs-filters {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 390px) {
  .mob-nav-btn { font-size: 9px; }
  .mob-nav-btn .mob-nav-icon { font-size: 18px; }
  .quick-btn { font-size: 12px; padding: 7px 10px; }
}

/* ─── File Upload ────────────────────────────────────────── */

/* Attach (+) button */
.btn-attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-attach:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--accent);
}
.btn-attach.has-files {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.file-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 6px;
  font-size: 12px;
  color: var(--text);
  max-width: 200px;
  position: relative;
}

.file-chip-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.file-chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.file-chip-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 2px;
}
.file-chip-remove:hover { color: var(--red); }

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(108,99,255,0.15);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  z-index: 10;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  pointer-events: none;
}
.drop-overlay.active { display: flex; }

.chat-input-area { position: relative; }

.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.msg-img-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.msg-img-thumb:hover { opacity: 0.8; }

.msg-file-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
}

/* ── Stop Button ──────────────────────────────────────────────── */
.btn-stop {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--red, #EF4444);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.4);
  animation: pulse-red 1.4s ease-in-out infinite;
}
.btn-stop:hover {
  background: #DC2626;
  transform: scale(1.06);
}
.btn-stop:active {
  transform: scale(0.96);
}
@keyframes pulse-red {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* Inline stop-run button inside chat status bar */
.stop-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--red, #EF4444);
  border-radius: 6px;
  background: transparent;
  color: var(--red, #EF4444);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  vertical-align: middle;
}
.stop-run-btn:hover {
  background: var(--red, #EF4444);
  color: #fff;
}

/* Pulsing status badge while running */
.status-badge.pulsing {
  animation: badge-pulse 1.2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ─── Analytics Tab ──────────────────────────────────────── */
.analytics-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.analytics-period {
  font-size: 12px;
  color: var(--text3);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.analytics-site-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.analytics-site-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.analytics-site-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.analytics-site-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.analytics-site-url {
  font-size: 11px;
  color: var(--text3);
  text-decoration: none;
}
.analytics-site-url:hover { color: var(--accent); text-decoration: underline; }

.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.analytics-metric {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}
.analytics-metric:last-child { border-right: none; }
.analytics-metric:nth-child(4) { border-right: none; }
.analytics-metric:nth-child(n+5) { border-top: 1px solid var(--border); }

.analytics-metric-label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.analytics-metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.analytics-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--border);
}

.analytics-table-wrap {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}
.analytics-table-wrap:last-child { border-right: none; }

.analytics-table-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.analytics-error {
  font-size: 11px;
  color: var(--red);
}

/* Responsive: stack to 2 cols on small screens */
@media (max-width: 700px) {
  .analytics-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-metric:nth-child(2) { border-right: none; }
  .analytics-metric:nth-child(even) { border-right: none; }
  .analytics-metric:nth-child(n+3) { border-top: 1px solid var(--border); }
  .analytics-tables { grid-template-columns: 1fr; }
  .analytics-table-wrap { border-right: none; border-top: 1px solid var(--border); }
}
