/* ===================================================
   MS Course Category Tabs - Premium Frontend Styles
   v2.0 — 프리미엄 플러그인 급 디자인
   =================================================== */

/* ── CSS 변수 (커스터마이징 용이) ─────────────────── */
.ms-course-tabs-wrap {
    --ct-primary:       #3b82f6;
    --ct-primary-hover: #2563eb;
    --ct-primary-light: #eff6ff;
    --ct-primary-soft:  #dbeafe;
    --ct-text:          #1e293b;
    --ct-text-muted:    #64748b;
    --ct-text-light:    #94a3b8;
    --ct-bg:            #ffffff;
    --ct-bg-secondary:  #f8fafc;
    --ct-border:        #e2e8f0;
    --ct-border-light:  #f1f5f9;
    --ct-radius:        12px;
    --ct-radius-sm:     8px;
    --ct-shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --ct-shadow-md:     0 4px 16px rgba(0,0,0,0.08);
    --ct-shadow-lg:     0 12px 40px rgba(0,0,0,0.12);
    --ct-transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);

    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── 탭 내비게이션 ────────────────────────────────── */
.ms-ct-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 0;
    margin-bottom: 32px;
    position: sticky;
    top: 0;
    background: var(--ct-bg);
    z-index: 100;
    /* 하단 그림자 효과 (스크롤 시 구분감) */
    box-shadow: 0 1px 0 var(--ct-border);
}

/* 탭 공통 스타일 (pill 디자인) */
.ms-ct-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border: 1.5px solid var(--ct-border);
    border-radius: 50px;
    background: var(--ct-bg);
    color: var(--ct-text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    transition: all var(--ct-transition);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
}

/* 호버 효과 */
.ms-ct-tab:hover {
    color: var(--ct-primary);
    border-color: var(--ct-primary);
    background: var(--ct-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--ct-shadow-sm);
}

/* 활성 탭 */
.ms-ct-tab.active {
    color: #ffffff;
    background: var(--ct-primary);
    border-color: var(--ct-primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.ms-ct-tab.active:hover {
    background: var(--ct-primary-hover);
    border-color: var(--ct-primary-hover);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

/* 탭 리플 효과 (클릭 시) */
.ms-ct-tab:active {
    transform: translateY(0);
    box-shadow: none;
}

/* 카운트 배지 */
.ms-ct-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    transition: all var(--ct-transition);
    background: var(--ct-border-light);
    color: var(--ct-text-light);
}

.ms-ct-tab:hover .ms-ct-tab-count {
    background: var(--ct-primary-soft);
    color: var(--ct-primary);
}

.ms-ct-tab.active .ms-ct-tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* ── 그리드 래퍼 ─────────────────────────────────── */
.ms-ct-grid-wrap {
    position: relative;
    min-height: 200px;
}

/* ── 로딩 오버레이 ────────────────────────────────── */
.ms-ct-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
    border-radius: var(--ct-radius);
}

.ms-ct-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ct-border);
    border-top-color: var(--ct-primary);
    border-radius: 50%;
    animation: ms-ct-spin 0.7s linear infinite;
}

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

/* ── 강의 그리드 ─────────────────────────────────── */
.ms-ct-grid {
    display: grid;
    gap: 24px;
}

.ms-ct-cols-1 { grid-template-columns: 1fr; }
.ms-ct-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ms-ct-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ms-ct-cols-4 { grid-template-columns: repeat(4, 1fr); }
.ms-ct-cols-5 { grid-template-columns: repeat(5, 1fr); }
.ms-ct-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ── 강의 카드 ───────────────────────────────────── */
.ms-ct-card {
    background: var(--ct-bg);
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    overflow: hidden;
    transition: all var(--ct-transition);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.ms-ct-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--ct-shadow-lg);
    border-color: transparent;
    text-decoration: none;
    color: inherit;
}

/* 카드 상단 포커스 라인 */
.ms-ct-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ct-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--ct-transition);
    z-index: 2;
    border-radius: var(--ct-radius) var(--ct-radius) 0 0;
}

.ms-ct-card:hover::before {
    transform: scaleX(1);
}

/* 썸네일 */
.ms-ct-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    overflow: hidden;
    background: var(--ct-bg-secondary);
}

.ms-ct-thumbnail img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-ct-card:hover .ms-ct-thumbnail img {
    transform: scale(1.06);
}

/* 썸네일 없을 때 placeholder */
.ms-ct-thumbnail--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf4 100%);
}

.ms-ct-thumb-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    opacity: 0.3;
}

/* 카드 바디 */
.ms-ct-card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

/* 카테고리 뱃지 */
.ms-ct-cat-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--ct-primary-light);
    color: var(--ct-primary);
    letter-spacing: 0.2px;
    margin-bottom: 2px;
}

.ms-ct-cat-badge svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

/* 배지 (레벨) */
.ms-ct-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ms-ct-level {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: var(--ct-primary-light);
    color: var(--ct-primary);
}

/* 레벨별 색상 */
.ms-ct-level--beginner     { background: #dcfce7; color: #166534; }
.ms-ct-level--intermediate { background: #fef9c3; color: #854d0e; }
.ms-ct-level--advanced     { background: #fce7f3; color: #9d174d; }
.ms-ct-level--expert       { background: #ede9fe; color: #5b21b6; }
.ms-ct-level--all          { background: #f1f5f9; color: #475569; }

/* 제목 */
.ms-ct-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--ct-text);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--ct-transition);
}

.ms-ct-card:hover .ms-ct-title {
    color: var(--ct-primary);
}

/* 요약 */
.ms-ct-excerpt {
    font-size: 13px;
    color: var(--ct-text-muted);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* 강사 / 수강생 */
.ms-ct-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--ct-text-light);
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--ct-border-light);
    flex-wrap: wrap;
}

.ms-ct-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ms-ct-meta-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.6;
}

/* 가격 */
.ms-ct-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--ct-text);
    margin-top: auto;
    letter-spacing: -0.3px;
}

.ms-ct-price.free {
    color: #059669;
    font-size: 14px;
    font-weight: 700;
    background: #dcfce7;
    padding: 2px 10px;
    border-radius: 6px;
    display: inline-block;
}

.ms-ct-price del {
    font-weight: 400;
    color: var(--ct-text-light);
    margin-right: 6px;
    font-size: 13px;
}

.ms-ct-price.sale {
    color: #dc2626;
}

/* ── 빈 상태 ─────────────────────────────────────── */
.ms-ct-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--ct-text-muted);
    font-size: 15px;
}

.ms-ct-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.35;
}

/* ── 페이지네이션 ─────────────────────────────────── */
.ms-ct-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--ct-border);
}

.ms-ct-pagination button {
    padding: 10px 24px;
    border: 1.5px solid var(--ct-border);
    background: var(--ct-bg);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--ct-text-muted);
    transition: all var(--ct-transition);
}

.ms-ct-pagination button:hover:not(:disabled) {
    background: var(--ct-primary);
    border-color: var(--ct-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.ms-ct-pagination button:active:not(:disabled) {
    transform: translateY(0);
}

.ms-ct-pagination button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.ms-ct-page-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-text-muted);
    min-width: 70px;
    text-align: center;
    letter-spacing: 1px;
}

/* ── 반응형 ──────────────────────────────────────── */

/* 태블릿 대형 */
@media (max-width: 1200px) {
    .ms-ct-cols-5,
    .ms-ct-cols-6 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 태블릿 */
@media (max-width: 992px) {
    .ms-ct-cols-4,
    .ms-ct-cols-5,
    .ms-ct-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .ms-ct-tabs {
        gap: 6px;
    }

    .ms-ct-tab {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* 모바일 가로 */
@media (max-width: 768px) {
    .ms-ct-cols-3,
    .ms-ct-cols-4,
    .ms-ct-cols-5,
    .ms-ct-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .ms-ct-grid {
        gap: 16px;
    }

    .ms-ct-tabs {
        position: relative;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 12px 0;
        margin-bottom: 24px;
        gap: 6px;
        /* 좌우 그라데이션 페이드 효과 */
        mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
    }
    .ms-ct-tabs::-webkit-scrollbar {
        display: none;
    }

    .ms-ct-tab {
        font-size: 13px;
        padding: 7px 14px;
    }

    .ms-ct-card-body {
        padding: 14px;
    }
}

/* 모바일 세로 */
@media (max-width: 480px) {
    .ms-ct-cols-2,
    .ms-ct-cols-3,
    .ms-ct-cols-4,
    .ms-ct-cols-5,
    .ms-ct-cols-6 {
        grid-template-columns: 1fr;
    }

    .ms-ct-grid {
        gap: 14px;
    }

    .ms-ct-card-body {
        padding: 12px;
    }

    .ms-ct-title {
        font-size: 14px;
    }
}

/* ── 애니메이션 ──────────────────────────────────── */

/* 카드 등장 애니메이션 */
@keyframes ms-ct-fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ms-ct-grid .ms-ct-card {
    animation: ms-ct-fadeUp 0.4s ease both;
}

.ms-ct-grid .ms-ct-card:nth-child(1)  { animation-delay: 0.02s; }
.ms-ct-grid .ms-ct-card:nth-child(2)  { animation-delay: 0.06s; }
.ms-ct-grid .ms-ct-card:nth-child(3)  { animation-delay: 0.10s; }
.ms-ct-grid .ms-ct-card:nth-child(4)  { animation-delay: 0.14s; }
.ms-ct-grid .ms-ct-card:nth-child(5)  { animation-delay: 0.18s; }
.ms-ct-grid .ms-ct-card:nth-child(6)  { animation-delay: 0.22s; }
.ms-ct-grid .ms-ct-card:nth-child(7)  { animation-delay: 0.26s; }
.ms-ct-grid .ms-ct-card:nth-child(8)  { animation-delay: 0.30s; }
.ms-ct-grid .ms-ct-card:nth-child(9)  { animation-delay: 0.34s; }
.ms-ct-grid .ms-ct-card:nth-child(10) { animation-delay: 0.38s; }
.ms-ct-grid .ms-ct-card:nth-child(11) { animation-delay: 0.42s; }
.ms-ct-grid .ms-ct-card:nth-child(12) { animation-delay: 0.46s; }

/* ── 접근성: 키보드 포커스 ────────────────────────── */
.ms-ct-tab:focus-visible {
    outline: 2px solid var(--ct-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.ms-ct-card:focus-visible {
    outline: 2px solid var(--ct-primary);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   Elementor 탭 스타일 변형
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Underline 스타일 ─────────────────────────── */
.ms-ct-style-underline .ms-ct-tabs {
    border-bottom: 2px solid var(--ct-border);
    box-shadow: none;
    gap: 0;
}

.ms-ct-style-underline .ms-ct-tab {
    border: none;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    padding-left: 16px;
    padding-right: 16px;
}

.ms-ct-style-underline .ms-ct-tab:hover {
    background: transparent;
    border-bottom-color: var(--ct-border);
    transform: none;
    box-shadow: none;
}

.ms-ct-style-underline .ms-ct-tab.active {
    background: transparent;
    color: var(--ct-primary, #3b82f6);
    border-bottom-color: currentColor;
    box-shadow: none;
    transform: none;
}

.ms-ct-style-underline .ms-ct-tab.active .ms-ct-tab-count {
    background: var(--ct-primary-light, #eff6ff);
    color: var(--ct-primary, #3b82f6);
}


/* ── 2. Box 스타일 ───────────────────────────────── */
.ms-ct-style-box .ms-ct-tab {
    border-radius: 8px;
    border-width: 1.5px;
}

.ms-ct-style-box .ms-ct-tab.active {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}


/* ── 3. Flat 스타일 ──────────────────────────────── */
.ms-ct-style-flat .ms-ct-tab {
    border: none;
    border-radius: 8px;
    background: var(--ct-bg-secondary, #f8fafc);
}

.ms-ct-style-flat .ms-ct-tab:hover {
    background: var(--ct-primary-light, #eff6ff);
    transform: none;
    box-shadow: none;
}

.ms-ct-style-flat .ms-ct-tab.active {
    box-shadow: none;
    transform: none;
}


/* ── 활성 그림자 토글 ─────────────────────────────── */
.ms-ct-active-shadow .ms-ct-tab.active {
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.35);
}

/* 그림자 OFF일 때 */
.ms-course-tabs-wrap:not(.ms-ct-active-shadow) .ms-ct-tab.active {
    box-shadow: none;
}


/* ── 카운트 숨김 (Elementor에서 OFF할 때) ─────────── */
.ms-ct-hide-count .ms-ct-tab-count {
    display: none !important;
}


/* ── 다크모드 지원 (선택적) ───────────────────────── */
@media (prefers-color-scheme: dark) {
    .ms-course-tabs-wrap[data-theme="auto"] {
        --ct-text: #e2e8f0;
        --ct-text-muted: #94a3b8;
        --ct-text-light: #64748b;
        --ct-bg: #0f172a;
        --ct-bg-secondary: #1e293b;
        --ct-border: #334155;
        --ct-border-light: #1e293b;
    }
}
