/* ============================================================
 * Challenge Widget — 대시보드에 삽입되는 챌린지 상태 컴포넌트
 * ============================================================ */

.cw-widget {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.cw-carousel {
    margin-bottom: 20px;
}
.cw-carousel__viewport {
    overflow: hidden;
    border-radius: 16px;
}
.cw-carousel__track {
    display: flex;
    transition: transform .28s ease;
    will-change: transform;
}
.cw-carousel__slide {
    width: 100%;
    flex: 0 0 100%;
}
.cw-carousel__slide .cw-widget {
    margin-bottom: 0;
}
.cw-carousel__footer {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.cw-carousel__meta {
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #56735f;
}
.cw-carousel__nav {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cfe2d3;
    border-radius: 999px;
    background: #fff;
    color: #4f6f58;
    cursor: pointer;
}
.cw-carousel__nav .material-icons {
    font-size: 20px;
}
.cw-carousel__nav:disabled {
    opacity: .35;
    cursor: not-allowed;
}
/* 마지막 위젯 카드에만 하단 마진 확보 */
.cw-widget:last-child {
    margin-bottom: 20px;
}

/* --- Header: Badge + Live --- */
.cw-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.cw-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: #3E6B4E;
    background: #E8F5E9;
}
.cw-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}
.cw-live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #4CAF50;
    animation: cw-blink 1.8s ease-in-out infinite;
}
@keyframes cw-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

/* --- Progress Bar --- */
.cw-progress {
    margin-bottom: 16px;
}
.cw-progress__label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}
.cw-progress__pct {
    font-weight: 600;
    color: #5B8C6B;
}
.cw-progress__bar {
    height: 8px;
    border-radius: 4px;
    background: #f0f0f0;
    overflow: hidden;
}
.cw-progress__fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #81C784, #5B8C6B);
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* --- Mission Card --- */
.cw-mission {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #FAFBF9;
}
.cw-mission__info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.cw-mission__icon {
    font-size: 24px;
    color: #5B8C6B;
    flex-shrink: 0;
}
.cw-mission__label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-bottom: 2px;
}
.cw-mission__task {
    font-size: 14px;
    font-weight: 600;
    color: #2E2E2E;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.cw-mission__task--muted {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    margin-top: 2px;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.cw-mission__guided-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}
.cw-mission--guided-writing .cw-mission__guided-top {
    flex-wrap: wrap;
}
.cw-diary-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    background: #5B8C6B;
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
    transition: filter 0.2s ease, transform 0.15s ease;
}
.cw-diary-cta:hover {
    filter: brightness(1.06);
}
.cw-diary-cta .material-icons {
    font-size: 18px;
}
.cw-mission__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    transition: all .25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.cw-mission__btn .material-icons { font-size: 18px; }
.cw-mission__btn:hover:not(.cw-mission__btn--done) {
    border-color: #5B8C6B;
    color: #5B8C6B;
}
.cw-mission__btn--done {
    border-color: #5B8C6B;
    background: #E8F5E9;
    color: #3E6B4E;
    cursor: default;
}

/* --- Quest counter (+ / −) --- */
.cw-mission--counter {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}
.cw-mission__info--compact {
    flex: 1 1 auto;
    min-width: 0;
}
.cw-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.cw-counter__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid #5B8C6B;
    border-radius: 12px;
    background: #fff;
    color: #5B8C6B;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, opacity .2s ease;
}
.cw-counter__btn .material-icons {
    font-size: 22px;
}
.cw-counter__btn:hover:not(:disabled) {
    background: #E8F5E9;
}
.cw-counter__btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    border-color: #ccc;
    color: #999;
}
.cw-counter__readout {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-variant-numeric: tabular-nums;
    min-width: 5.5rem;
    justify-content: center;
}
.cw-counter__value {
    font-size: 26px;
    font-weight: 800;
    color: #2E2E2E;
    line-height: 1;
}
.cw-counter__slash {
    font-size: 18px;
    font-weight: 600;
    color: #999;
    margin: 0 2px;
}
.cw-counter__target {
    font-size: 20px;
    font-weight: 700;
    color: #5B8C6B;
}
.cw-counter__unit {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    margin-left: 4px;
}
.cw-counter__unit:empty {
    display: none;
}

/* --- Empty State --- */
.cw-widget--empty {
    text-align: center;
    padding: 28px 20px;
}
.cw-widget__empty-text {
    font-size: 14px;
    color: #999;
    margin-bottom: 12px;
}
.cw-widget__join-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #5B8C6B;
    text-decoration: none;
}
.cw-widget__join-link:hover { text-decoration: underline; }
.cw-widget__join-link .material-icons { font-size: 16px; }

/* --- Recruiting Cards (모집 중인 챌린지 인라인 참여) --- */
.cw-widget--recruit {
    padding: 20px;
}
.cw-recruit__label {
    font-size: 13px;
    font-weight: 600;
    color: #5B8C6B;
    margin-bottom: 14px;
}
.cw-recruit__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cw-recruit__card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #FAFBF9;
    transition: background .2s ease;
}
.cw-recruit__card:hover {
    background: #F0F4EF;
}
.cw-recruit__info {
    flex: 1;
    min-width: 0;
}
.cw-recruit__name {
    font-size: 14px;
    font-weight: 600;
    color: #2E2E2E;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-recruit__meta {
    font-size: 12px;
    color: #999;
}
.cw-recruit__btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 18px;
    border: 2px solid #5B8C6B;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #5B8C6B;
    cursor: pointer;
    transition: all .25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.cw-recruit__btn:hover {
    background: #5B8C6B;
    color: #fff;
}
.cw-recruit__btn:disabled {
    opacity: .6;
    cursor: default;
}
.cw-recruit__btn--done {
    border-color: #5B8C6B;
    background: #E8F5E9;
    color: #3E6B4E;
    cursor: default;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .cw-widget {
        padding: 16px;
    }
    .cw-mission:not(.cw-mission--counter) {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .cw-mission__btn {
        width: 100%;
        justify-content: center;
    }
    .cw-recruit__card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .cw-recruit__btn {
        width: 100%;
        justify-content: center;
    }
}
