/*
Theme Name: Endev
Theme URI: https://endev.local
Author: Endev Team
Description: Minimalist dashboard theme with Preact and multisite API support
Version: 1.0.0
License: GPL v2
Text Domain: endev
*/

/* ===== CSS Variables ===== */
:root {
  /* Dark theme (default) */
  --color-bg: #0a0a0a;
  --color-surface: #141414;
  --color-surface-elevated: #1a1a1a;
  --color-border: #262626;
  --color-text: #e5e5e5;
  --color-text-muted: #737373;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  
  --status-idle: #ef4444;
  --status-loading: #22c55e;
  --status-emitting: #3b82f6;
  
  --top-height: 48px;
  --status-height: 24px;
  --left-collapsed: 48px;
  --left-expanded: 240px;
  --right-width: 320px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', Monaco, monospace;
  
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 500ms ease;

  /* Customization defaults */
  --color-accent-blue: #3b82f6;
  --color-accent-green: #22c55e;
  --color-accent-purple: #8b5cf6;
  --color-accent-orange: #f59e0b;
  
  /* Density multipliers */
  --density-scale: 1;
  --spacing-unit: calc(8px * var(--density-scale));
  
  /* Typography scale */
  --font-size-scale: 1;
  --font-family: var(--font-sans);
}

/* Light theme */
[data-theme="light"] {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-surface-elevated: #f5f5f5;
  --color-border: #e5e5e5;
  --color-text: #171717;
  --color-text-muted: #737373;
  --color-accent: var(--color-accent-blue);
  --color-accent-hover: #2563eb;
}

/* Density modes */
.density-compact { --density-scale: 0.6; }
.density-comfortable { --density-scale: 1.4; }

/* Typography modes */
.font-size-small { --font-size-scale: 0.875; }
.font-size-large { --font-size-scale: 1.125; }
.font-size-xl { --font-size-scale: 1.25; }

.font-family-serif { --font-family: var(--font-serif); }
.font-family-mono { --font-family: var(--font-mono); }

/* Reduced motion mode */
.reduced-motion,
.reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: calc(14px * var(--font-size-scale));
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
}

#endev-root {
  height: 100vh;
  width: 100vw;
}

/* ===== Layout ===== */
.app-container {
  display: grid;
  grid-template-areas:
    "top top top"
    "left main right"
    "status status status";
  grid-template-rows: var(--top-height) 1fr var(--status-height);
  grid-template-columns: auto 1fr auto;
  height: 100vh;
  width: 100vw;
}

/* When right panel is collapsed, main content takes full width */
.app-container.right-collapsed {
  grid-template-areas:
    "top top"
    "left main"
    "status status";
  grid-template-columns: auto 1fr;
}

.app-container.right-collapsed .right-panel {
  display: none;
}

/* ===== Top Bar ===== */
.top-bar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: calc(12px * var(--density-scale));
  padding: 0 calc(16px * var(--density-scale));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--color-surface-elevated);
}

.logo {
  font-weight: 600;
  font-size: 16px;
  color: var(--color-text);
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.panel-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.panel-toggle-btn:hover {
  background: var(--color-surface-elevated);
}

.panel-toggle-btn.active {
  background: var(--color-accent);
  color: white;
}

.panel-toggle-btn .icon {
  stroke-width: 2;
  fill: none;
}

/* ===== Left Panel ===== */
.left-panel {
  grid-area: left;
  display: flex;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  transition: width var(--transition-base);
  overflow: hidden;
}

.left-panel.collapsed {
  width: var(--left-collapsed);
}

.left-panel.expanded {
  width: var(--left-expanded);
}

.toolbar-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--left-collapsed);
  padding: 8px 0;
  gap: 4px;
  flex-shrink: 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.tool-btn:hover,
.tool-btn.active {
  background: var(--color-surface-elevated);
  color: var(--color-text);
}

.sidebar-content {
  flex: 1;
  padding: calc(16px * var(--density-scale));
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
}

.sidebar-content h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.sidebar-content nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-content nav a {
  display: block;
  padding: calc(8px * var(--density-scale)) calc(12px * var(--density-scale));
  color: var(--color-text);
  text-decoration: none;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.sidebar-content nav a:hover {
  background: var(--color-surface-elevated);
}

/* ===== Main Content ===== */
.main-content {
  grid-area: main;
  background: var(--color-bg);
  overflow-y: auto;
  padding: calc(24px * var(--density-scale));
}

/* Page content styling */
.main-content .page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

.main-content .page-content {
  line-height: 1.7;
  color: var(--color-text);
}

.main-content .page-content p {
  margin-bottom: 16px;
}

.main-content .page-content h2,
.main-content .page-content h3,
.main-content .page-content h4 {
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--color-text);
}

.main-content .page-content a {
  color: var(--color-accent);
  text-decoration: underline;
}

.main-content .page-content a:hover {
  color: var(--color-accent-hover);
}

.main-content .page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.main-content .page-content ul,
.main-content .page-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.main-content .page-content li {
  margin-bottom: 4px;
}

.main-content .page-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--color-text-muted);
}

/* Archive/Posts list */
.main-content .posts-list {
  margin-top: 24px;
}

.main-content .post-item {
  padding: calc(16px * var(--density-scale)) 0;
  border-bottom: 1px solid var(--color-border);
}

.main-content .post-item h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.main-content .post-item h2 a {
  color: var(--color-text);
  text-decoration: none;
}

.main-content .post-item h2 a:hover {
  color: var(--color-accent);
}

.main-content .archive-description {
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

/* ===== Right Panel ===== */
.right-panel {
  grid-area: right;
  display: flex;
  flex-direction: column;
  width: var(--right-width);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  transition: transform var(--transition-base), width var(--transition-base);
}

.right-panel.collapsed {
  width: 0;
  transform: translateX(100%);
}

.right-panel.resizable {
  resize: horizontal;
  overflow: auto;
  min-width: 240px;
  max-width: 480px;
  position: relative;
}

.right-panel.resizable::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60px;
  background: var(--color-border);
  border-radius: 2px;
  cursor: col-resize;
  transition: background 0.2s;
}

.right-panel.resizable:hover::before {
  background: var(--color-accent);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px * var(--density-scale)) calc(16px * var(--density-scale));
  border-bottom: 1px solid var(--color-border);
}

.panel-title {
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-elevated);
}

.tab {
  padding: calc(10px * var(--density-scale)) calc(16px * var(--density-scale));
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  background: var(--color-surface);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: calc(16px * var(--density-scale));
}

/* ===== Status Bar ===== */
.status-bar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: calc(12px * var(--density-scale));
  padding: 0 calc(16px * var(--density-scale));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background-color var(--transition-fast);
}

.status-dot.idle { background: var(--status-idle); }
.status-dot.loading { background: var(--status-loading); }
.status-dot.emitting { 
  background: var(--status-emitting);
  animation: pulse 1.5s ease-in-out infinite;
}

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

.status-message {
  flex: 1;
}

/* ===== Cards & Content ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-weight: 500;
  margin-bottom: 8px;
}

.card-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition-fast);
  margin-left: auto;
}

.theme-toggle:hover {
  background: var(--color-surface-elevated);
  border-color: var(--color-accent);
}

[data-theme="light"] .theme-toggle .moon,
[data-theme="dark"] .theme-toggle .sun,
:root:not([data-theme]) .theme-toggle .sun {
  display: none;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== External Site Content ===== */
.external-post {
  padding: calc(12px * var(--density-scale));
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.external-post:hover {
  background: var(--color-surface-elevated);
}

.external-post:last-child {
  border-bottom: none;
}

.external-post-title {
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.4;
}

.external-post-source {
  font-size: 11px;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Loading States ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Icons ===== */
.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ===== Hero Slider ===== */
.hero-slider-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

.hero-slider-container.modal-open {
  pointer-events: none;
}

.hero-slider-container {
  background: var(--color-bg);
  overflow: hidden;
}

/* Transparent shell when Hero is visible */
.app-container.has-hero {
  background: transparent;
}

.app-container.has-hero > *:not(.hero-slider-container):not(.modal-overlay) {
  position: relative;
  z-index: 10;
}

.app-container.has-hero .top-bar,
.app-container.has-hero .left-panel,
.app-container.has-hero .right-panel,
.app-container.has-hero .status-bar,
.app-container.has-hero .panel-header {
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(255, 255, 255, 0.05);
}
.app-container.has-hero .main-content {
  background: transparent;
  pointer-events: none;
}

[data-theme="light"] .app-container.has-hero .top-bar,
[data-theme="light"] .app-container.has-hero .left-panel,
[data-theme="light"] .app-container.has-hero .right-panel,
[data-theme="light"] .app-container.has-hero .status-bar,
[data-theme="light"] .app-container.has-hero .panel-header {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(0, 0, 0, 0.05);
}

.hero-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}

.hero-slide.active, .hero-slide.leaving {
  opacity: 1;
  pointer-events: auto;
}
.hero-slide.leaving {
  z-index: 1;
  pointer-events: none;
}
.hero-slide.active {
  z-index: 2;
}

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

@keyframes h-slide-right-in { from { transform: translateX(-10%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes h-slide-right-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(10%); opacity: 0; } }

@keyframes h-slide-left-in { from { transform: translateX(10%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes h-slide-left-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-10%); opacity: 0; } }

@keyframes h-zoom-in-in { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes h-zoom-out-out { from { transform: scale(1); opacity: 1; } to { transform: scale(1.05); opacity: 0; } }

/* Entrance Transitions */
.hero-slide.active.in-fade { animation: h-fade-in var(--transition-slow) forwards; }
.hero-slide.active.in-slide_left { animation: h-slide-left-in var(--transition-slow) forwards; }
.hero-slide.active.in-slide_right { animation: h-slide-right-in var(--transition-slow) forwards; }
.hero-slide.active.in-zoom_in { animation: h-zoom-in-in var(--transition-slow) forwards; }

/* Exit Transitions */
.hero-slide.leaving.out-fade { animation: h-fade-out var(--transition-slow) forwards; }
.hero-slide.leaving.out-slide_left { animation: h-slide-left-out var(--transition-slow) forwards; }
.hero-slide.leaving.out-slide_right { animation: h-slide-right-out var(--transition-slow) forwards; }
.hero-slide.leaving.out-zoom_out { animation: h-zoom-out-out var(--transition-slow) forwards; }

.hero-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

/* Hero Effects */
.hero-image.grayscale { filter: grayscale(1); }
.hero-image.blur { filter: blur(5px); }
.hero-image.sepia { filter: sepia(0.8); }
.hero-image.vignette::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 150px rgba(0,0,0,0.7);
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.2) 100%);
  z-index: 0;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 20;
  max-width: 800px;
  padding: 40px;
  color: white;
  pointer-events: auto;
}

.hero-title {
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(30px);
}

.hero-slide.active .hero-title {
  animation: slideUp 0.8s forwards 0.3s;
}

.hero-subtitle {
  font-size: clamp(18px, 2vw, 24px);
  margin-bottom: 32px;
  color: rgba(255,255,255,0.8);
  opacity: 0;
  transform: translateY(20px);
}

.hero-slide.active .hero-subtitle {
  animation: slideUp 0.8s forwards 0.5s;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 32px;
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  font-weight: 600;
  border-radius: 50px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  pointer-events: auto;
  position: relative;
  z-index: 10;
  opacity: 0;
  transform: translateY(20px);
}

.hero-slide.active .hero-btn {
  animation: slideUp 0.8s forwards 0.7s;
}

.hero-btn:hover {
  background: var(--color-accent-hover);
  transform: scale(1.05);
}

@keyframes slideUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Mosaic Grid ===== */
.mosaic-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px;
}

.mosaic-item {
  background: var(--color-surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition: transform var(--transition-base);
}

.mosaic-item:hover { transform: translateY(-4px); }

.mosaic-media {
  height: 200px;
  background-size: cover;
  background-position: center;
}

.mosaic-info { padding: 16px; }
.mosaic-title { font-weight: 600; margin-bottom: 8px; }
.mosaic-meta { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; }

/* ===== Personalization Drawer ===== */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform var(--transition-base);
  box-shadow: -10px 0 30px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-content { padding: 20px; flex: 1; overflow-y: auto; }

.config-section { margin-bottom: 24px; }
.config-label { font-size: 11px; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 12px; font-weight: 500; }

/* Toggle checkbox styling */
.config-section label {
  font-size: 13px;
  color: var(--color-text);
}

.config-section input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* Density buttons */
.density-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  font-size: 12px;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.density-btn.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.density-btn:hover:not(.active) {
  background: var(--color-border);
}

.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.color-swatch { 
  height: 32px; 
  border-radius: 6px; 
  cursor: pointer; 
  border: 2px solid transparent; 
}
.color-swatch.active { border-color: var(--color-text); }

/* ===== Custom Form Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--color-surface);
  padding: 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  position: relative;
  pointer-events: auto;
}

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group textarea {
  width: 100%;
  padding: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  outline: none;
}

.form-group input:focus { border-color: var(--color-accent); }

/* ===== Offline Mode ===== */
body.is-offline {
  filter: grayscale(0.7) brightness(0.75) sepia(0.25);
  transition: filter 1.2s ease;
}

body.is-online {
  filter: none;
  transition: filter 1.2s ease;
}

.offline-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1a1a;
  color: #e5e5e5;
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}

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

.offline-toast .toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: pulse-dot 1.4s ease infinite;
}

.offline-toast.back-online .toast-dot {
  background: #22c55e;
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Chat Panel ===== */
.chat-panel {
  position: fixed;
  top: calc(var(--top-height) + 8px);
  right: 12px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: calc(100vh - var(--top-height) - var(--status-height) - 24px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

.chat-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow: auto;
}

.chat-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.chat-input {
  width: 100%;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 8px;
  padding: 10px 12px;
}

.chat-agent-row {
  width: 100%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-elevated);
  color: var(--color-text);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.chat-agent-row:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-agent-status {
  font-size: 11px;
  text-transform: uppercase;
}

.chat-agent-status.available { color: #22c55e; }
.chat-agent-status.busy { color: #f59e0b; }
.chat-agent-status.unavailable,
.chat-agent-status.offline { color: #ef4444; }

.chat-session-meta {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}

.chat-messages {
  flex: 1;
  min-height: 180px;
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.35;
}

.chat-msg.visitor {
  align-self: flex-end;
  background: var(--color-accent);
  color: white;
}

.chat-msg.agent {
  align-self: flex-start;
  background: var(--color-surface-elevated);
}

.chat-compose {
  display: flex;
  gap: 8px;
}

.chat-send-btn,
.chat-close-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.chat-send-btn {
  background: var(--color-accent);
  color: #fff;
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-close-btn {
  background: #374151;
  color: #fff;
}

.chat-muted {
  font-size: 12px;
  color: var(--color-text-muted);
}
