/* ==========================================================================
   全域變數與重設 (Variables & Reset)
   ========================================================================== */
:root {
    /* 主題色系 */
    --bg-dark: #09080e;          /* 整體背景深黑 */
    --bg-card: #151324;          /* 卡片背景深紫 */
    --bg-modal: #1a172c;         /* 彈窗背景 */
    --primary-neon: #a252ff;     /* 霓虹紫 */
    --secondary-neon: #00f0ff;   /* 霓虹藍 */
    --accent-red: #ff3b30;       /* 警告或硬核難度紅 */
    --text-white: #ffffff;       /* 白色主要文字 */
    --text-muted: #a3a1b8;       /* 灰色輔助文字 */
    --star-gold: #ffb800;        /* 星星金黃色 */
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 美觀的滾動條 */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: #2b2848;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-neon);
}

/* ==========================================================================
   頂部區域 (Header)
   ========================================================================== */
.header {
    text-align: center;
    padding: 3rem 1.5rem 2rem;
    background: linear-gradient(180deg, rgba(22, 20, 38, 0.8) 0%, rgba(9, 8, 14, 0) 100%);
}

.logo-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px var(--primary-neon));
}

.logo-title {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(45deg, var(--primary-neon), var(--secondary-neon));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(162, 82, 255, 0.3));
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

/* 篩選器 (Filters) */
.filter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: rgba(21, 19, 36, 0.6);
    border: 1px solid rgba(162, 82, 255, 0.15);
    padding: 1rem 2rem;
    border-radius: 50px;
    display: inline-flex;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.filter-group select {
    background-color: rgba(9, 8, 14, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    padding: 0.4rem 1.2rem;
    border-radius: 20px;
    outline: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.filter-group select:focus {
    border-color: var(--primary-neon);
    box-shadow: 0 0 8px rgba(162, 82, 255, 0.5);
}

/* ==========================================================================
   劇本列表 (Script Grid)
   ========================================================================== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.script-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

/* 劇本卡片 (Script Card) */
.script-card {
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* 懸停發光與放大效果 */
.script-card:hover {
    transform: translateY(-8px);
    border-color: rgba(162, 82, 255, 0.4);
    box-shadow: 0 15px 30px rgba(162, 82, 255, 0.15), 0 0 15px rgba(0, 240, 255, 0.1);
}

/* CSS 製作精美海報區 */
.card-cover {
    height: 180px;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #2b1055, #7597de);
    overflow: hidden;
}

.card-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 100%);
}

.card-emoji {
    font-size: 3.5rem;
    z-index: 1;
    transition: var(--transition-smooth);
}

.script-card:hover .card-emoji {
    transform: scale(1.15) rotate(5deg);
}

/* 難度標籤 */
.difficulty-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 0.25rem 0.8rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* 不同難度的顏色 */
.badge-easy { background-color: #28cd41; color: #fff; }
.badge-medium { background-color: #ff9500; color: #fff; }
.badge-hard { background-color: var(--accent-red); color: #fff; }

/* 卡片文字內容 */
.card-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-white);
    transition: var(--transition-smooth);
}

.script-card:hover .card-title {
    color: var(--secondary-neon);
}

.card-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* 卡片腳部資訊 */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.8rem;
    margin-top: auto;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-stars {
    color: var(--star-gold);
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ==========================================================================
   詳細資訊彈窗 (Modal Dialog)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 4, 8, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--bg-modal);
    border: 1px solid rgba(162, 82, 255, 0.25);
    border-radius: 20px;
    width: 90%;
    max-width: 950px;
    max-height: 85vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(162, 82, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* 關閉按鈕 */
.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    z-index: 1010;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    color: var(--accent-red);
    transform: rotate(90deg);
}

/* 彈窗內容佈局 */
.modal-body {
    display: flex;
    height: 85vh;
    max-height: 85vh;
}

@media (max-width: 768px) {
    .modal-body {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
        max-height: 85vh;
    }
    .modal-left, .modal-right {
        width: 100% !important;
        height: auto !important;
    }
}

/* 彈窗左側：基本描述 */
.modal-left {
    width: 45%;
    padding: 2.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.modal-cover {
    height: 200px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.cover-emoji {
    font-size: 4rem;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 0.8rem;
    line-height: 1.2;
}

.modal-meta-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.modal-tag {
    background-color: rgba(255, 255, 255, 0.07);
    color: var(--text-white);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rating-display-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 184, 0, 0.08);
    border: 1px solid rgba(255, 184, 0, 0.2);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    width: fit-content;
}

.average-stars {
    color: var(--star-gold);
    font-size: 1.1rem;
}

.average-score {
    font-weight: 800;
    color: var(--star-gold);
    font-size: 1.2rem;
}

.total-reviews {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal-description {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: pre-line;
}

/* 彈窗右側：評論與表單 */
.modal-right {
    width: 55%;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto; /* 允許右側面板整體滾動，極致防高度擠壓 */
}

.modal-right h3 {
    margin-bottom: 1.2rem;
    font-size: 1.3rem;
    font-weight: 800;
    border-left: 4px solid var(--primary-neon);
    padding-left: 0.5rem;
}

/* 評論串流區 */
.reviews-list {
    flex-grow: 1;
    min-height: 200px;
    max-height: 350px; /* 限制最高高度，超出版面時內部滾動 */
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

.review-item {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.4s ease forwards;
}

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

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.reviewer-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--secondary-neon);
}

.reviewer-stars {
    color: var(--star-gold);
    font-size: 0.85rem;
}

.review-comment {
    font-size: 0.88rem;
    color: var(--text-muted);
    word-break: break-all;
}

.review-date {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.2);
    text-align: right;
    margin-top: 0.3rem;
}

.no-reviews-placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem 0;
}

/* 填寫評論表單區 */
.review-form-container {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.5rem;
    margin-top: auto;
}

.review-form-container h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-white);
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.name-group {
    width: 60%;
}

.rating-group {
    width: 40%;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-group input, .form-group textarea {
    background-color: rgba(9, 8, 14, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group textarea:focus {
    border-color: var(--secondary-neon);
}

/* CSS 經典星級評分選取器 */
.star-rating-input {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    height: 38px;
}

.star-rating-input input {
    display: none;
}

.star-rating-input label {
    font-size: 1.6rem;
    color: #3b3758;
    cursor: pointer;
    transition: color 0.15s ease-in-out;
    padding: 0 2px;
}

.star-rating-input label:hover,
.star-rating-input label:hover ~ label,
.star-rating-input input:checked ~ label {
    color: var(--star-gold);
}

.submit-btn {
    background: linear-gradient(90deg, var(--primary-neon), #c15eff);
    border: none;
    color: var(--text-white);
    padding: 0.7rem 1.5rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(162, 82, 255, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(162, 82, 255, 0.5);
    background: linear-gradient(90deg, #b062ff, var(--primary-neon));
}

/* ==========================================================================
   多媒體評論上傳與顯示樣式 (Media Upload & Display Styles)
   ========================================================================== */
.media-upload-row {
    margin-bottom: 1.2rem;
}

.media-group {
    width: 50%;
}

.media-group input[type="file"] {
    background-color: rgba(9, 8, 14, 0.7);
    border: 1px dashed rgba(162, 82, 255, 0.3);
    padding: 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
}

.media-group input[type="file"]:hover {
    border-color: var(--secondary-neon);
    background-color: rgba(162, 82, 255, 0.05);
}

/* 貼文式多媒體顯示容器 */
.review-media-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.review-photo-preview {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.review-photo-preview:hover {
    transform: scale(1.02);
    border-color: var(--secondary-neon);
}

.review-video-preview {
    width: 100%;
    max-height: 250px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    outline: none;
    background-color: #000;
}

/* ==========================================================================
   頁籤分頁樣式 (Tabs & Lobbies Styles)
   ========================================================================== */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1.5rem;
    gap: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.6rem 0.2rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-white);
}

.tab-btn.active {
    color: var(--secondary-neon);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--secondary-neon);
    box-shadow: 0 0 8px var(--secondary-neon);
}

/* 分頁切換隱藏/顯示 */
.tab-pane {
    display: none;
    flex-direction: column;
    flex-grow: 1;
}

.tab-pane.active {
    display: flex;
}

/* 組局房間列表 */
.sessions-list {
    flex-grow: 1;
    min-height: 200px;
    max-height: 350px; /* 限制最高高度，超出版面時內部滾動 */
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding-right: 0.5rem;
}

.session-item {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(162, 82, 255, 0.15);
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    animation: fadeIn 0.4s ease forwards;
}

.session-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-time {
    color: var(--secondary-neon);
    font-weight: 700;
    font-size: 0.95rem;
}

.session-slots {
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background-color: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.2);
}

.session-slots.full {
    background-color: rgba(255, 59, 48, 0.1);
    border-color: rgba(255, 59, 48, 0.2);
    color: var(--accent-red);
}

.session-host-info {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.session-host-name {
    color: var(--text-white);
    font-weight: 700;
}

/* 玩家上車名單 */
.session-players-box {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.6rem;
}

.session-players-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.session-players-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.player-tag {
    background-color: rgba(162, 82, 255, 0.12);
    border: 1px solid rgba(162, 82, 255, 0.25);
    color: #dfbaff;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.player-tag.is-host {
    background-color: rgba(0, 240, 255, 0.15);
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--secondary-neon);
}

.no-sessions-placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem 0;
}

/* 發起組局表單容器 */
.session-form-container {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.5rem;
    margin-top: auto;
}

.session-form-container h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-white);
}

.host-group, .time-group, .store-group, .price-group {
    width: 50%;
}

.adjust-time-btn {
    background: none;
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: var(--secondary-neon);
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    vertical-align: middle;
}

.adjust-time-btn:hover {
    background-color: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 5px var(--secondary-neon);
}

.session-details-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    background-color: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 0.5rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.session-store, .session-price {
    display: flex;
    align-items: center;
    gap: 4px;
}

.session-join-area {
    display: flex;
    justify-content: flex-end;
}

.join-btn {
    background: linear-gradient(90deg, #00c6ff, #0072ff);
    border: none;
    color: var(--text-white);
    padding: 0.5rem 1.2rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.join-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.4);
}

.join-btn:disabled {
    background: #2b2848;
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   頁尾 (Footer)
   ========================================================================== */
.footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 4rem;
}
