/* ════════════════════════════════════════════════
   Course Detail Page — course-detail.css
   ════════════════════════════════════════════════ */

/* ── Media (video/thumbnail) ── */
.cd-media { border-radius: .75rem; overflow: hidden; }
.cd-media iframe,
.cd-media video,
.cd-media img { width: 100%; display: block; }

/* ── Title ── */
.cd-title { font-size: 1.5rem; font-weight: 700; line-height: 1.4; }

/* ── Meta row ── */
.cd-meta-item { font-size: .9rem; color: #555; white-space: nowrap; }
.cd-category-badge {
    background: #000000;
    color: #FFF !important;
    padding: 7px 11px;
    border-radius: 20px;
    font-weight: bold;
    font-size: .75rem;
    text-decoration: none;
    transition: background .2s;
}
.cd-category-badge:hover { background: #d2e3fc; }

/* ── Instructor row ── */
.cd-instructor-avatar { width: 52px; height: 52px; object-fit: cover; }
.cd-instructor-bio-wrap { font-size: .88rem; }
.cd-bio-less { display: none; }
[aria-expanded="true"] .cd-bio-more { display: none; }
[aria-expanded="true"] .cd-bio-less  { display: inline; }

/* ── Sticky Nav-pills ── */
.cd-nav-wrapper {
    position: sticky;
    top: 96px;          /* ความสูง navbar */
    z-index: 100;
    background: #fff;
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px;
}
.cd-nav-pills {
    display: flex; gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cd-nav-pills::-webkit-scrollbar { display: none; }
.cd-nav-pill {
    padding: 10px 20px;
    font-size: .9rem;
    font-weight: 500;
    color: #747579;
    text-decoration: none;
    border-radius: 20px;
    white-space: nowrap;
    transition: all .25s ease;
}
.cd-nav-pill:hover {
    color: #066ac9;
    background: rgba(6,106,201,.06);
}
.cd-nav-pill.active {
    color: #fff !important;
    background: #066ac9;
}

/* ── Description (read more / less) ── */
.cd-desc-wrap { position: relative; max-height: 200px; overflow: hidden; transition: max-height .4s ease; }
.cd-desc-wrap.expanded { max-height: none !important; }
.cd-desc-fade {
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(transparent, #fff);
    pointer-events: none;
    transition: opacity .3s;
}
.cd-desc-wrap.expanded + .btn-more .desc-more,
.cd-desc-wrap.expanded ~ .btn-more .desc-more { display: none; }
.cd-desc-wrap.expanded + .btn-more .desc-less,
.cd-desc-wrap.expanded ~ .btn-more .desc-less { display: inline; }
.cd-desc-wrap:not(.expanded) + .btn-more .desc-less,
.cd-desc-wrap:not(.expanded) ~ .btn-more .desc-less { display: none; }
.cd-desc-wrap:not(.expanded) + .btn-more .desc-more,
.cd-desc-wrap:not(.expanded) ~ .btn-more .desc-more { display: inline; }
.cd-desc-wrap.expanded .cd-desc-fade { opacity: 0; }
.btn-more { cursor: pointer; font-size: .9rem; color: #066ac9; }
.btn-more i { transition: transform .3s; }
.cd-desc-wrap.expanded ~ .btn-more i { transform: rotate(180deg); }

/* ── Curriculum ── */
.cd-accordion .accordion-button { font-size: .95rem; font-weight: 600; padding: .75rem 1rem; }
.cd-accordion .accordion-button:not(.collapsed) { background: #f8f9fa; box-shadow: none; }
.cd-accordion .accordion-body { padding: .5rem 1rem; }
.cd-video-item { font-size: .88rem; }
.cd-video-item .btn-round { width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; }
.btn-danger-soft { background: rgba(214, 41, 62, .1) !important; color: #d6293e !important; border: none; }

/* ── Flipbook ── */
.cd-flipbook-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}
.cd-flipbook-stage {
    flex: 1;
    min-height: 300px;
    min-width: 0;
}
.cd-flip-arrow {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .2s;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.cd-flip-arrow:hover {
    background: #066ac9;
    color: #fff;
    border-color: #066ac9;
}
@media (max-width: 575.98px) {
    .cd-flip-arrow {
        width: 32px;
        height: 32px;
        font-size: .8rem;
    }
}

/* ── Reviews ── */
.cd-reviews-list .avatar-lg { width: 48px; height: 48px; }
.cd-reviews-list .avatar-img { width: 48px; height: 48px; object-fit: cover; }

/* ── Sidebar (desktop sticky) ── */
.cd-sidebar {
    position: sticky;
    top: 102px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    scrollbar-width: thin;
    border-radius: 12px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}

/* ── Price Card Shadow ── */
.cd-price-card {
    border: none !important;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
}

/* ── Icon Buttons (Heart + Share) ── */
.cd-icon-btn {
    background: none; border: none; padding: 4px;
    font-size: 1.2rem; color: #adb5bd;
    cursor: pointer; transition: all .2s ease;
    line-height: 1;
}
.cd-icon-btn:hover { transform: scale(1.15); }
.cd-wishlist-btn:hover,
.cd-wishlist-btn:focus { color: #dc3545; }
.cd-wishlist-btn.active { color: #dc3545; }
.cd-wishlist-btn.active i { animation: wishPop .3s ease; }
@keyframes wishPop { 0%{transform:scale(1)} 50%{transform:scale(1.3)} 100%{transform:scale(1)} }
.cd-share-btn:hover,
.cd-share-btn:focus { color: #198754; }

/* ── Course Info Grid ── */
.cd-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}
.cd-info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.cd-info-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #f0f6ff;
    color: #066ac9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}
.cd-info-item small { font-size: .72rem; }
.cd-info-item .fw-semibold { font-size: .82rem; }

/* ── LINE Button ── */
.cd-line-btn {
    border-color: #06c755 !important;
    color: #06c755 !important;
}
.cd-line-btn:hover {
    background: #06c755 !important;
    color: #fff !important;
}

/* Package selection in sidebar */
.cd-pkg-item { cursor: pointer; transition: border-color .2s, background .2s; }
.cd-pkg-item:hover { border-color: #066ac9 !important; }
.cd-pkg-item.selected { border-color: #066ac9 !important; background: #f0f7ff; }

/* ── Mobile bottom bar ── */
.cd-mobile-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1040;
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 10px 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.1);
    transform: translateY(100%);
    transition: transform .3s ease;
}
.cd-mobile-bar.visible { transform: translateY(0); }

/* Row 1 */
.cd-mb-title {
    font-weight: 700;
    font-size: .85rem;
    color: #333;
}
.cd-mb-cert {
    background: #ff8c00;
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Row 2 */
.cd-mb-stats {
    display: flex;
    font-size: .8rem;
    color: #000;
}
.cd-mb-stats span {
    white-space: nowrap;
    font-size: 13.5px;
}

/* Row 3 */
.cd-mobile-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ec3b3b;
}
.cd-mb-buy-btn {
    border-radius: 9999px !important;
    padding: 6px 18px !important;
    font-size: .85rem !important;
}

/* ── Guest modal ── */
#guestBuyModal .form-control:focus { box-shadow: 0 0 0 .15rem rgba(6,106,201,.25); }

/* ── Responsive ── */
@media (max-width: 1199.98px) {
    .cd-nav-wrapper { top: 70px; }
    /* เพิ่ม padding-bottom สำหรับ mobile bar */
    .cd-page { padding-bottom: 80px !important; }
}

@media (max-width: 575.98px) {
    .cd-title { font-size: 1.25rem; }
    .cd-meta-item { font-size: .8rem; }
    .cd-nav-pill { padding: 8px 12px; font-size: .85rem; }
}

/* ── Copy link tooltip ── */
.cd-copied-toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: #333; color: #fff; padding: 8px 20px;
    border-radius: 20px; font-size: .85rem;
    animation: cdFadeInOut 2s forwards;
    z-index: 9999;
}
@keyframes cdFadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; }
    100% { opacity: 0; }
}

/* ── Share dropdown on hover (desktop) ── */
@media (min-width: 992px) {
    .cd-share-wrap:hover > .dropdown-menu {
        display: block;
        margin-top: 0;
    }
}

/* ── Share dropdown: hover on desktop ── */
@media (min-width: 992px) {
    .cd-share-wrap:hover > .dropdown-menu {
        display: block;
        margin-top: 0;
    }
    .cd-share-wrap > .cd-share-btn[data-bs-toggle] {
        pointer-events: none; /* desktop: ไม่ต้องกด ให้ hover เปิดเอง */
    }
    .cd-share-wrap:hover > .cd-share-btn {
        pointer-events: none;
    }
    .cd-share-wrap > .dropdown-menu {
        pointer-events: auto;
    }
}
/* mobile: ใช้ click ปกติผ่าน data-bs-toggle="dropdown" */

/* ── Instructor Profile Section ── */
.cd-instructor-photo {
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.cd-instructor-bio {
    font-size: .92rem;
    line-height: 1.7;
    color: #333;
}
/* ── Meta inline (right side) ── */
.cd-meta-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .78rem;
    color: #555;
    white-space: nowrap;
}
.cd-meta-inline span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
/* ── ปุ่ม Toggle ประวัติผู้สอน ── */
.cd-bio-toggle-btn {
    background: #daf0ff;
    color: #0066cc;
    border: none;
    border-radius: 9999px;
    padding: 5px 10px 3px 10px;
    transition: background .25s, color .25s;
}
.cd-bio-toggle-btn:hover {
    background: #c5e5ff;
    color: #0066cc;
}
.cd-bio-toggle-btn[aria-expanded="true"] {
    background: #0099ff;
    color: #fff;
}
.cd-bio-toggle-btn[aria-expanded="true"]:hover {
    background: #0088e6;
    color: #fff;
}
/* ── ป้องกัน horizontal scroll บน mobile ── */
body.cd-body-no-overflow-x {
    overflow-x: hidden;
}
.cd-video-item span,
.cd-video-item .flex-grow-1 {
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}
.cd-accordion .accordion-body {
    overflow: hidden;
}
.cd-accordion .accordion-button > .d-flex {
    min-width: 0;
    overflow: hidden;
}
.cd-accordion .accordion-button > .d-flex > span:first-child {
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

/* ── Free play button ── */
.cd-play-free-btn {
    background: none; border: none; padding: 0; cursor: pointer;
}
.cd-free-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: #e8f5e9; color: #2e7d32;
    font-size: .7rem; font-weight: 600;
    padding: 3px 8px; border-radius: 9999px;
    transition: background .2s;
}
.cd-free-badge i { font-size: .85rem; }
.cd-play-free-btn:hover .cd-free-badge {
    background: #c8e6c9;
}
/* ── Locked play icon ── */
.cd-play-locked {
    color: #bbb; font-size: 1.1rem;
}
/* ── PDF icon ── */
.cd-pdf-icon {
    color: #dc3545; font-size: 1.1rem;
}
/* ── Font: Noto Sans Thai สำหรับ curriculum ── */
.cd-accordion,
.cd-accordion .accordion-button,
.cd-accordion .accordion-body {
    font-family: 'Noto Sans Thai', 'Noto Sans', sans-serif;
}
.cd-accordion .accordion-body .cd-video-item:last-child {
    border-bottom: none !important;
}
/* ── Duration / Download column alignment ── */
.cd-dur-col {
    min-width: 110px;
    flex-shrink: 0;
}
/* ── Curriculum item title — ไม่ล้นจอ ── */
.cd-item-title {
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}
.accordion-body .d-flex.justify-content-between {
    gap: 8px;
}
.accordion-body .d-flex.justify-content-between > .position-relative {
    min-width: 0;
    flex: 1;
}
