/* ============================================================
   DMS Foundation CSS — Phase 1
   Progressive enhancement layer. Does NOT override existing styles.
   Uses existing CSS variables from index.html :root.
   ============================================================ */

/* ─── Pipeline Ribbon (enhanced) ─── */
.foundation-ribbon {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.ribbon-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    min-width: 80px;
    transition: all 0.2s ease;
    position: relative;
}

.ribbon-stage:hover {
    background: var(--surface-2);
    transform: translateY(-1px);
}

.ribbon-stage__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border: 2px solid var(--border);
    background: var(--surface-2);
    transition: all 0.25s ease;
    margin-bottom: 4px;
}

.ribbon-stage__label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
}

.ribbon-stage__time {
    font-size: 0.55rem;
    color: var(--muted);
    margin-top: 2px;
}

/* Stage states */
.ribbon-stage[data-state="pending"] .ribbon-stage__icon {
    border-color: var(--border);
    color: var(--muted);
}

.ribbon-stage[data-state="active"] .ribbon-stage__icon {
    border-color: var(--accent);
    background: rgba(0, 201, 167, 0.12);
    color: var(--accent);
    box-shadow: 0 0 8px rgba(0, 201, 167, 0.3);
    animation: ribbon-pulse 2s infinite;
}

.ribbon-stage[data-state="active"] .ribbon-stage__label {
    color: var(--accent);
}

.ribbon-stage[data-state="done"] .ribbon-stage__icon {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.ribbon-stage[data-state="done"] .ribbon-stage__label {
    color: var(--success);
}

.ribbon-stage[data-state="error"] .ribbon-stage__icon {
    border-color: var(--fail);
    background: rgba(239, 68, 68, 0.12);
    color: var(--fail);
}

.ribbon-stage[data-state="error"] .ribbon-stage__label {
    color: var(--fail);
}

.ribbon-stage[data-state="skipped"] {
    opacity: 0.4;
}

.ribbon-connector {
    width: 24px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
}

.ribbon-connector[data-done="true"] {
    background: var(--success);
}

@keyframes ribbon-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 201, 167, 0.3); }
    50% { box-shadow: 0 0 16px rgba(0, 201, 167, 0.5); }
}


/* ─── Grouped Nav (collapsible sidebar categories) ─── */
.nav-group {
    margin-bottom: 4px;
}

.nav-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    user-select: none;
}

.nav-group__header:hover {
    background: var(--surface-2);
}

.nav-group__chevron {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    stroke: var(--muted);
}

.nav-group.collapsed .nav-group__chevron {
    transform: rotate(-90deg);
}

.nav-group__items {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease;
}

.nav-group.collapsed .nav-group__items {
    max-height: 0;
}

.nav-group__count {
    font-size: 0.6rem;
    background: var(--surface-2);
    color: var(--muted);
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 6px;
}


/* ─── Loading States ─── */

/* Skeleton loading placeholder */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--border) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 6px;
}

.skeleton--text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton--text:nth-child(2) { width: 60%; }
.skeleton--text:nth-child(3) { width: 70%; }

.skeleton--card {
    height: 100px;
    border-radius: 12px;
}

.skeleton--circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

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

/* Spinner overlay for buttons and containers */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: foundation-spin 0.6s linear infinite;
    vertical-align: middle;
}

.loading-spinner--lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.loading-spinner--center {
    display: block;
    margin: 24px auto;
}

@keyframes foundation-spin {
    to { transform: rotate(360deg); }
}

/* Button loading state */
.btn--loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn--loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: foundation-spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

/* Disabled button during loading */
.btn[data-loading="true"] {
    pointer-events: none;
    opacity: 0.6;
}

/* Container loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 22, 40, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
    backdrop-filter: blur(2px);
}

[data-theme='light'] .loading-overlay {
    background: rgba(248, 250, 252, 0.7);
}


/* ─── AI Whisper Cards ─── */
.ai-whisper {
    position: relative;
    background: var(--surface);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

.ai-whisper::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 15px;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent-2), var(--accent), var(--accent-2));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.ai-whisper__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.ai-whisper__icon {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.ai-whisper__title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
}

.ai-whisper__badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(0, 201, 167, 0.15));
    color: var(--accent-2);
    margin-left: auto;
}

.ai-whisper__body {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.6;
}

.ai-whisper__body strong {
    color: var(--text);
}

.ai-whisper__actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Whisper variants */
.ai-whisper--suggestion {
    border-left: 3px solid var(--accent-2);
}

.ai-whisper--insight {
    border-left: 3px solid var(--accent);
}

.ai-whisper--warning {
    border-left: 3px solid var(--warn);
}

.ai-whisper--warning::before {
    background: linear-gradient(135deg, var(--warn), var(--accent-2), var(--warn));
}


/* ─── Responsive ─── */
@media (max-width: 768px) {
    .foundation-ribbon {
        padding: 8px 12px;
        gap: 0;
    }
    .ribbon-stage {
        min-width: 60px;
        padding: 6px 8px;
    }
    .ribbon-connector {
        width: 12px;
    }
}
