/* web/components/skeletons/skeletons.css
   Universal Skeleton Loading System for AiSockt / Dreamer Frontend
   Matches the exact component layouts across all pages to prevent Layout Shift (CLS).
*/

/* ---- Core Shimmer Animation & Base Tokens ---- */
.app-skel-pulse,
.app-skel-line,
.app-skel-circle,
.app-skel-box,
.app-skel-btn,
.app-skel-pill {
  position: relative;
  overflow: hidden;
  background: var(--tb-surface-2, rgba(127, 127, 127, 0.12));
  background: linear-gradient(
    90deg,
    var(--tb-surface, rgba(255, 255, 255, 0.04)) 0%,
    var(--tb-surface-2, rgba(127, 127, 127, 0.15)) 50%,
    var(--tb-surface, rgba(255, 255, 255, 0.04)) 100%
  );
  background-size: 200% 100%;
  animation: app-skel-shimmer 1.8s linear infinite;
  border-radius: var(--radius-input, 6px);
  pointer-events: none;
  user-select: none;
}

@keyframes app-skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .app-skel-pulse,
  .app-skel-line,
  .app-skel-circle,
  .app-skel-box,
  .app-skel-btn,
  .app-skel-pill {
    animation: none;
    background: var(--tb-surface-2, rgba(127, 127, 127, 0.1));
  }
}

/* Primitive Skeleton Elements */
.app-skel-line { height: 12px; margin-bottom: 6px; }
.app-skel-line.sm { height: 9px; }
.app-skel-line.lg { height: 18px; }
.app-skel-line.w-25 { width: 25%; }
.app-skel-line.w-40 { width: 40%; }
.app-skel-line.w-50 { width: 50%; }
.app-skel-line.w-65 { width: 65%; }
.app-skel-line.w-75 { width: 75%; }
.app-skel-line.w-90 { width: 90%; }
.app-skel-line.w-100 { width: 100%; }

.app-skel-circle {
  border-radius: 50%;
  flex-shrink: 0;
}
.app-skel-circle.sm { width: 24px; height: 24px; }
.app-skel-circle.md { width: 36px; height: 36px; }
.app-skel-circle.lg { width: 44px; height: 44px; }

.app-skel-pill {
  height: 28px;
  width: 72px;
  border-radius: var(--radius-btn, 8px);
  display: inline-block;
  flex-shrink: 0;
}
.app-skel-pill.sm { height: 22px; width: 56px; border-radius: 12px; }
.app-skel-pill.lg { height: 32px; width: 90px; }

.app-skel-btn {
  height: 32px;
  width: 84px;
  border-radius: var(--radius-btn, 8px);
  flex-shrink: 0;
}

.app-skel-container {
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   1. Connectors Page Skeleton Layout
   ========================================================================== */
.app-skel-connectors {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.app-skel-connectors-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
}
.app-skel-connectors-tabs {
  display: flex;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--cnp-edge-hi, rgba(255,255,255,0.08));
}
.app-skel-connectors-filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.app-skel-connectors-filters-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.app-skel-search-box {
  width: 200px;
  height: 32px;
  border-radius: var(--radius-input, 6px);
}
.app-skel-connectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}
.app-skel-connector-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-card, 10px);
  background: var(--cnp-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--cnp-edge-hi, rgba(255, 255, 255, 0.08));
}
.app-skel-connector-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ==========================================================================
   2. Projects Page Skeleton Layout
   ========================================================================== */
.app-skel-projects {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}
.app-skel-projects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.app-skel-projects-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.app-skel-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.app-skel-project-card {
  padding: 16px;
  border-radius: var(--radius-card, 12px);
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-skel-project-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-skel-project-tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* ==========================================================================
   3. Workflows Page Skeleton Layout (Split View)
   ========================================================================== */
.app-skel-split-view {
  display: flex;
  height: 100%;
  min-height: 520px;
  gap: 16px;
  width: 100%;
}
.app-skel-split-sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  padding-right: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-skel-split-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 12px;
}
.app-skel-row-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-card, 8px);
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.06));
}
.app-skel-flow-canvas {
  flex: 1 1 auto;
  border: 1px dashed var(--tb-border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-card, 12px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.app-skel-flow-node {
  width: 220px;
  padding: 12px;
  border-radius: 8px;
  background: var(--tb-surface-2, rgba(127,127,127,0.12));
  border: 1px solid var(--tb-border, rgba(255,255,255,0.1));
}

/* ==========================================================================
   4. Agents Page Skeleton Layout
   ========================================================================== */
.app-skel-agents {
  display: flex;
  height: 100%;
  min-height: 520px;
  gap: 16px;
  width: 100%;
}
.app-skel-agent-editor {
  flex: 1 1 auto;
  padding: 18px;
  border-radius: var(--radius-card, 12px);
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   5. Dashboard Bento Grid Skeleton Layout
   ========================================================================== */
.app-skel-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
}
.app-skel-dash-card {
  padding: 16px;
  border-radius: var(--radius-card, 12px);
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.app-skel-dash-card.span2 {
  grid-column: span 2;
}
.app-skel-dash-card.span4 {
  grid-column: span 4;
}

/* ==========================================================================
   6. Devices & Sessions Skeleton Layouts
   ========================================================================== */
.app-skel-cards-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}
.app-skel-block-card {
  padding: 16px;
  border-radius: var(--radius-card, 12px);
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-skel-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tb-border, rgba(255, 255, 255, 0.06));
}

/* ==========================================================================
   7. Settings Shell Skeleton Layout
   ========================================================================== */
.app-skel-settings-shell {
  display: flex;
  gap: 20px;
  width: 100%;
  min-height: 500px;
}
.app-skel-settings-nav {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.app-skel-settings-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ==========================================================================
   8. Chat Thread Skeleton Layout
   ========================================================================== */
.app-skel-chat {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 12px;
}
.app-skel-chat-user {
  align-self: flex-end;
  width: 55%;
  padding: 12px 16px;
  border-radius: 14px 14px 4px 14px;
  background: var(--tb-accent-soft, rgba(29, 78, 216, 0.15));
  border: 1px solid var(--tb-accent-border, rgba(29, 78, 216, 0.25));
}
.app-skel-chat-bot {
  align-self: flex-start;
  width: 75%;
  display: flex;
  gap: 12px;
}
.app-skel-chat-bot-body {
  flex: 1 1 auto;
  padding: 14px 18px;
  border-radius: 14px 14px 14px 4px;
  background: var(--tb-surface-card, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--tb-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
