/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0a0e17;
  color: #e2e8f0;
  -webkit-font-smoothing: antialiased;
}
a { color: #60a5fa; text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== LAYOUT ===== */
.app { display: flex; height: 100vh; width: 100vw; position: relative; }
.toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: rgba(15, 20, 35, 0.92);
  backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.06);
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-title {
  font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-right: 16px; white-space: nowrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
  background: rgba(255,255,255,0.06); color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.15s ease; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.1); color: #f1f5f9; }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white; border: none;
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-icon { padding: 6px 8px; min-width: 32px; justify-content: center; }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ===== CANVAS ===== */
.canvas-container {
  flex: 1; position: relative; overflow: hidden;
  margin-top: 48px; cursor: grab;
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas-container.grabbing { cursor: grabbing; }
.canvas-container.widget-dragging { cursor: move; }
.canvas-transform {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  transform-origin: 0 0; will-change: transform;
}

/* ===== WIDGETS ===== */
.widget {
  position: absolute; border-radius: 12px;
  background: rgba(15, 20, 35, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  overflow: hidden; transition: box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex; flex-direction: column;
}
.widget:hover {
  border-color: rgba(96, 165, 250, 0.3);
  box-shadow: 0 8px 32px rgba(59,130,246,0.15);
}
.widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; cursor: move; user-select: none;
  background: rgba(255,255,255,0.02); border-bottom: 1px solid rgba(255,255,255,0.04);
  min-height: 36px;
}
.widget-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  color: #94a3b8; display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.widget-title .emoji { font-size: 14px; }
.widget-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.widget:hover .widget-actions { opacity: 1; }
.widget-action {
  padding: 3px 6px; border-radius: 4px; font-size: 14px;
  background: transparent; color: #64748b; transition: all 0.1s;
}
.widget-action:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.widget-body {
  flex: 1; overflow: auto; padding: 12px; font-size: 13px; line-height: 1.5;
}
.widget-body iframe {
  width: 100%; height: 100%; border: none; border-radius: 4px;
  background: transparent;
}
.widget-resize {
  position: absolute; bottom: 0; right: 0; width: 16px; height: 16px;
  cursor: nwse-resize; opacity: 0;
}
.widget:hover .widget-resize { opacity: 0.5; }
.widget-resize::after {
  content: ''; position: absolute; bottom: 4px; right: 4px;
  width: 8px; height: 8px; border-right: 2px solid #475569;
  border-bottom: 2px solid #475569; border-radius: 0 0 2px 0;
}
.widget.selected { border-color: rgba(96,165,250,0.5); }
.widget.loading .widget-body { display: flex; align-items: center; justify-content: center; }
.widget.error .widget-body { color: #f87171; }

/* ===== WIDGET SIZES ===== */
.widget.size-sm { width: 280px; height: 200px; }
.widget.size-md { width: 400px; height: 300px; }
.widget.size-lg { width: 560px; height: 400px; }
.widget.size-xl { width: 720px; height: 500px; }
.widget.size-wide { width: 600px; height: 240px; }
.widget.size-tall { width: 320px; height: 480px; }

/* ===== CHAT SIDEBAR ===== */
.chat-sidebar {
  position: fixed; right: 0; top: 48px; bottom: 0; width: 360px;
  background: rgba(15, 20, 35, 0.96); backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; z-index: 90;
  transform: translateX(100%); transition: transform 0.25s ease;
}
.chat-sidebar.open { transform: translateX(0); }
.chat-header {
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header h3 { font-size: 14px; font-weight: 600; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.chat-msg {
  padding: 10px 14px; border-radius: 12px; font-size: 13px;
  line-height: 1.55; max-width: 92%;
}
.chat-msg.user {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white; align-self: flex-end; border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  background: rgba(255,255,255,0.05); align-self: flex-start;
  border-bottom-left-radius: 4px; border: 1px solid rgba(255,255,255,0.06);
}
.chat-msg.system {
  background: rgba(167,139,250,0.1); color: #a78bfa; align-self: center;
  font-size: 12px; text-align: center;
}
.chat-input-area {
  padding: 12px; border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; gap: 8px;
}
.chat-input-area textarea {
  flex: 1; resize: none; height: 40px; padding: 8px 12px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04); color: #e2e8f0; font-size: 13px;
  outline: none; transition: border-color 0.15s;
}
.chat-input-area textarea:focus { border-color: rgba(96,165,250,0.4); }
.chat-input-area textarea::placeholder { color: #475569; }

/* ===== CANVAS CONTROLS ===== */
.canvas-controls {
  position: fixed; bottom: 16px; left: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 4px;
}
.canvas-controls .btn { background: rgba(15,20,35,0.9); backdrop-filter: blur(8px); }

/* ===== ZOOM INDICATOR ===== */
.zoom-indicator {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 80; padding: 4px 12px; border-radius: 6px;
  background: rgba(15,20,35,0.9); backdrop-filter: blur(8px);
  font-size: 12px; color: #64748b; pointer-events: none;
  opacity: 0; transition: opacity 0.3s;
}
.zoom-indicator.visible { opacity: 1; }

/* ===== WIDGET PALETTE ===== */
.widget-palette {
  position: fixed; top: 60px; left: 12px; z-index: 90;
  background: rgba(15, 20, 35, 0.96); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 12px;
  padding: 8px; width: 240px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transform: scale(0.95) translateY(-8px); opacity: 0;
  pointer-events: none; transition: all 0.2s ease;
}
.widget-palette.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }
.palette-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; transition: background 0.1s;
}
.palette-item:hover { background: rgba(255,255,255,0.06); }
.palette-item .emoji { font-size: 18px; width: 24px; text-align: center; }
.palette-item-info { flex: 1; }
.palette-item-name { font-size: 13px; font-weight: 500; }
.palette-item-desc { font-size: 11px; color: #64748b; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: rgba(15, 20, 35, 0.98); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 24px; width: 90%; max-width: 480px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 4px; font-weight: 500; }
.modal-field input, .modal-field select {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04);
  color: #e2e8f0; font-size: 13px; outline: none;
}
.modal-field input:focus, .modal-field select:focus { border-color: rgba(96,165,250,0.4); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== STATUS DOT ===== */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.status-dot.live { background: #ef4444; box-shadow: 0 0 6px #ef4444; animation: pulse 2s infinite; }
.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #475569; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ===== TALENT CARD (widget-specific) ===== */
.talent-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; transition: background 0.1s; cursor: pointer;
}
.talent-card:hover { background: rgba(255,255,255,0.04); }
.talent-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.06); flex-shrink: 0;
  object-fit: cover;
}
.talent-info { flex: 1; min-width: 0; }
.talent-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talent-meta { font-size: 11px; color: #64748b; display: flex; gap: 8px; align-items: center; }
.talent-stat { font-size: 11px; color: #94a3b8; text-align: right; flex-shrink: 0; }

/* ===== SCHEDULE ITEM ===== */
.schedule-item {
  display: flex; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.schedule-item:last-child { border-bottom: none; }
.schedule-time { font-size: 11px; color: #64748b; min-width: 60px; padding-top: 2px; }
.schedule-content { flex: 1; }
.schedule-title { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.schedule-channel { font-size: 11px; color: #94a3b8; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .toolbar-title { font-size: 13px; }
  .toolbar-title span.full { display: none; }
  .btn span.btn-label { display: none; }
  .btn-icon { padding: 6px 10px; }
  .chat-sidebar { width: 100%; }
  .widget-palette { left: 8px; right: 8px; width: auto; }
  .canvas-controls { bottom: 12px; left: 12px; }
}
@media (max-width: 480px) {
  .toolbar { padding: 0 10px; }
  .toolbar-title { margin-right: 8px; }
}

/* ===== LOADING SHIMMER ===== */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.loading-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 100%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; top: 60px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  background: rgba(15,20,35,0.95); border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transform: translateX(120%); transition: transform 0.3s ease;
  max-width: 320px;
}
.toast.show { transform: translateX(0); }
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.info { border-color: rgba(96,165,250,0.3); }
