/* ============================================
   PaneHub App-Like Demo Styles
   Full-screen terminal grid experience
   ============================================ */

/* Base app layout */
html, body.panehub-app {
  height: 100%;
  margin: 0;
  padding: 0;
}

body.panehub-app {
  background: #0d1117;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Minimal Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(22, 27, 34, 0.95);
  border-bottom: 1px solid #30363d;
  backdrop-filter: blur(12px);
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo .logo-text {
  font-weight: 700;
  font-size: 16px;
  background: linear-gradient(135deg, #7c3aed, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.live-text {
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.viewer-count {
  color: #8b949e;
  padding-left: 6px;
  border-left: 1px solid #30363d;
}

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

.header-link {
  color: #8b949e;
  font-size: 13px;
  font-weight: 500;
}

.header-link:hover { color: #f0f6fc; }

.header-cta {
  padding: 6px 14px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.2s;
}

.header-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
  color: white;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.total-count {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #8b949e;
  font-size: 13px;
  font-weight: 600;
}

.total-count span { color: #f0f6fc; }

.status-divider {
  width: 1px;
  height: 16px;
  background: #30363d;
}

.status-chips {
  display: flex;
  gap: 8px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-chip.working {
  background: rgba(88, 166, 255, 0.15);
  border-color: rgba(88, 166, 255, 0.4);
  color: #58a6ff;
}

.status-chip.waiting {
  background: rgba(210, 153, 34, 0.15);
  border-color: rgba(210, 153, 34, 0.4);
  color: #d29922;
}

.status-chip.waiting.pulse {
  animation: chip-pulse 1.5s ease-in-out infinite;
}

@keyframes chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(210, 153, 34, 0.1); }
}

.status-chip.idle {
  background: rgba(139, 148, 158, 0.15);
  border-color: rgba(139, 148, 158, 0.3);
  color: #8b949e;
}

.status-chip.complete {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.4);
  color: #3fb950;
}

.status-chip.error {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.4);
  color: #f85149;
}

.chip-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(88, 166, 255, 0.3);
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chip-icon { font-size: 10px; }
.chip-count { font-weight: 700; }
.chip-label { opacity: 0.8; }

.status-right { display: flex; align-items: center; }

.attention-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid rgba(210, 153, 34, 0.5);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: #d29922;
  animation: attention-glow 2s ease-in-out infinite;
}

@keyframes attention-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(210, 153, 34, 0.2); }
  50% { box-shadow: 0 0 16px rgba(210, 153, 34, 0.4); }
}

/* Main App Container */
.app-main {
  flex: 1;
  display: flex;
  padding: 12px;
  gap: 12px;
  overflow: hidden;
  position: relative;
}

/* Terminal Grid - 4x3 layout */
.terminal-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  overflow: hidden;
  min-height: 0; /* Allow flex shrink */
  height: 100%; /* Ensure grid takes full height */
}

@media (max-width: 1400px) {
  .terminal-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
  }
}

@media (max-width: 1000px) {
  .terminal-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }
}

/* Terminal Tile */
.terminal-tile {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.2s ease;
  position: relative;
  min-height: 120px;
  /* Override terminal.css which sets opacity: 0 by default */
  opacity: 1 !important;
  transform: scale(1) !important;
}

.terminal-tile:hover {
  border-color: #58a6ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.terminal-tile.status-working { border-color: rgba(88, 166, 255, 0.5); }
.terminal-tile.status-waiting {
  border-color: rgba(210, 153, 34, 0.6);
  animation: tile-pulse 2s ease-in-out infinite;
}
.terminal-tile.status-complete { border-color: rgba(63, 185, 80, 0.5); }
.terminal-tile.status-error { border-color: rgba(248, 81, 73, 0.5); }

@keyframes tile-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.3); }
  50% { box-shadow: 0 0 12px 2px rgba(210, 153, 34, 0.2); }
}

/* Tile Header */
.tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(22, 27, 34, 0.6);
  border-bottom: 1px solid #21262d;
}

.tile-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #21262d;
  border-radius: 4px;
}

.tile-info { flex: 1; min-width: 0; }

.tile-name {
  font-size: 12px;
  font-weight: 600;
  color: #f0f6fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-path {
  font-size: 10px;
  color: #8b949e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tile Status Badge */
.tile-status {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.tile-status.working { background: rgba(88, 166, 255, 0.2); color: #58a6ff; }
.tile-status.waiting { background: rgba(210, 153, 34, 0.2); color: #d29922; }
.tile-status.idle { background: rgba(139, 148, 158, 0.2); color: #8b949e; }
.tile-status.complete { background: rgba(63, 185, 80, 0.2); color: #3fb950; }
.tile-status.error { background: rgba(248, 81, 73, 0.2); color: #f85149; }

/* Tile Body - Terminal Preview */
.tile-body {
  flex: 1;
  padding: 6px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  line-height: 1.4;
  color: #8b949e;
  overflow: hidden;
  background: #0d1117;
}

.tile-body .output-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-body .output-line.command { color: #58a6ff; }
.tile-body .output-line.success { color: #3fb950; }
.tile-body .output-line.error { color: #f85149; }

/* Tile Footer */
.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(22, 27, 34, 0.4);
  border-top: 1px solid #21262d;
  font-size: 10px;
}

.tile-agent {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #7c3aed;
  font-weight: 500;
}

/* Viewer Presence in Footer */
.tile-viewers {
  display: flex;
  align-items: center;
  gap: 0;
}

.tile-viewer-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #0d1117;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  margin-left: -6px;
  background: linear-gradient(135deg, #7c3aed, #f472b6);
}

.tile-viewer-avatar:first-child { margin-left: 0; }

.tile-viewer-count {
  padding: 2px 6px;
  background: rgba(124, 58, 237, 0.3);
  border-radius: 100px;
  font-size: 9px;
  color: #a78bfa;
  margin-left: 4px;
  font-weight: 500;
}

.tile-typing {
  position: absolute;
  bottom: 32px;
  left: 8px;
  right: 8px;
  padding: 4px 8px;
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid rgba(124, 58, 237, 0.4);
  border-radius: 4px;
  font-size: 9px;
  color: #a78bfa;
  animation: typing-fade 1s ease-in-out infinite;
}

@keyframes typing-fade {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Floating Chat Panel */
.chat-panel {
  width: 280px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-panel.minimized .chat-body,
.chat-panel.minimized .chat-input-wrap {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(22, 27, 34, 0.8);
  border-bottom: 1px solid #30363d;
}

.chat-title {
  font-size: 13px;
  font-weight: 600;
  color: #f0f6fc;
}

.chat-online {
  flex: 1;
  font-size: 11px;
  color: #8b949e;
  text-align: right;
}

.chat-minimize {
  width: 20px;
  height: 20px;
  background: #21262d;
  border: none;
  border-radius: 4px;
  color: #8b949e;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.chat-minimize:hover { background: #30363d; color: #f0f6fc; }

.chat-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
}

.chat-message {
  display: flex;
  gap: 8px;
  animation: msg-appear 0.3s ease;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #f472b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-content { flex: 1; min-width: 0; }

.chat-username {
  font-size: 11px;
  font-weight: 600;
  color: #a78bfa;
  margin-bottom: 2px;
}

.chat-text {
  font-size: 12px;
  color: #f0f6fc;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-typing {
  padding: 0 10px 6px;
  font-size: 11px;
  color: #8b949e;
  font-style: italic;
  min-height: 18px;
}

.chat-input-wrap {
  padding: 8px 10px;
  background: rgba(13, 17, 23, 0.6);
  border-top: 1px solid #30363d;
}

.chat-input {
  width: 100%;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #f0f6fc;
  font-size: 12px;
}

.chat-input:disabled { opacity: 0.5; }

/* Feature Toast */
.feature-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(168, 85, 247, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.4);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.feature-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon { font-size: 18px; }
.toast-text { flex: 1; }

/* Responsive */
@media (max-width: 768px) {
  .chat-panel { display: none; }
  .terminal-grid { grid-template-columns: repeat(2, 1fr); }
  .status-chips { display: none; }
}

