/* ============================================================
   MyKey 牙醫線上學院 - 前台樣式 (可自行客製)
   ============================================================ */

:root {
    --mk-primary: #01a78d;
    /* 牙科主色 teal */
    --mk-primary-dark: #0f766e;
    --mk-accent: #f59e0b;
    --mk-dark: #0f172a;
    --mk-dark-2: #1e293b;
    --mk-text: #1e293b;
    --mk-muted: #64748b;
    --mk-bg: #f8fafc;
}

body {
    font-family: "微軟正黑體", "Noto Sans TC", "Microsoft JhengHei", -apple-system, "Segoe UI", sans-serif;
    color: var(--mk-text);
    background: var(--mk-bg);
}

a {
    text-decoration: none;
}


/* 主色覆寫 Bootstrap */

.btn-primary {
    --bs-btn-bg: var(--mk-primary);
    --bs-btn-border-color: var(--mk-primary);
    --bs-btn-hover-bg: var(--mk-primary-dark);
    --bs-btn-hover-border-color: var(--mk-primary-dark);
    --bs-btn-active-bg: var(--mk-primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--mk-primary);
    --bs-btn-border-color: var(--mk-primary);
    --bs-btn-hover-bg: var(--mk-primary);
    --bs-btn-hover-border-color: var(--mk-primary);
}

.text-primary {
    color: var(--mk-primary) !important;
}

.bg-primary {
    background-color: var(--mk-primary) !important;
}

.badge.bg-primary {
    background-color: var(--mk-primary) !important;
}

.link-primary,
a.text-primary {
    color: var(--mk-primary) !important;
}


/* Navbar */

.mk-navbar {
    background: var(--mk-dark);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}

.mk-navbar .navbar-brand {
    font-size: 1rem;
}

.mk-navbar .nav-link {
    font-weight: 500;
}

.mk-navbar .nav-link.active {
    color: var(--mk-accent) !important;
}

.mk-search {
    min-width: 30%;
}

.mk-main {
    min-height: 60vh;
}


/* Hero 輪播 */

.mk-hero .carousel-item {
    height: 440px;
}

.mk-hero .carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mk-hero .carousel-caption {
    background: linear-gradient(transparent, rgba(0, 0, 0, .75));
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3rem 15% 2.5rem;
    text-align: left;
}

.mk-hero .carousel-caption h2 {
    font-weight: 800;
}

@media (max-width: 768px) {
    .mk-hero .carousel-item {
        height: 240px;
    }
    .mk-hero .carousel-caption {
        padding: 1.5rem 8% 1.5rem;
    }
    .mk-hero .carousel-caption h2 {
        font-size: 1.25rem;
    }
}


/* Netflix 橫向分類列 */

.mk-row {
    margin: 1.75rem 0;
}

.mk-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.mk-row-head h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.mk-row-scroll {
    position: relative;
}

.mk-scroller {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding-bottom: .5rem;
    scrollbar-width: thin;
}

.mk-scroller::-webkit-scrollbar {
    height: 6px;
}

.mk-scroller::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.mk-scroller>* {
    flex: 0 0 auto;
    width: 260px;
}

.mk-scroll-btn {
    position: absolute;
    top: 0;
    bottom: 8px;
    width: 30px;
    border: 0;
    background: #f8fafc75;
    backdrop-filter: blur(3px);
    color: #fff;
    z-index: 3;
    opacity: 0;
    transition: .2s;
    cursor: pointer;
}

.mk-row-scroll:hover .mk-scroll-btn {
    opacity: 1;
}

.mk-scroll-btn i {
    color: var(--mk-dark-2)
}

.mk-scroll-btn.prev {
    left: 0;
    border-radius: 0;
}

.mk-scroll-btn.next {
    right: 0;
    border-radius: 0;
}

@media (max-width: 576px) {
    .mk-scroller>* {
        width: 200px;
    }
    .mk-scroll-btn {
        display: none;
    }
}


/* 課程卡片 */

.course-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    transition: transform .18s, box-shadow .18s;
    height: 100%;
    border: 1px solid #eef2f7;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
}

.course-card .cc-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #e2e8f0;
}

.course-card .cc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-card .cc-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.course-card .cc-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, .75);
    color: #fff;
    font-size: .72rem;
    padding: 1px 6px;
    border-radius: 4px;
}

.course-card .cc-body {
    padding: .75rem .85rem 1rem;
}

.course-card .cc-title {
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    color: var(--mk-text);
}

.course-card .cc-meta {
    font-size: .8rem;
    color: var(--mk-muted);
}

.course-card .cc-price .now {
    color: #ef4444;
    font-weight: 700;
}

.course-card .cc-price .orig {
    color: #94a3b8;
    text-decoration: line-through;
    font-size: .8rem;
}

.course-card .cc-progress {
    height: 4px;
}


/* 講師卡 */

.instructor-card {
    text-align: center;
}

.instructor-card img,
.instructor-card .avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto .5rem;
    border: 3px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #94a3b8;
}


/* 直播卡 */

.live-badge {
    background: #ef4444;
    color: #fff;
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 20px;
}

.live-badge.scheduled {
    background: #f59e0b;
}


/* 分頁 */

.pagination .page-link {
    color: var(--mk-primary);
}

.pagination .page-item.active .page-link {
    background: var(--mk-primary);
    border-color: var(--mk-primary);
}


/* Footer */

.mk-footer {
    background: var(--mk-dark);
    color: #cbd5e1;
}

.mk-footer a {
    color: #cbd5e1;
}

.mk-footer a:hover {
    color: #fff;
}

.mk-footer h5,
.mk-footer h6 {
    color: #fff;
}


/* 課程頁 */

.course-hero {
    background: var(--mk-dark);
    color: #fff;
    padding: 2.5rem 0;
}

.course-hero .price-box {
    background: #fff;
    color: var(--mk-text);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
}

.rating-stars i {
    color: var(--mk-accent);
}

.chapter-item {
    border-bottom: 1px solid #eef2f7;
}

.video-item {
    padding: .6rem .75rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: 8px;
}

.video-item:hover {
    background: #f1f5f9;
}

.video-item.locked {
    opacity: .65;
}


/* 課程頁側欄 (捲動跟隨) */

.course-aside {
    position: sticky;
    top: 90px;
}

@media (max-width: 991.98px) {
    .course-aside {
        position: static;
    }
}

.course-aside-list li {
    padding: .3rem 0;
}

.course-aside-list li i {
    width: 1.2rem;
}


/* 長文內容 (課程介紹／商品說明／CMS 頁面): 後台可貼 HTML 或純文字, 兩種都要正常呈現 */

.course-description,
.rich-content {
    line-height: 1.85;
    word-break: break-word;
}

.course-description>*:first-child,
.rich-content>*:first-child {
    margin-top: 0;
}

.course-description>*:last-child,
.rich-content>*:last-child {
    margin-bottom: 0;
}

.course-description p,
.rich-content p {
    margin-bottom: 1rem;
}

.course-description h2,
.course-description h3,
.course-description h4,
.rich-content h2,
.rich-content h3,
.rich-content h4 {
    margin: 1.75rem 0 .75rem;
    font-weight: 700;
    line-height: 1.4;
}

.course-description h2,
.rich-content h2 {
    font-size: 1.35rem;
}

.course-description h3,
.rich-content h3 {
    font-size: 1.15rem;
}

.course-description h4,
.rich-content h4 {
    font-size: 1.05rem;
}

.course-description ul,
.course-description ol,
.rich-content ul,
.rich-content ol {
    margin: 0 0 1rem;
    padding-left: 1.4rem;
}

.course-description li,
.rich-content li {
    margin-bottom: .35rem;
}

.course-description blockquote,
.rich-content blockquote {
    margin: 1.25rem 0;
    padding: .75rem 1rem;
    border-left: 4px solid var(--mk-primary);
    background: #f8fafc;
    color: #475569;
}

.course-description hr,
.rich-content hr {
    margin: 1.75rem 0;
}


/* 牙齒展示圖等內文圖片: 一律縮到容器寬度, 可點擊放大 */

.course-description img,
.rich-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.25rem auto;
    border-radius: 10px;
    cursor: zoom-in;
}

.course-description figure,
.rich-content figure {
    margin: 1.25rem 0;
}

.course-description figcaption,
.rich-content figcaption {
    text-align: center;
    font-size: .875rem;
    color: #64748b;
    margin-top: .5rem;
}

.course-description iframe,
.rich-content iframe {
    max-width: 100%;
    border: 0;
    border-radius: 10px;
    aspect-ratio: 16/9;
    height: auto;
}


/* 表格: 加框線, 過寬時容器可橫向捲動而不撐破版面 */

.course-description table,
.rich-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.course-description table th,
.course-description table td,
.rich-content table th,
.rich-content table td {
    border: 1px solid #e2e8f0;
    padding: .5rem .75rem;
}

.course-description table th,
.rich-content table th {
    background: #f8fafc;
}

.course-description,
.rich-content {
    overflow-x: auto;
}


/* 內文圖片放大檢視 */

.mk-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .88);
    padding: 2rem;
    cursor: zoom-out;
}

.mk-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.mk-lightbox .mk-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    color: #fff;
    background: none;
    border: 0;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}


/* 播放頁 */

body.player-page {
    background: #0b1120;
    color: #e2e8f0;
}

.player-wrap {
    background: #000;
}

.player-wrap video {
    width: 100%;
    max-height: 78vh;
    display: block;
}

.playlist {
    background: #0f172a;
    max-height: 78vh;
    overflow-y: auto;
}

.playlist .video-item {
    color: #cbd5e1;
}

.playlist .video-item:hover {
    background: #1e293b;
}

.playlist .video-item.active {
    background: var(--mk-primary-dark);
    color: #fff;
}


/* 直播聊天室 */

.live-chat-box {
    height: 340px;
    overflow-y: auto;
    padding: .6rem .75rem;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.live-chat-box .chat-row {
    padding: .3rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    word-break: break-word;
}

.live-chat-box .chat-row:last-child {
    border-bottom: 0;
}

.live-chat-box .chat-name {
    font-size: .78rem;
    color: #7dd3fc;
    font-weight: 600;
}

.live-chat-box .chat-time {
    color: #64748b;
    font-weight: 400;
    margin-left: .4rem;
    font-size: .7rem;
}

.live-chat-box .chat-del {
    color: #f87171;
    text-decoration: none;
    margin-left: .4rem;
    font-size: .7rem;
}

.live-chat-box .chat-text {
    font-size: .88rem;
    color: #e2e8f0;
    line-height: 1.45;
}

.live-chat-box .chat-system {
    color: #fbbf24;
    font-size: .8rem;
    text-align: center;
    border-bottom: 0;
}

.live-chat-box .chat-reaction {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.live-chat-box .chat-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

.live-chat-box::-webkit-scrollbar {
    width: 6px;
}

.live-chat-box::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}


/* 表情飄浮 */

.reaction-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.reaction-fly {
    position: absolute;
    bottom: 8%;
    font-size: 1.6rem;
    animation: mkFly 3s ease-out forwards;
}

@keyframes mkFly {
    0% {
        transform: translateY(0) scale(.6);
        opacity: 0;
    }
    15% {
        transform: translateY(-18px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-220px) scale(1.1);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reaction-fly {
        animation-duration: .01ms;
    }
}

@media (max-width: 991.98px) {
    .live-chat-box {
        height: 260px;
    }
}


/* 通用 */

.section-title {
    font-weight: 700;
    position: relative;
    padding-left: .75rem;
}

.section-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: .15em;
    bottom: .15em;
    width: 5px;
    background: var(--mk-primary);
    border-radius: 3px;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.object-cover {
    object-fit: cover;
}

.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* 友站連結卡片 hover */

.link-card {
    transition: transform .15s ease, box-shadow .15s ease;
}

.link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .12) !important;
}


/* 影片字幕 (WebVTT) — 跨平台可讀性 + 防跑版 (含 iOS Safari) */

#mkPlayer::cue {
    background-color: rgba(0, 0, 0, .72);
    color: #fff;
    font-size: 1.02em;
    line-height: 1.35;
    white-space: pre-line;
}

@media (max-width: 640px) {
    #mkPlayer::cue {
        font-size: .92em;
    }
}


/* ---------- 播放器字幕大小 (學員可自行調整, 記憶於瀏覽器) ---------- */


/* ::cue 需分開寫 —— 瀏覽器遇到不認得的選擇器會整組丟棄 */

.player-wrap video::cue {
    background: rgba(0, 0, 0, .72);
    color: #fff;
    line-height: 1.35;
    font-size: var(--mk-cue-size, 1.15rem);
}

.player-wrap video::-webkit-media-text-track-display {
    font-size: var(--mk-cue-size, 1.15rem) !important;
}


/* iOS/Safari 原生播放器改由系統字幕設定控制, 此處僅影響一般瀏覽器 */

.sub-sm {
    --mk-cue-size: .95rem;
}

.sub-md {
    --mk-cue-size: 1.15rem;
}

.sub-lg {
    --mk-cue-size: 1.5rem;
}

.sub-xl {
    --mk-cue-size: 2rem;
}

#subSizeGroup .btn.active {
    background: var(--mk-primary);
    border-color: var(--mk-primary);
    color: #fff;
}