/* Recovery Score Dashboard Widget — MindCare */

@keyframes rsSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes rsPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes rsRingDraw {
    from { stroke-dashoffset: 339.292; }
}

@keyframes rsLivePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.4); }
}

@keyframes rsLoadSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes rsShimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes rsBarGrow {
    from { width: 0%; }
}

.rs-dashboard-section {
    padding: 0 20px;
    margin-bottom: 20px;
    position: relative;
    z-index: 10;
}

@media (min-width: 768px) {
    .rs-dashboard-section {
        padding: 0 28px;
        margin-bottom: 24px;
    }
}

.rs-widget {
    background: linear-gradient(135deg,
        rgba(255,255,255,0.95) 0%,
        rgba(255,255,255,0.88) 100%);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 24px;
    padding: 0;
    box-shadow:
        0 8px 32px rgba(139, 92, 246, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.rs-widget:hover {
    box-shadow:
        0 12px 40px rgba(139, 92, 246, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.06);
}

.rs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 0;
    flex-wrap: wrap;
    gap: 10px;
}

.rs-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rs-header-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.rs-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
}

.rs-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #0F766E;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rs-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #14b8a6;
    animation: rsLivePulse 2s ease-in-out infinite;
}

/* Why this score? */
.rs-why-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 12px;
    border: 1.5px solid rgba(139, 92, 246, 0.2);
    background: rgba(139, 92, 246, 0.06);
    color: #8b5cf6;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.rs-why-btn:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.35);
    transform: translateY(-1px);
}

.rs-why-btn.rs-why-active {
    background: #8b5cf6;
    color: #fff;
    border-color: #8b5cf6;
}

.rs-body {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 22px 14px;
}

/* Ring */
.rs-ring-area {
    position: relative;
    width: 110px;
    height: 110px;
    flex-shrink: 0;
}

.rs-ring {
    width: 110px;
    height: 110px;
    transform: rotate(-90deg);
}

.rs-ring-bg {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 8;
}

.rs-ring-progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    transition: stroke-dashoffset 1.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: rsRingDraw 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.rs-score-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: baseline;
    gap: 1px;
}

.rs-score-num {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.rs-score-pct {
    font-size: 0.9rem;
    font-weight: 600;
    color: #94a3b8;
}

/* Meta info */
.rs-meta {
    flex: 1;
    min-width: 0;
}

.rs-status {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.rs-trend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.rs-trend-up {
    background: rgba(20, 184, 166, 0.1);
    color: #0F766E;
}

.rs-trend-down {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.rs-trend-stable {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
}

.rs-desc {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.5;
    margin: 0;
}

.rs-component-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 22px;
    margin: 4px 0 0;
}

.rs-component-chip {
    --chip-accent: #64748b;
    --chip-accent-soft: rgba(100, 116, 139, 0.14);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 8px 14px 8px 10px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,250,252,0.92) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.72),
        0 8px 22px rgba(148, 163, 184, 0.08);
    color: #334155;
}

.rs-component-chip-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chip-accent-soft), rgba(255,255,255,0.82));
    color: var(--chip-accent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
    flex-shrink: 0;
}

.rs-component-chip-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.rs-component-chip-head {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.rs-component-chip-label {
    font-size: 0.84rem;
    font-weight: 700;
    color: #334155;
    line-height: 1.1;
}

.rs-component-chip-score {
    font-size: 0.88rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.rs-component-chip-score--na {
    color: #475569;
}

.rs-component-chip-state {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.rs-component-chip-state--critical {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.rs-component-chip-state--struggling {
    background: rgba(249, 115, 22, 0.14);
    color: #c2410c;
}

.rs-component-chip-state--moderate {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.rs-component-chip-state--stable {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.rs-component-chip-state--strong {
    background: rgba(20, 184, 166, 0.14);
    color: #0f766e;
}

.rs-component-chip-meta {
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.35;
}

.rs-component-chip--strong {
    border-color: rgba(20, 184, 166, 0.18);
}

.rs-component-chip--steady {
    border-color: rgba(139, 92, 246, 0.18);
}

.rs-component-chip--fragile {
    border-color: rgba(239, 68, 68, 0.18);
}

.rs-component-chip--mood {
    --chip-accent: #0f766e;
    --chip-accent-soft: rgba(20, 184, 166, 0.18);
}

.rs-component-chip--activity {
    --chip-accent: #2563eb;
    --chip-accent-soft: rgba(37, 99, 235, 0.16);
}

.rs-component-chip--urgeControl {
    --chip-accent: #7c3aed;
    --chip-accent-soft: rgba(124, 58, 237, 0.16);
}

.rs-component-chip--triggers {
    --chip-accent: #ea580c;
    --chip-accent-soft: rgba(249, 115, 22, 0.18);
}

.rs-sparkline-section {
    padding: 8px 22px 16px;
    margin-top: 2px;
}

.rs-spark-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 2px;
}

.rs-sparkline-shell {
    border-radius: 18px;
    padding: 10px 12px 8px;
    border: 1px solid rgba(139, 92, 246, 0.08);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.75) 0%, rgba(248,250,252,0.92) 100%),
        radial-gradient(circle at top right, rgba(139,92,246,0.08), transparent 45%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.65),
        0 10px 24px rgba(148, 163, 184, 0.08);
}

.rs-sparkline {
    width: 100%;
    height: 52px;
    display: block;
}

.rs-transparency {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding: 18px 22px 20px;
    background: rgba(241, 245, 249, 0.5);
}

.rs-trans-header {
    margin-bottom: 16px;
}

.rs-trans-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rs-trans-header h4 i {
    color: #8b5cf6;
}

.rs-trans-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rs-trans-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 700;
}

.rs-chip-positive {
    background: rgba(20, 184, 166, 0.1);
    color: #0F766E;
}

.rs-chip-negative {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.rs-chip-base {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

/* Contribution Rows */
.rs-contribs-section {
    margin-top: 4px;
}

.rs-contribs-heading {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rs-contribs-heading.positive {
    color: #0F766E;
}

.rs-contribs-heading.negative {
    color: #ef4444;
}

.rs-contrib-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.rs-contrib-row + .rs-contrib-row {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.rs-contrib-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.rs-contrib-info {
    flex: 1;
    min-width: 0;
}

.rs-contrib-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.rs-contrib-val {
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.73rem;
}

.rs-inline-state {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.rs-inline-state--critical {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.rs-inline-state--struggling {
    background: rgba(249, 115, 22, 0.14);
    color: #c2410c;
}

.rs-inline-state--moderate {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.rs-inline-state--stable {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

.rs-inline-state--strong {
    background: rgba(20, 184, 166, 0.14);
    color: #0f766e;
}

.rs-contrib-bar-bg {
    height: 6px;
    border-radius: 3px;
    background: #f1f5f9;
    overflow: hidden;
}

.rs-contrib-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation: rsBarGrow 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.rs-contrib-pts {
    font-size: 0.82rem;
    font-weight: 700;
    min-width: 38px;
    text-align: right;
}

.rs-contrib-pts.positive {
    color: #0F766E;
}

.rs-contrib-pts.negative {
    color: #ef4444;
}

.rs-contrib-pts-neutral {
    color: #64748b;
}

.rs-transparency-meta {
    margin: 4px 0 0 42px;
    color: #64748b;
    font-size: 0.74rem;
    line-height: 1.4;
}

.rs-empty-negative {
    font-size: 0.82rem;
    color: #0F766E;
    font-weight: 500;
    margin: 8px 0;
    padding: 10px 14px;
    background: rgba(20, 184, 166, 0.06);
    border-radius: 10px;
    text-align: center;
}

.rs-decay-note {
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.06);
    border-radius: 10px;
    font-size: 0.73rem;
    color: #64748b;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}

.rs-decay-note i {
    color: #8b5cf6;
    font-size: 0.85rem;
    margin-top: 1px;
    flex-shrink: 0;
}

.rs-insight-note {
    margin-top: 8px;
    color: #334155;
}

.rs-deep-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 22px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(20, 184, 166, 0.06) 100%);
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    color: #8b5cf6;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.25s ease;
    cursor: pointer;
}

.rs-deep-link:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(20, 184, 166, 0.12) 100%);
    color: #7c3aed;
}

.rs-deep-link .fa-chevron-right {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.rs-deep-link:hover .fa-chevron-right {
    transform: translateX(3px);
}

.rs-loading .rs-loading-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 22px;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
}

.rs-loading-ring {
    width: 28px;
    height: 28px;
    border: 3px solid #f1f5f9;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: rsLoadSpin 1s linear infinite;
}

.rs-error {
    padding: 18px 22px;
}

.rs-error-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 500;
}

.rs-error-content a {
    color: #8b5cf6;
    font-weight: 600;
    text-decoration: underline;
}

@media (max-width: 480px) {
    .rs-dashboard-section {
        padding: 0 14px;
        margin-bottom: 16px;
    }

    .rs-widget {
        border-radius: 20px;
    }

    .rs-header {
        padding: 14px 16px 0;
    }

    .rs-body {
        padding: 14px 16px 10px;
        gap: 14px;
    }

    .rs-ring-area, .rs-ring {
        width: 90px;
        height: 90px;
    }

    .rs-score-num {
        font-size: 1.6rem;
    }

    .rs-status {
        font-size: 0.95rem;
    }

    .rs-desc {
        font-size: 0.78rem;
    }

    .rs-why-btn span {
        display: none;
    }

    .rs-transparency {
        padding: 14px 16px 16px;
    }

    .rs-component-chips {
        padding: 0 16px;
        gap: 8px;
    }

    .rs-component-chip {
        min-height: 50px;
        padding: 8px 12px 8px 9px;
        border-radius: 16px;
    }

    .rs-component-chip-icon {
        width: 30px;
        height: 30px;
        border-radius: 10px;
    }

    .rs-sparkline-section {
        padding: 8px 16px 12px;
    }
}

@media (max-width: 380px) {
    .rs-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .rs-meta {
        text-align: center;
    }
}

@media (min-width: 768px) {
    .rs-widget {
        max-width: 100%;
    }

    .rs-body {
        padding: 22px 28px 18px;
        gap: 28px;
    }

    .rs-ring-area, .rs-ring {
        width: 120px;
        height: 120px;
    }

    .rs-score-num {
        font-size: 2.2rem;
    }

    .rs-header {
        padding: 20px 28px 0;
    }

    .rs-component-chips {
        padding: 0 28px;
        gap: 12px;
    }

    .rs-sparkline-section {
        padding: 10px 28px 18px;
    }

    .rs-transparency {
        padding: 20px 28px 24px;
    }
}

/* Dark Mode Support (inherits from MindCare design system) */
[data-theme="dark"] .rs-widget,
.dark-mode .rs-widget {
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.95) 0%,
        rgba(30, 41, 59, 0.88) 100%);
    border-color: rgba(139, 92, 246, 0.2);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .rs-title,
.dark-mode .rs-title {
    color: #f1f5f9;
}

[data-theme="dark"] .rs-desc,
.dark-mode .rs-desc {
    color: #94a3b8;
}

[data-theme="dark"] .rs-component-chip,
.dark-mode .rs-component-chip {
    border-color: rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(51,65,85,0.92) 0%, rgba(30,41,59,0.9) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.04),
        0 10px 24px rgba(2, 6, 23, 0.2);
    color: #e2e8f0;
}

[data-theme="dark"] .rs-component-chip-label,
.dark-mode .rs-component-chip-label {
    color: #e2e8f0;
}

[data-theme="dark"] .rs-component-chip-score,
.dark-mode .rs-component-chip-score {
    color: #f8fafc;
}

[data-theme="dark"] .rs-component-chip-score--na,
.dark-mode .rs-component-chip-score--na {
    color: #cbd5e1;
}

[data-theme="dark"] .rs-component-chip-meta,
.dark-mode .rs-component-chip-meta {
    color: #94a3b8;
}

[data-theme="dark"] .rs-component-chip-icon,
.dark-mode .rs-component-chip-icon {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

[data-theme="dark"] .rs-sparkline-shell,
.dark-mode .rs-sparkline-shell {
    border-color: rgba(139, 92, 246, 0.16);
    background:
        linear-gradient(180deg, rgba(51, 65, 85, 0.7) 0%, rgba(30, 41, 59, 0.92) 100%),
        radial-gradient(circle at top right, rgba(139,92,246,0.18), transparent 45%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.04),
        0 12px 24px rgba(2, 6, 23, 0.24);
}

[data-theme="dark"] .rs-ring-bg,
.dark-mode .rs-ring-bg {
    stroke: #334155;
}

[data-theme="dark"] .rs-contrib-label,
.dark-mode .rs-contrib-label {
    color: #e2e8f0;
}

[data-theme="dark"] .rs-contrib-bar-bg,
.dark-mode .rs-contrib-bar-bg {
    background: #334155;
}

[data-theme="dark"] .rs-transparency,
.dark-mode .rs-transparency {
    background: rgba(15, 23, 42, 0.4);
    border-top-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .rs-trans-header h4,
.dark-mode .rs-trans-header h4 {
    color: #f1f5f9;
}

[data-theme="dark"] .rs-deep-link,
.dark-mode .rs-deep-link {
    border-top-color: rgba(255, 255, 255, 0.06);
}
