/* =============================================================
   Grist Extension — styles.css
   ============================================================= */

/* ─── SIDEBAR ─────────────────────────────────────────────── */
#gext-sidebar {
  position: fixed;
  bottom: 60px;
  left: 0;
  width: 220px;
  background: var(--grist-color-light-bg, #fff);
  border-right: 1px solid #e2e8f0;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 4px 16px rgba(0,0,0,.1);
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  overflow: hidden;
  will-change: transform;
  transition: width .2s ease;
}

#gext-sidebar.gext-collapsed {
  width: 80px;
}

#gext-sidebar.gext-collapsed .gext-sidebar-header {
  padding: 10px 6px;
  justify-content: flex-start;
}

#gext-sidebar.gext-collapsed #gext-my-badge,
#gext-sidebar.gext-collapsed .gext-lk-bar,
#gext-sidebar.gext-collapsed .gext-sidebar-title,
#gext-sidebar.gext-collapsed .gext-sidebar-section-title,
#gext-sidebar.gext-collapsed .gext-sidebar-hint {
  display: none;
}

.gext-presence-panel {
  transition: opacity .18s ease;
}

/* Новый пользователь в панели — slide in */
.gext-user-row {
  animation: gext-user-appear .2s ease;
}
@keyframes gext-user-appear {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.gext-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f7fafc;
}

.gext-sidebar-title {
  flex: 1;
  font-weight: 600;
  color: #2d3748;
}

#gext-sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #718096;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 4px;
}

.gext-sidebar-section-title {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #a0aec0;
}

.gext-sidebar-hint {
  padding: 8px 12px;
  font-size: 11px;
  color: #a0aec0;
}

/* ─── PRESENCE PANEL ─────────────────────────────────────── */
.gext-presence-panel {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.gext-user-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gext-user-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2d3748;
}

.gext-user-status {
  font-size: 11px;
  white-space: nowrap;
}

/* ─── AVATAR ──────────────────────────────────────────────── */
.gext-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ─── ROW PRESENCE BADGE ─────────────────────────────────── */
/* position/top/left/transform задаются inline через getBoundingClientRect */
.gext-presence-badge-row {
  border: 2px solid transparent;
  border-radius: 50%;
  z-index: 9995;
  pointer-events: none;
}

/* ─── LK FILTER BAR ──────────────────────────────────────── */
.gext-lk-bar {
  padding: 4px 8px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.gext-lk-btn {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #4a5568;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.gext-lk-btn:hover {
  background: #ebf8ff;
  border-color: #bee3f8;
}

.gext-lk-btn.active {
  background: #3182ce;
  color: #fff;
  border-color: #3182ce;
}

.gext-lk-all {
  background: #f7fafc;
  font-weight: 600;
}

/* ─── НИЖНИЕ КНОПКИ ──────────────────────────────────────── */
#gext-bottom-btns {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 6px;
}

#gext-statusbar-toggle {
  background: #2d3748;
  color: #e2e8f0;
  border: none;
  border-radius: 20px;
  padding: 4px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: background .15s;
  user-select: none;
}

#gext-statusbar-toggle:hover { background: #4a5568; }

#gext-search-btn {
  background: #f0f2f5;
  color: #1a1d27;
  border: none;
  border-radius: 20px;
  width: 30px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: background .15s;
  padding: 0;
}

#gext-search-btn:hover { background: #e2e6ea; }

#gext-statusbar {
  position: fixed;
  bottom: 40px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 20px;
  font-size: 12px;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}

#gext-statusbar.gext-bar-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#gext-statusbar-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity .15s ease;
}

.gext-statbar-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.gext-statbar-row-workers {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 6px;
  gap: 16px;
}

.gext-stat-worker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 2px 8px;
}

.gext-stat b {
  color: #fff;
}

.gext-stat-online b {
  color: #68d391;
}

.gext-stat-online b {
  color: #68d391;
}

/* ─── SPOTLIGHT ──────────────────────────────────────────── */
#gext-spotlight {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.18);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  z-index: 99999;
  animation: gext-fade-in .15s ease;
}

@keyframes gext-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gext-spotlight-box {
  width: 580px;
  background: #ffffff;
  border: 1px solid #e2e6ea;
  border-radius: 14px;
  box-shadow: 0 32px 120px rgba(0,0,0,.45), 0 8px 32px rgba(0,0,0,.2);
  overflow: hidden;
  animation: gext-slide-down .15s ease;
}

@keyframes gext-slide-down {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.gext-spotlight-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e6ea;
}

.gext-spotlight-icon {
  font-size: 16px;
  opacity: 0.5;
  flex-shrink: 0;
}

#gext-spotlight-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  color: #1a1d27;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#gext-spotlight-input::placeholder { color: #a0aec0; }

.gext-spotlight-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #a0aec0;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color .12s;
}
.gext-spotlight-close:hover { color: #4a5568; }

#gext-spotlight-results {
  max-height: 360px;
  overflow-y: auto;
}

#gext-spotlight-results::-webkit-scrollbar { width: 4px; }
#gext-spotlight-results::-webkit-scrollbar-track { background: transparent; }
#gext-spotlight-results::-webkit-scrollbar-thumb { background: #2d3555; border-radius: 2px; }

.gext-result-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background .1s;
}

.gext-result-row:hover  { background: #f7f8fa; }
.gext-result-row:last-child { border-bottom: none; }

.gext-result-plate {
  font-weight: 700;
  font-size: 13px;
  color: #2d3748;
  min-width: 95px;
  font-family: 'Courier New', monospace;
  background: #eef0f3;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: .04em;
}

.gext-result-brand {
  flex: 1;
  color: #4a5568;
  font-size: 13px;
}

.gext-result-lk {
  font-size: 11px;
  color: #718096;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gext-result-status {
  font-size: 12px;
  flex-shrink: 0;
}

.gext-spotlight-empty {
  padding: 32px 20px;
  text-align: center;
  color: #a0aec0;
  font-size: 13px;
}

.gext-spotlight-footer {
  padding: 8px 18px;
  border-top: 1px solid #e2e6ea;
  font-size: 10px;
  color: #a0aec0;
  display: flex;
  gap: 14px;
}

.gext-spotlight-footer kbd {
  background: #eef0f3;
  color: #718096;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: inherit;
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────── */
#gext-toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.gext-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2d3748;
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  font-size: 13px;
  pointer-events: all;
  animation: gext-slide-in .2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.gext-toast-success { border-left: 4px solid #68d391; }
.gext-toast-warning { border-left: 4px solid #f6e05e; }
.gext-toast-info    { border-left: 4px solid #63b3ed; }

.gext-toast-text { flex: 1; }

.gext-toast-close {
  background: none;
  border: none;
  color: #a0aec0;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
}

/* ─── PRESENCE EDGE INDICATOR (строка вне поля зрения) ───── */
.gext-presence-edge {
  position: fixed;
  left: 240px;
  width: fit-content;
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  border-radius: 6px;
  z-index: 9990;
  pointer-events: none;
  font-size: 11px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #fff;
  opacity: 0.88;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.gext-presence-edge .gext-avatar {
  width: 18px;
  height: 18px;
  font-size: 9px;
  flex-shrink: 0;
}

.gext-presence-edge-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

/* ─── COMMENT DOT ────────────────────────────────────────── */
.gext-comment-dot {
  position: absolute;
  top: 2px;
  right: 24px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3182ce;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
}

/* ─── ANIMATIONS ─────────────────────────────────────────── */
@keyframes gext-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── DARK MODE ПОДДЕРЖКА ────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  #gext-sidebar {
    background: #1a202c;
    border-color: #2d3748;
  }
  .gext-sidebar-header { background: #2d3748; }
  .gext-sidebar-title  { color: #e2e8f0; }
  .gext-user-name      { color: #e2e8f0; }
  .gext-lk-btn         { background: #2d3748; color: #e2e8f0; border-color: #4a5568; }
  .gext-spotlight-box  { background: #1a202c; }
  #gext-spotlight-input{ background: #1a202c; color: #e2e8f0; border-color: #2d3748; }
  .gext-result-row:hover { background: #2d3748; }
  .gext-result-plate   { color: #e2e8f0; }
  .gext-result-brand   { color: #a0aec0; }
}

.gext-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gext-user-table {
  font-size: 10px;
  color: #a0aec0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gext-user-agent {
  font-size: 10px;
  color: #718096;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── ПЕЧАТЬ — скрываем все кастомные оверлеи ───────────── */
@media print {
  #gext-sidebar,
  #gext-sidebar-toggle,
  #gext-statusbar,
  #gext-statusbar-toggle,
  #gext-canvas,
  #gext-toast-container,
  #gext-spotlight,
  #gext-presence-panel {
    display: none !important;
  }
}