/* Ensure latestLogLine is always visible below toolbars */
#latestLogLine {
  position: fixed;
  top: calc(var(--header-height, 56px) + var(--toolbar2-height, 40px));
  left: 0;
  width: 100vw;
  z-index: 1001;
  background: #e8f5e9;
  font-size: 13px;
  color: var(--text, #1d1d1f);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border, #e5e5e7);
  box-sizing: border-box;
  display: block;
  height: var(--latestlogline-height, 32px);
  transition: top 0.2s;
}

#gridAreaWrapper {
  margin-top: calc(var(--header-height, 56px) + var(--toolbar2-height, 40px) + var(--latestlogline-height, 32px));
}

/* Highlight for grid area when paused */
#gridAreaWrapper.paused-updates-bg {
  background: linear-gradient(180deg, #ffb347 0%, #ff8800 100%) !important;
  border-radius: 16px;
  box-shadow: 0 0 32px 0 #ffb34755;
  padding: 12px 0 18px 0;
  transition: background 0.3s, box-shadow 0.3s;
}

/* Toast notification: bottom right positioning */
#toast {
  position: fixed;
  right: 32px;
  bottom: 32px;
  z-index: 9999;
  min-width: 220px;
  max-width: 360px;
  background: rgba(40, 40, 40, 0.97);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.5;
  display: none;
  cursor: default;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.98;
  user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.toast-content {
  min-width: 0;
  user-select: text;
}

.toast-close {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toast-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

/* Charts panel layout fix */
/* Docked right sidebar for charts panel */
#chartsPanel {
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 95vw;
  min-width: 320px;
  z-index: 9998;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  border-radius: 18px 0 0 18px;
  overflow: hidden;
}

#chartsPanel.open {
  display: flex;
}

.charts-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: auto;
  min-height: 0;
}

#chartsFrameContainer {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

#chartsFrame {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: none;
  flex: 1 1 auto;
  background: #fff;
  border-radius: 0;
}

/* ========================================
   VINE MONITOR - CONTENT & LOG STYLING  
   Log output display and item grid layout
   ======================================== */

/* Log output display area (pre-formatted text) */
#gridAreaWrapper {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: calc(var(--header-height, 56px) + var(--toolbar2-height, 40px) + var(--latestlogline-height, 32px));
}

#log {
  margin: 0;
  white-space: pre-wrap;
  padding: 0 5px 5px 5px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Color classes */
.new-item-line {
  color: #2cdb66;
  font-weight: bold;
}

.priority-line {
  color: #ff66ff;
  font-weight: bold;
}

.checking-line {
  color: #66aaff;
  font-weight: bold;
}

.found-line {
  color: #f7b304;
  font-weight: bold;
}

.found-new-line {
  color: #ff4444;
  font-weight: bold;
}

.error-line {
  color: #ff4444;
  font-weight: bold;
}

.warning-line {
  color: #ffa500;
  font-weight: bold;
}

.bullet::before {
  content: " • ";
  color: #888;
}

.normal-line {
  display: inline;
}

.log-item-with-preview {
  display: block;
  margin-bottom: 6px;
}

.item-preview {
  margin-left: 24px;
  margin-top: 3px;
}

.item-preview img {
  max-height: 72px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* #toast rules removed; use only the top-of-file rules for bottom-right positioning */

/* Item list */
.list-item,
.process-item,
.log-item,
.entry,
#log .line {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(29, 29, 31, 0.04);
}

.list-item+.list-item,
.process-item+.process-item,
.log-item+.log-item,
.entry+.entry {
  margin-top: 8px;
}

.list-item .title,
.process-item .title,
.log-item .title,
.entry .title {
  color: var(--text);
  font-weight: 600;
}

.list-item .meta,
.process-item .meta,
.log-item .meta,
.entry .meta {
  color: var(--muted-text);
  font-size: 13px;
}

.list-item:hover,
.process-item:hover,
.log-item:hover,
.entry:hover,
#log .line:hover {
  background: rgba(0, 0, 0, 0.02);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.06);
}

.status-badge {
  background: rgba(0, 0, 0, 0.03);
  color: var(--muted-text);
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 600;
}

.status-running {
  background: rgba(52, 199, 89, 0.12);
  color: #034e2f;
}

.status-stopped {
  background: rgba(255, 59, 48, 0.08);
  color: #7a1411;
}

.status-error {
  background: rgba(255, 69, 58, 0.08);
  color: #7a1411;
}

.preview {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

:root {
  --grid-cols: 4;
}

/* Grid view for previews */
#log.grid-view {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  gap: 8px;
  padding: 12px;
  white-space: normal;
  align-items: start;
}


.grid-item {
  display: flex;
  flex-direction: column;
  max-width: 200px;
  margin: 0 auto;
  width: 100%;
  flex: 1 1 auto;
}

.grid-item-favorite {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(249, 115, 22, 0.13) 100%);
  border-radius: 8px;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.22), inset 0 0 4px rgba(239, 68, 68, 0.15);
  border: 2px solid rgba(242, 11, 11, 0.7);
  transition: box-shadow 120ms ease;
}


.grid-item-favorite:hover {
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.38), inset 0 0 7px rgba(239, 68, 68, 0.22);
}

/* Alert-enabled priority items pulse indefinitely */
.grid-item-alert {
  animation: alert-pulse 1.2s ease-in-out infinite;
}

/* Stop pulse when item is dimmed (above the flagged marker) */
.grid-item-alert.grid-item-dimmed {
  animation: none;
}

@keyframes alert-pulse {
  0%, 100% {
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.24), inset 0 0 4px rgba(59, 130, 246, 0.16);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.72), inset 0 0 10px rgba(96, 165, 250, 0.38), 0 0 40px rgba(14, 165, 233, 0.42);
    transform: scale(1.03);
  }
}

.grid-item-rfy {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.32) 0%, rgba(253, 224, 71, 0.26) 100%);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.42), inset 0 0 12px rgba(250, 204, 21, 0.3);
  border: 2px solid rgba(234, 179, 8, 0.58);
  transition: box-shadow 120ms ease;
}

.grid-item-rfy:hover {
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.62), inset 0 0 14px rgba(250, 204, 21, 0.4);
}

.grid-item-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.grid-item-link:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.15);
}

.grid-item-img {
  width: 100%;
  height: auto;
  max-width: 180px;
  aspect-ratio: 1/1;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: block;
}

.grid-item-text {
  font-size: 12px;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  font-weight: 600;
}

.grid-item-link:hover .grid-item-text {
  color: var(--primary);
}

.grid-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  width: calc(100% - 4px);
  margin: 10px 2px 0 2px;
  padding-top: 2px;
}

.grid-item-actions .action-link {
  background: var(--surface);
  border-color: var(--border);
}

.grid-item-actions .grid-item-search-link.action-link {
  flex: 1;
  width: auto;
  height: 24px;
  padding: 0 6px;
  font-size: 11px;
  border-radius: 4px;
}

.grid-item-actions .grid-item-flag-link.action-link {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  font-size: 13px;
  border-radius: 4px;
}

.grid-item.grid-item-flagged .grid-item-link {
  border-color: #44ff00;
  border-width: 2px;
  background: rgba(34, 197, 94, 0.18);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.55), 0 0 24px rgba(34, 197, 94, 0.78), 0 10px 24px rgba(34, 197, 94, 0.45);
}

.grid-item.grid-item-dimmed {
  opacity: 0.68;
  filter: saturate(0.82) brightness(0.92);
  position: relative;
}
}