/* ==========================================
   Life OS Dashboard - Styles
   Extracted from inline <style> + new view system
   ========================================== */

body {
  background: #020617;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
}

/* === Ambient Background === */
.bg-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.12;
  animation: drift 25s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: #6366f1; top: -15%; left: -10%; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: #8b5cf6; bottom: -20%; right: -10%; animation-delay: -8s; }
.orb-3 { width: 400px; height: 400px; background: #06b6d4; top: 35%; left: 55%; animation-delay: -16s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 20px) scale(0.92); }
}

/* === Glass Cards === */
.glass {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 16px;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}
.glass-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-color: rgba(148, 163, 184, 0.15);
}
.glass-subtle {
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.06);
  border-radius: 12px;
}

/* === Status Indicators === */
.pulse-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pulse-dot::before {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: inherit; opacity: 0.4; animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.pulse-dot.no-pulse::before { animation: none; opacity: 0; }
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2.5); opacity: 0; }
}
.dot-green { background: #22c55e; }
.dot-red { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-slate { background: #475569; }

/* === Toggle Switch === */
.toggle { position: relative; width: 40px; height: 22px; border-radius: 11px; cursor: pointer; transition: background 0.2s; background: #334155; flex-shrink: 0; }
.toggle.on { background: #22c55e; }
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: white;
  transition: transform 0.2s ease-out; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle.on::after { transform: translateX(18px); }

/* === Spinner === */
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.15);
  border-top-color: #a5b4fc; border-radius: 50%;
  animation: spin 0.5s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Toast === */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: 10px; font-size: 13px; color: #f1f5f9;
  backdrop-filter: blur(16px); border: 1px solid rgba(148,163,184,0.1);
  animation: toast-in 0.3s ease-out; max-width: 320px;
}
.toast-success { background: rgba(22, 101, 52, 0.85); }
.toast-error { background: rgba(127, 29, 29, 0.85); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* === Progress Bars === */
.bar-fill { height: 6px; border-radius: 3px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

/* === Skeleton Loading === */
.skeleton { background: linear-gradient(90deg, rgba(30,41,59,0.5) 25%, rgba(51,65,85,0.4) 50%, rgba(30,41,59,0.5) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === SSE Flash Animation === */
.sse-flash { animation: sse-pulse 0.3s ease-out; }
@keyframes sse-pulse { 0% { background: rgba(99,102,241,0.15); } 100% { background: transparent; } }

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}

.action-btn { transition: transform 0.1s ease-out, background 0.15s ease-out; }
.action-btn:active { transform: scale(0.97); }

.agent-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.15) 0%, rgba(6,182,212,0.08) 100%);
  flex-shrink: 0;
}

.section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b;
}

.stat-accent { position: absolute; top: 0; left: 16px; right: 16px; height: 1px; border-radius: 1px; }

/* === Chat === */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble.agent {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-bottom-left-radius: 4px;
}
.chat-bubble.agent .typing-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  background: #64748b;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
  margin: 0 2px;
}
.chat-bubble.agent .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.agent .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* === Tab styling (legacy, kept for compatibility) === */
.tab-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  transition: all 0.15s ease-out;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  position: relative;
}
.tab-btn:hover { color: #94a3b8; background: rgba(51, 65, 85, 0.3); }
.tab-btn.active {
  color: #e2e8f0;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.tab-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* === Kanban === */
.kanban-col {
  min-width: 220px;
  max-width: 260px;
  flex-shrink: 0;
}
.kanban-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.06);
  border-radius: 10px;
  padding: 12px;
  transition: border-color 0.15s, transform 0.1s;
  cursor: default;
}
.kanban-card:hover {
  border-color: rgba(148, 163, 184, 0.15);
  transform: translateY(-1px);
}

/* === Email row === */
.email-row {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.04);
  cursor: pointer;
  transition: background 0.1s;
}
.email-row:hover { background: rgba(51, 65, 85, 0.2); }
.email-row.unread { border-left: 2px solid #6366f1; }
.email-row.priority-high { border-left: 3px solid #ef4444; }
.email-row.priority-high.unread { border-left: 3px solid #ef4444; }

/* === Calendar event === */
.cal-event {
  padding: 10px 14px;
  border-left: 3px solid;
  border-radius: 0 8px 8px 0;
  background: rgba(15, 23, 42, 0.4);
  margin-bottom: 6px;
}

/* === System Architecture (org chart) === */
.org-tree { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org-node {
  padding: 8px 14px; border-radius: 10px; text-align: center; position: relative;
  border: 1px solid rgba(148,163,184,0.08);
}
.org-node-manager { background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15)); border-color: rgba(99,102,241,0.25); }
.org-node-agent { background: rgba(15,23,42,0.5); }
.org-node-service { background: rgba(15,23,42,0.3); border-color: rgba(148,163,184,0.05); }
.org-vline { width: 1px; height: 20px; background: rgba(99,102,241,0.25); }
.org-hline { height: 1px; background: rgba(99,102,241,0.2); }
.org-branch-line { width: 1px; height: 16px; background: rgba(99,102,241,0.15); }
.org-agents { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; position: relative; }
.org-agent-col { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 140px; max-width: 160px; }
.org-services { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.org-svc {
  font-size: 10px; color: #64748b; padding: 3px 8px; border-radius: 6px;
  background: rgba(15,23,42,0.4); border: 1px solid rgba(148,163,184,0.04);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-tag {
  display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 4px;
  font-weight: 600; letter-spacing: 0.3px;
}
.org-tag-tools { background: rgba(34,197,94,0.12); color: #4ade80; }
.org-tag-sched { background: rgba(245,158,11,0.12); color: #fbbf24; }

/* === 3-View Tab System === */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  background: rgba(2, 6, 23, 0.3);
  flex-shrink: 0;
}
.view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease-out;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
}
.view-tab:hover {
  color: #94a3b8;
  background: rgba(51, 65, 85, 0.3);
}
.view-tab.active {
  color: #e2e8f0;
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.2);
}
.view-tab .tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* === View Containers === */
.view-container {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.view-container.active {
  display: block;
}

/* === Widget Grid === */
.widget-grid {
  min-height: 200px;
}

/* === Widget Inner === */
.widget-inner {
  height: 100%;
  border-radius: 16px;
  padding: 16px;
}

/* === Widget Header === */
.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.widget-refresh-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.widget-inner:hover .widget-refresh-btn {
  opacity: 1;
}
.widget-refresh-btn:hover {
  background: rgba(51, 65, 85, 0.4);
}

/* === Widget Body === */
.widget-body {
  flex: 1;
  overflow: hidden;
}

/* === GridStack overrides === */
.gs-item-content {
  inset: 0 !important;
}
.grid-stack > .grid-stack-item > .grid-stack-item-content {
  inset: 6px !important;
}

/* === Summary Hero === */
.summary-hero {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.06);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  transition: all 0.3s ease-out;
  overflow: hidden;
}
.summary-hero .summary-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.summary-hero .summary-toggle .chevron {
  transition: transform 0.2s ease-out;
}

/* Expanded: show full content, hide bar */
.summary-hero .summary-expanded { display: block; }
.summary-hero .summary-bar { display: none; }

/* Collapsed: hide expanded, show thin bar */
.summary-hero.collapsed {
  padding: 0;
  cursor: pointer;
}
.summary-hero.collapsed .summary-expanded { display: none; }
.summary-hero.collapsed .summary-bar { display: flex; }

/* Summary bar (collapsed state) */
.summary-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  user-select: none;
  min-height: 38px;
}
.summary-bar .summary-collapsed-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Mobile: collapse chat === */
@media (max-width: 1023px) {
  .chat-panel { display: none !important; }
  .chat-panel.mobile-open {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
  .chat-fab { display: flex !important; }
  .main-panel { margin-left: 0 !important; }
}
@media (min-width: 1024px) {
  .chat-fab { display: none !important; }
}

/* === Mobile: bottom tab bar === */
@media (max-width: 768px) {
  .view-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    justify-content: space-around;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(30, 41, 59, 0.5);
    border-bottom: none;
    padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
  }
  .view-tab {
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    padding: 6px 12px;
  }
  .view-container {
    padding-bottom: 80px; /* space for bottom tab bar */
  }
  .chat-fab {
    bottom: 72px !important; /* above bottom tab bar */
  }
  .summary-hero {
    margin-left: 12px;
    margin-right: 12px;
    margin-top: 12px;
    padding: 14px 16px;
  }
  .view-container {
    padding: 12px;
    padding-bottom: 80px;
  }
  .grid-stack > .grid-stack-item > .grid-stack-item-content {
    inset: 4px !important;
  }
}
