﻿/* ══════════════════════════════════════════════════════════════════
   COMPONENTS — Buttons, Cards, Badges, Forms, Alerts, Sections
   ══════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: var(--navy);
    color: white;
}

    .btn-primary:hover {
        background: var(--navy-dark);
        transform: translateY(-1px);
        box-shadow: var(--shadow);
    }

.btn-gold {
    background: var(--gold);
    color: var(--navy);
}

    .btn-gold:hover {
        background: var(--gold-dark);
        transform: translateY(-1px);
    }

.btn-outline {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
}

    .btn-outline:hover {
        background: rgba(255,255,255,0.25);
        transform: translateY(-1px);
    }

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.825rem;
}

.btn-disabled, .btn:disabled {
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Section Layout ──────────────────────────────────────────────── */
.section {
    padding: 3.5rem 1.5rem;
}

.section-alt {
    background: white;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 1.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gold);
    display: inline-block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

    .page-header h1 {
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--navy);
        margin-bottom: 0.25rem;
    }

    .page-header p {
        color: var(--text-muted);
    }

/* ── Cards ───────────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-card);
}

    .card:hover {
        transform: translateY(-3px);
        border-color: var(--steel);
        box-shadow: 0 8px 24px rgba(26,50,99,0.15);
    }

.card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.card-img-placeholder {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: linear-gradient(135deg, #e8e2db, #d4cdc5);
}

.card-img-wrapper {
    position: relative;
}

.card-body {
    padding: 1.1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.4rem;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0.85rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Badges ──────────────────────────────────────────────────────── */
.version-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    background: rgba(26,50,99,0.08);
    color: var(--navy);
    border: 1px solid rgba(26,50,99,0.15);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.card-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.detail-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: white;
}

.badge-new {
    background: #EF4444;
}

.badge-update {
    background: #F59E0B;
}

.price-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 0.3rem;
}

.price-free {
    background: #d1fae5;
    color: #065f46;
}

.price-paid {
    background: #fef3c7;
    color: #92400e;
}

.price-display {
    margin: 0.5rem 0;
}

/* ── Program / Game Card ─────────────────────────────────────────── */
.program-card {
    position: relative;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
}

    .program-card:not(.program-card-disabled):hover {
        transform: translateY(-5px) scale(1.02);
        border-color: var(--steel);
        box-shadow: 0 14px 32px rgba(26,50,99,0.18);
    }

.program-card-disabled {
    cursor: not-allowed;
}

.program-card-img {
    height: 150px;          /* background / icon มาจาก inline style */
}

.program-card-body {
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.program-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.tag {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tag-free { background: #d1fae5; color: #065f46; }
.tag-type { background: rgba(26,50,99,0.08); color: var(--navy); }
.tag-soon { background: #e5e7eb; color: #6b7280; }

.program-card-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 0.35rem;
}

.program-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.program-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
}

.program-card-version {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── New badge (ใช้ซ้ำได้ — Nav, การ์ด ฯลฯ) ──────────────────────── */
.new-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.45rem;
    background: #EF4444;
    color: white;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.6;
    vertical-align: middle;
}

    /* แบบมุมการ์ด — ลอยมุมขวาบน + เด้งเรียกความสนใจ */
    .new-badge.corner {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        z-index: 2;
        font-size: 0.65rem;
        padding: 0.18rem 0.55rem;
        box-shadow: 0 2px 6px rgba(0,0,0,0.25);
        animation: pulse 1.8s ease-in-out infinite;
    }

/* ── Leaderboard tabs (สลับดูตารางอันดับทีละแบบ กันหน้ายาว) ── */
.lb-tabs {
    display: flex;
    gap: 0.35rem;
    background: #f1f5f9;
    padding: 0.3rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}
.lb-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.55rem 0.4rem;
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.lb-tab:hover { color: var(--navy); }
.lb-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(26, 50, 99, 0.12);
}

/* ── Gift badge (โทนทองเดียวกับแถบลุ้นรางวัลหัวตาราง) — ใช้บนปุ่มแท็บประจำเดือน ── */
.gift-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.6;
    vertical-align: middle;
    color: #9a6a00;
    background: linear-gradient(135deg, #fff7e0, #ffe6a0);
    border: 1px solid #f0d176;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(240, 209, 118, 0.4);
    animation: pulse 1.8s ease-in-out infinite;
}

.price-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--navy);
}

/* ── Form Controls (Shared) ──────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

    .form-group label {
        display: block;
        font-size: 0.82rem;
        color: var(--text-muted);
        margin-bottom: 0.4rem;
        font-weight: 500;
    }

.form-input,
.form-control {
    width: 100%;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    resize: vertical;
}

    .form-input:focus,
    .form-control:focus {
        outline: none;
        border-color: var(--steel);
        background: white;
        box-shadow: 0 0 0 3px rgba(84,119,146,0.12);
    }

    .form-control:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

    .alert i {
        margin-right: 0.25rem;
    }

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
}

/* ── Ad strip (แถบโฆษณาเลื่อนใต้ navbar) ──────────────────────────── */
.ad-strip {
    width: 100%;
    overflow: hidden;
    /* โทนเดียวกับ navbar (--navy) แต่อ่อนลง */
    background: rgba(26, 50, 99, 0.06);
    border-bottom: 1px solid rgba(26, 50, 99, 0.15);
}

.ad-track {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    width: max-content;
    padding: 0.6rem 1rem;
    animation-name: ad-scroll;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

/* หยุดเลื่อนเมื่อ hover (อ่าน/คลิกง่ายขึ้น) */
.ad-strip:hover .ad-track {
    animation-play-state: paused;
}

.ad-item {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
}

.ad-item img {
    height: 64px;
    width: auto;
    max-width: 380px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

/* เลื่อนซ้าย→ขวา · วนต่อเนื่องไม่สะดุด (track มีรายการซ้ำ 2 ชุด → ขยับ 50%) */
@keyframes ad-scroll {
    from { transform: translateX(-50%); }
    to   { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .ad-track { animation: none; }
}

/* ── Program cards (หน้า /programs) ───────────────────────────────── */
.program-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.program-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 6px rgba(26, 50, 99, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.program-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(26, 50, 99, 0.12);
}

.program-thumb {
    position: relative;
    width: 100%;
    border: none;
    padding: 0;
    cursor: zoom-in;
    background: #f1f5f9;
    line-height: 0;
}

.program-thumb img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.program-zoom-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.program-thumb:hover .program-zoom-hint { opacity: 1; }

.program-body {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.program-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
    margin: 0;
}

.program-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.program-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.6rem;
}

/* ── Lightbox ── */
.program-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    cursor: zoom-out;
    animation: fadeIn 0.15s ease;
}

.program-lightbox img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.program-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.program-lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

/* ── Popup ขอเข้าสู่ระบบก่อนดูรายละเอียดโปรแกรม ── */
.login-prompt-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem 1.75rem;
    max-width: 360px;
    width: 100%;
    text-align: center;
    cursor: default;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.15s ease;
}

/* ── Proposal status badges (หน้าเสนอคำ) ─────────────────────────── */
.prop-status {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.prop-pending { background: #fffbeb; color: #b45309; }
.prop-approved { background: #f0fdf4; color: #16a34a; }
.prop-rejected { background: #f1f5f9; color: #64748b; }

/* ── Notification bell (กระดิ่งแจ้งเตือน) ─────────────────────────── */
.notif-wrap { position: relative; display: inline-flex; align-items: center; }

.notif-bell {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1rem;
    padding: 0.4rem 0.5rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.notif-bell:hover { color: #fff; }

.notif-badge {
    position: absolute;
    top: -1px;
    right: -1px;
    background: #EF4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.notif-backdrop { position: fixed; inset: 0; z-index: 300; background: transparent; }

.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 330px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(26, 50, 99, 0.2);
    z-index: 301;
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--navy);
}
.notif-readall { background: none; border: none; color: var(--primary); font-size: 0.72rem; cursor: pointer; font-weight: 600; }
.notif-empty { padding: 1.5rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; }
.notif-list { overflow-y: auto; }

.notif-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-align: left;
    padding: 0.7rem 1rem;
    background: #fff;
    border: none;
    border-bottom: 1px solid #f0f4f8;
    cursor: pointer;
}
.notif-item:hover { background: #f8f9fa; }
.notif-item-unread { background: #f0f7ff; }
.notif-item-icon { color: var(--primary); font-size: 1rem; flex-shrink: 0; }
.notif-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.notif-item-title { font-size: 0.875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-date { font-size: 0.72rem; color: var(--text-muted); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: #EF4444; flex-shrink: 0; }

/* popup รายละเอียดเต็ม */
.notif-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}
.notif-modal {
    background: #fff;
    border-radius: 14px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    padding: 1.25rem;
}
.notif-modal-head { display: flex; align-items: center; justify-content: space-between; }
.notif-modal-cat { font-size: 0.78rem; font-weight: 600; color: var(--primary); background: #eef4fb; padding: 3px 10px; border-radius: 20px; }
.notif-modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.notif-modal-title { font-size: 1.15rem; font-weight: 800; color: var(--text); margin: 0.75rem 0 0.25rem; }
.notif-modal-date { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.notif-modal-body { font-size: 0.9rem; color: var(--text); line-height: 1.7; white-space: pre-wrap; }

/* ── Error / Success Messages ────────────────────────────────────── */
.error-msg {
    color: #DC2626;
    font-size: 0.825rem;
    margin-bottom: 0.75rem;
}

.success-msg {
    color: #16A34A;
    font-size: 0.825rem;
    margin-bottom: 0.75rem;
}

/* ── Review Stars ────────────────────────────────────────────────── */
.star-picker {
    display: flex;
    gap: 0.35rem;
}

.star {
    font-size: 1.6rem;
    color: var(--border);
    cursor: pointer;
    transition: var(--transition);
}

    .star.active, .star:hover {
        color: var(--gold);
    }
