/* ==========================================================================
   Essence CRM — reusable skeleton loader
   Companion to js/skeleton.js (window.Skeleton). Dark-mode aware via the
   shared --dark-* tokens. Animation is disabled for prefers-reduced-motion.
   ========================================================================== */

:root {
    --sk-base: #e9edf1;
    --sk-strong: #dfe5ea;
    --sk-shine: rgba(255, 255, 255, 0.72);
    --sk-surface: #ffffff;
    --sk-border: #eef1f4;
    --sk-radius: 8px;
}

html.dark {
    --sk-base: #2b3238;
    --sk-strong: #3a4249;
    --sk-shine: rgba(255, 255, 255, 0.05);
    --sk-surface: var(--dark-elevated, #23282e);
    --sk-border: var(--dark-border-soft, #2d3532);
}

.sk-line,
.sk-block,
.sk-avatar,
.sk-pill,
.sk-tile,
.sk-orb,
.sk-value,
.sk-box,
.sk-square,
.sk-filter,
.sk-cat-row,
.sk-tab,
.sk-bar,
.sk-progress-track {
    position: relative;
    overflow: hidden;
    background-color: var(--sk-base);
}

.sk-line::after,
.sk-block::after,
.sk-avatar::after,
.sk-pill::after,
.sk-tile::after,
.sk-orb::after,
.sk-value::after,
.sk-box::after,
.sk-square::after,
.sk-filter::after,
.sk-cat-row::after,
.sk-tab::after,
.sk-bar::after,
.sk-progress-track i::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--sk-shine), transparent);
    animation: sk-shimmer 1.4s ease-in-out infinite;
}

@keyframes sk-shimmer {
    100% { transform: translateX(100%); }
}

.sk-line { height: 12px; border-radius: 9999px; }
.sk-line-sm { height: 9px; }
.sk-line-lg { height: 16px; }

.sk-block { width: 100%; border-radius: var(--sk-radius); }

.sk-avatar { width: 40px; height: 40px; border-radius: 9999px; flex: none; }
.sk-pill { width: 46px; height: 20px; border-radius: 9999px; flex: none; }

.sk-cell { padding: 14px 16px; }

.sk-card {
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sk-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sk-pills { display: flex; gap: 6px; flex: none; }

.sk-list-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; }

/* Skeleton host injected while a lazy view loads (Skeleton.host) */
.sk-host { margin: 12px 0 24px; display: block; animation: sk-fade-in 180ms ease both; }

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

/* Pipeline board */
.sk-board { display: flex; gap: 12px; align-items: flex-start; }
.sk-col { flex: 1 1 240px; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.sk-col-head { padding: 6px 0; }

.sk-board-card {
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Section-layout presets (dashboard / tools / hub / tribe / accordion) */
.sk-host:has(.sk-page) { max-width: 72rem; margin: 0 auto 24px; }
.sk-page { display: flex; flex-direction: column; gap: 16px; }
.sk-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.sk-panel, .sk-stat {
    background: var(--sk-surface);
    border: 1px solid var(--sk-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
.sk-stat { gap: 10px; }
.sk-panel--row { padding: 14px 16px; }
.sk-panel-head { display: flex; align-items: center; gap: 10px; }
.sk-panel-head .sk-line { flex: none; }
.sk-icon { width: 28px; height: 28px; border-radius: 8px; flex: none; background-color: var(--sk-base); }
.sk-icon-end { margin-left: auto; width: 20px; height: 20px; }
.sk-input { height: 40px; border-radius: 12px; }
.sk-btn { height: 40px; width: 140px; border-radius: 12px; }
.sk-chips { flex-wrap: wrap; }
.sk-chip { width: 72px; height: 28px; }
.sk-member { display: flex; align-items: center; gap: 12px; }

/* ---- section-specific shapes ---- */
.sk-row { display: flex; align-items: center; gap: 10px; }
.sk-row--between { justify-content: space-between; }
.sk-wb { display: grid; gap: 16px; }
.sk-wb-main,
.sk-wb-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sk-stack { display: flex; flex-direction: column; gap: 12px; }
.sk-field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sk-tiles { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; overflow: hidden; }
.sk-tile { width: 34px; height: 46px; border-radius: 8px; flex: none; }
.sk-orb { width: 120px; height: 120px; border-radius: 50%; flex: none; }
.sk-orb--sm { width: 56px; height: 56px; }
.sk-value { width: 65%; height: 28px; border-radius: 7px; }
.sk-box { width: 100%; height: 54px; border-radius: 10px; }
.sk-square { width: 120px; height: 120px; border-radius: 8px; flex: none; }
.sk-filter { width: 100%; height: 42px; border-radius: 10px; }
.sk-cat-row { width: 100%; height: 30px; border-radius: 8px; }
.sk-tab { width: 62px; height: 18px; border-radius: 6px; flex: none; }
.sk-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.sk-stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.sk-tabs { display: flex; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--sk-border); }
.sk-metric { gap: 10px; }
.sk-progress-row { display: flex; flex-direction: column; gap: 6px; }
.sk-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sk-progress-track { width: 100%; height: 6px; border-radius: 99px; }
.sk-progress-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-color: var(--sk-strong, var(--sk-base));
    position: relative;
    overflow: hidden;
}
.sk-bars { display: flex; align-items: flex-end; gap: 6px; height: 220px; padding: 8px 4px 0; }
.sk-bar { flex: 1; min-height: 8px; border-radius: 4px 4px 0 0; }
.sk-rev-main { display: grid; gap: 16px; }
.sk-rev-rail { display: flex; flex-direction: column; gap: 16px; }
.sk-notice { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.sk-table-wrap { overflow: hidden; border-radius: 12px; border: 1px solid var(--sk-border); }
.sk-table { width: 100%; border-collapse: collapse; }
.sk-table .sk-cell { padding: 10px 12px; }
.sk-table .sk-row:not(:last-child) .sk-cell { border-bottom: 1px solid var(--sk-border); }
.sk-tribe { display: flex; flex-direction: column; gap: 16px; }
.sk-tribe-selector { max-width: 32rem; margin: 0 auto; width: 100%; align-items: center; }
.sk-tribe-hero { align-items: center; text-align: center; padding: 28px 16px; }
.sk-tribe-hero > .sk-grid { width: 100%; max-width: 48rem; }
.sk-feature { align-items: center; }
.sk-help { width: 100%; text-align: left; }
.sk-formula { display: flex; flex-direction: column; gap: 16px; }
.sk-page-head { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; }
.sk-cidx { display: grid; gap: 16px; }
.sk-cidx-side { gap: 8px; }
.sk-yantra-card { align-items: center; gap: 10px; }
.sk-yantra-card .sk-card-body { width: 100%; align-items: center; }
.sk-page-head .sk-icon { width: 40px; height: 40px; border-radius: 12px; }
.sk-parent { gap: 10px; }
.sk-name-card { gap: 10px; }

/* Masked host: section header stays, the real body is replaced by the skeleton. */
.sk-mask > :not(.section-page-header):not(.sk-host) { display: none !important; }
.sk-mask > .sk-host { margin: 0; }

@media (min-width: 640px) {
    .sk-grid-2,
    .sk-grid-6 { grid-template-columns: repeat(2, 1fr); }
    .sk-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .sk-hero { grid-template-columns: auto minmax(0, 1fr); }
}

@media (min-width: 900px) {
    .sk-cidx { grid-template-columns: 220px minmax(0, 1fr); }
}

@media (min-width: 1024px) {
    .sk-wb { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
    .sk-rev-main { grid-template-columns: 2fr 1fr; align-items: start; }
    .sk-grid-6 { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 600px) {
    .sk-hero { grid-template-columns: 1fr; justify-items: center; }
    .sk-hero > .sk-card-body { width: 100%; align-items: center; }
    .sk-hero .sk-pills { justify-content: center; }
    .sk-hero .sk-stats3 { width: 100%; }
    .sk-tiles { flex-wrap: nowrap; }
}

@media (min-width: 640px) {
    .sk-grid-3, .sk-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
    .sk-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .sk-grid-4 { grid-template-columns: repeat(4, 1fr); }
    .sk-grid-2-1 { grid-template-columns: 2fr 1fr; }
    .sk-grid-1-2 { grid-template-columns: 1fr 2fr; }
}

@media (prefers-reduced-motion: reduce) {
    .sk-host { animation: none; }
    .sk-line::after,
    .sk-block::after,
    .sk-avatar::after,
    .sk-pill::after,
    .sk-tile::after,
    .sk-orb::after,
    .sk-value::after,
    .sk-box::after,
    .sk-square::after,
    .sk-filter::after,
    .sk-cat-row::after,
    .sk-tab::after,
    .sk-bar::after,
    .sk-progress-track i::after { animation: none; }
}

/* Today view skeleton: day header, day strip, chips, list + day rail (mirrors js/pipeline_today.js) */
.sk-today { display: flex; flex-direction: column; gap: 14px; }
.sk-today-hero { height: 104px; }
.sk-today-strip { height: 96px; }
.sk-today-chips { display: flex; gap: 8px; }
.sk-today-chips .sk-block { height: 44px; width: 132px; border-radius: 999px; }
.sk-today-cols { display: grid; grid-template-columns: minmax(0, 1fr) clamp(264px, 26vw, 316px); gap: 14px; align-items: start; }
.sk-today-list { display: flex; flex-direction: column; gap: 10px; }
.sk-today-rail { display: flex; flex-direction: column; gap: 12px; }
.sk-today-pane { height: 118px; }
@media (max-width: 900px) { .sk-today-cols { grid-template-columns: minmax(0, 1fr); } .sk-today-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .sk-today-hero { height: 150px; } .sk-today-strip { height: 76px; } .sk-today-rail { display: none; } .sk-today-chips .sk-block { width: 118px; height: 40px; } }
