@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800;900&family=Chakra+Petch:ital,wght@0,500;0,600;0,700;1,600&display=swap');

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

:root {
    --bg-page:      #dfe3e8;
    --bg-section:   #ffffff;
    --navy:         #1e3a8a;
    --navy-dark:    #1a3070;
    --navy-light:   #eff6ff;
    --green-dark:   #155c2c;
    --green-mid:    #1e7e3e;
    --green-card1:  #1f8c42;
    --green-card2:  #145928;
    --green-shine:  #2db356;
    --green-accent: #3ef07a;
    --text-primary: #1c2230;
    --text-secondary:#4a5568;
    --text-muted:   #8a94a6;
    --border:       #c8d0dc;
    --radius-card:  18px;
}

body {
    font-family: 'Noto Sans Thai', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ── Top Nav ── */
.topnav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(0,0,0,0.07);
}
.topnav .logo {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--navy);
    letter-spacing: -0.5px;
    flex-shrink: 0;
    margin-right: 8px;
}
.topnav .logo span { color: var(--green-shine); }
.topnav nav {
    display: flex;
    gap: 2px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.topnav nav a {
    padding: 6px 14px; border-radius: 8px;
    text-decoration: none; font-size: 0.84rem; font-weight: 600;
    color: var(--text-secondary); transition: all 0.15s;
    white-space: nowrap;
}
.topnav nav a:hover { background: var(--navy-light); color: var(--navy); }
.topnav nav a.active { background: var(--navy); color: #fff; }

/* ── User chip ── */
.topnav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.user-chip-wrap {
    position: relative;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    border: 1.5px solid var(--border);
    border-radius: 99px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.15s;
    user-select: none;
}
.user-chip:hover { border-color: #a5b4d0; }
.user-chip.open { border-color: #a5b4d0; background: #f1f5f9; }
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 0;
    width: max-content;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    z-index: 999;
    overflow: hidden;
    animation: dropIn 0.12s ease;
}
.user-dropdown.open { display: block; }
@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #ef4444;
    text-decoration: none;
    font-family: 'Noto Sans Thai', sans-serif;
    transition: background 0.12s;
    white-space: nowrap;
}
.user-dropdown a:hover { background: #fef2f2; }
.user-dropdown a.dropdown-admin { color: var(--navy); border-bottom: 1px solid #f1f5f9; }
.user-dropdown a.dropdown-admin:hover { background: var(--navy-light); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}
.user-avatar.role-admin  { background: linear-gradient(135deg,#1e3a8a,#2563eb); }
.user-avatar.role-agent  { background: linear-gradient(135deg,#5b21b6,#7c3aed); }
.user-avatar.role-user   { background: linear-gradient(135deg,#155c2c,#1e7e3e); }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-info-name {
    font-size: 0.78rem; font-weight: 700;
    color: var(--text-primary);
    max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-info-role {
    font-size: 0.62rem; font-weight: 600;
    color: var(--text-muted);
}
.btn-logout { display: none; }

/* ── Layout ── */
.page-wrapper {
    max-width: 1380px; margin: 0 auto;
    padding: 24px 20px 60px;
    display: flex; flex-direction: column; gap: 16px;
}

/* ── Section Block ── */
.section-block {
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.section-header {
    display: flex; align-items: center; gap: 10px;
    padding: 15px 22px; cursor: pointer; user-select: none;
    background: #fff; border-bottom: 1px solid transparent;
    transition: background 0.15s;
}
.section-header:hover { background: #f8fafb; }
.section-header.open { border-bottom-color: var(--border); }
.section-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.section-count {
    font-size: 0.75rem; font-weight: 700;
    background: var(--navy); color: #fff;
    padding: 2px 9px; border-radius: 20px;
}
.chevron {
    margin-left: auto; width: 18px; height: 18px;
    color: var(--text-muted); transition: transform 0.25s;
}
.section-header.open .chevron { transform: rotate(180deg); }
.section-body { padding: 18px 18px 22px; }

/* ── Cards Grid ── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 12px;
}

/* ════════════════════════════════
   LOTTERY CARD
   ════════════════════════════════ */
.lottery-card {
    border-radius: var(--radius-card);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(.22,.68,0,1.3), box-shadow 0.2s;
    box-shadow:
        0 4px 16px rgba(0,0,0,0.22),
        inset 0 1px 0 rgba(255,255,255,0.18);
    display: flex;
    flex-direction: column;
}
.lottery-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 14px 36px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.22);
}
.lottery-card:active { transform: translateY(-2px) scale(1.005); }

/* ── Green card ── */
.lottery-card.green {
    background: linear-gradient(145deg, #1fd66a 0%, #12a34a 35%, #0b7535 65%, #064a20 100%);
    border: 1px solid rgba(80,230,130,0.40);
    box-shadow:
        0 8px 32px rgba(0,80,30,0.45),
        inset 0 1px 0 rgba(255,255,255,0.40),
        inset 0 -1px 0 rgba(0,0,0,0.25);
}
.lottery-card.green::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.05) 45%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.lottery-card.green::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 70%; height: 60%;
    background: radial-gradient(ellipse at bottom right, rgba(0,0,0,0.25) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.lottery-card.green > * { position: relative; z-index: 1; }
.lottery-card.green:hover {
    background: linear-gradient(145deg, #28e877 0%, #16b854 35%, #0d8840 65%, #075a28 100%);
    box-shadow: 0 16px 40px rgba(0,80,30,0.55), inset 0 1px 0 rgba(255,255,255,0.45), inset 0 -1px 0 rgba(0,0,0,0.28);
}

/* ── Dark/closed card ── */
.lottery-card.dark {
    background:
        linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 40%),
        linear-gradient(200deg, #5a6075 0%, #3c4155 40%, #252a38 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow:
        0 6px 24px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.10);
    opacity: 0.82;
}

/* ── Card top section ── */
.card-top {
    padding: 14px 14px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    position: relative;
}

.lottery-card.green::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 60%; height: 55%;
    background: radial-gradient(ellipse at bottom right, rgba(0,0,0,0.22) 0%, transparent 70%);
    pointer-events: none;
}

.card-name {
    font-size: 0.97rem;
    font-weight: 800;
    line-height: 1.3;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
    flex: 1;
}

.flag-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.flag-img {
    width: 44px; height: 30px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.45), 0 0 0 1.5px rgba(255,255,255,0.25);
}
.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    height: 22px;
    border-radius: 5px;
    padding: 0 7px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    white-space: nowrap;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    position: relative;
    overflow: hidden;
}
.icon-badge::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: rgba(255,255,255,0.18);
    border-radius: 5px 5px 0 0;
}
.badge-extra   { background: linear-gradient(135deg,#f59e0b,#c07a00); color:#fff8e0; }
.badge-tv      { background: linear-gradient(135deg,#4f9ef8,#1a5fcb); color:#e0eeff; }
.badge-hd      { background: linear-gradient(135deg,#a875f5,#6d28d9); color:#f0e8ff; }
.badge-star    { background: linear-gradient(135deg,#f56565,#991b1b); color:#ffe8e8; }
.badge-starvip { background: linear-gradient(135deg,#92651a,#4a2f00); color:#ffe28a; border:1px solid rgba(255,220,100,0.5); }
.badge-asean   { background: linear-gradient(135deg,#34b88a,#065f46); color:#d1fae5; }
.badge-kachat  { background: linear-gradient(135deg,#f05555,#7f1d1d); color:#fff; }
.badge-unity   { background: linear-gradient(135deg,#5b6de8,#312e81); color:#e0e7ff; }
.badge-phatna  { background: linear-gradient(135deg,#3ecf6a,#14532d); color:#dcfce7; }
.badge-jones   { background: linear-gradient(135deg,#64748b,#1e293b); color:#e2e8f0; }
.badge-thai    { background: linear-gradient(135deg,#ef4444,#2563eb); color:#fff; }
.badge-default { background: linear-gradient(135deg,#64748b,#334155); color:#e2e8f0; }

.card-divider {
    height: 1px;
    margin: 0 14px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2) 30%, rgba(255,255,255,0.2) 70%, transparent);
}

.card-bottom {
    padding: 10px 14px 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.67rem;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.18);
    padding: 3px 8px;
    border-radius: 20px;
}
.card-date-chip svg { width: 9px; height: 9px; flex-shrink: 0; }

.card-closetime {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.closetime-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.closetime-value {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.countdown-strip {
    margin-top: 4px;
    border-radius: 10px;
    padding: 8px 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(255,255,255,0.14);
    backdrop-filter: blur(4px);
}
.countdown-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #7fffb4;
    box-shadow: 0 0 0 3px rgba(127,255,180,0.30);
    animation: pulse-ring 1.5s ease-in-out infinite;
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(127,255,180,0.55); }
    70%  { box-shadow: 0 0 0 6px rgba(127,255,180,0); }
    100% { box-shadow: 0 0 0 0 rgba(127,255,180,0); }
}
.countdown-label {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.65);
}
.countdown-value {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #7fffb4;
    letter-spacing: 1.5px;
    text-shadow: 0 0 12px rgba(127,255,180,0.45);
}

.lottery-card.dark .countdown-strip {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}
.lottery-card.dark .live-dot { display: none; }
.lottery-card.dark .countdown-label { color: rgba(255,255,255,0.4); }
.lottery-card.dark .countdown-value { color: rgba(255,255,255,0.6); text-shadow: none; letter-spacing: 1px; }

.closed-strip {
    margin-top: 4px;
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.1);
}
.closed-strip .lock-icon { font-size: 0.8rem; opacity: 0.7; }
.closed-strip-text {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.5px;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.lottery-card { animation: card-in 0.32s ease both; }
.cards-grid .lottery-card:nth-child(1)  { animation-delay: 0.03s; }
.cards-grid .lottery-card:nth-child(2)  { animation-delay: 0.06s; }
.cards-grid .lottery-card:nth-child(3)  { animation-delay: 0.09s; }
.cards-grid .lottery-card:nth-child(4)  { animation-delay: 0.12s; }
.cards-grid .lottery-card:nth-child(5)  { animation-delay: 0.15s; }
.cards-grid .lottery-card:nth-child(n+6){ animation-delay: 0.18s; }

.section-body[hidden] { display: none; }

@media (max-width: 640px) {
    .cards-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .page-wrapper { padding: 12px 12px 80px; }
    .topnav nav { display: none; }
}

/* ══════════════════════════════════
   MOBILE BOTTOM NAV BAR
   ══════════════════════════════════ */
.bottom-nav { display: none; }

@media (max-width: 640px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 62px;
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.10);
        z-index: 200;
        align-items: stretch;
    }
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 600;
        transition: color 0.15s, background 0.15s;
        padding: 6px 0;
    }
    .bottom-nav a:hover,
    .bottom-nav a.active {
        color: var(--navy);
        background: var(--navy-light);
    }
    .bottom-nav a svg {
        width: 22px; height: 22px;
        stroke: currentColor;
        transition: stroke 0.15s;
    }
}

/* ══════════════════════════════════════════════
   CUSTOM COLOR CARD — base layer
   ══════════════════════════════════════════════ */
.lottery-card.custom-color {
    color: #fff;
    box-shadow:
        0 6px 24px rgba(0,0,0,0.32),
        inset 0 1px 0 rgba(255,255,255,0.22),
        inset 0 -1px 0 rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.15);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* Shine sweep overlay */
.lottery-card.custom-color::before {
    content: '';
    position: absolute; inset: 0; border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(255,255,255,0.28) 0%,
        rgba(255,255,255,0.08) 35%,
        transparent 55%,
        rgba(0,0,0,0.08) 100%
    );
    pointer-events: none; z-index: 1;
}

/* Vignette bottom-right */
.lottery-card.custom-color::after {
    content: '';
    position: absolute;
    bottom: -10%; right: -5%;
    width: 65%; height: 65%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.28) 0%, transparent 70%);
    pointer-events: none; z-index: 1;
}

.lottery-card.custom-color > * { position: relative; z-index: 2; }

.lottery-card.custom-color:hover {
    filter: brightness(1.1) saturate(1.08);
    transform: translateY(-5px) scale(1.02);
    box-shadow:
        0 16px 40px rgba(0,0,0,0.38),
        inset 0 1px 0 rgba(255,255,255,0.28);
}

/* ── SHIMMER effect — disabled ── */
.lottery-card.custom-color .card-shimmer {
    display: none;
}

/* ── GLOW ring on hover per-theme ── */
.lottery-card.cc-blue:hover      { box-shadow: 0 12px 36px rgba(30,111,207,0.55), 0 0 0 2px rgba(30,111,207,0.35); }
.lottery-card.cc-purple:hover    { box-shadow: 0 12px 36px rgba(124,58,237,0.55), 0 0 0 2px rgba(124,58,237,0.35); }
.lottery-card.cc-red:hover       { box-shadow: 0 12px 36px rgba(220,38,38,0.55),  0 0 0 2px rgba(220,38,38,0.35); }
.lottery-card.cc-gold:hover      { box-shadow: 0 12px 36px rgba(217,119,6,0.55),  0 0 0 2px rgba(217,119,6,0.35); }
.lottery-card.cc-cyan:hover      { box-shadow: 0 12px 36px rgba(8,145,178,0.55),  0 0 0 2px rgba(8,145,178,0.35); }
.lottery-card.cc-orange:hover    { box-shadow: 0 12px 36px rgba(234,88,12,0.55),  0 0 0 2px rgba(234,88,12,0.35); }
.lottery-card.cc-pink:hover      { box-shadow: 0 12px 36px rgba(219,39,119,0.55), 0 0 0 2px rgba(219,39,119,0.35); }
.lottery-card.cc-teal:hover      { box-shadow: 0 12px 36px rgba(15,118,110,0.55), 0 0 0 2px rgba(15,118,110,0.35); }
.lottery-card.cc-rose:hover      { box-shadow: 0 12px 36px rgba(244,63,94,0.55),  0 0 0 2px rgba(244,63,94,0.35); }
.lottery-card.cc-indigo:hover    { box-shadow: 0 12px 36px rgba(99,102,241,0.55), 0 0 0 2px rgba(99,102,241,0.35); }
.lottery-card.cc-emerald:hover   { box-shadow: 0 12px 36px rgba(16,185,129,0.55), 0 0 0 2px rgba(16,185,129,0.35); }
.lottery-card.cc-amber:hover     { box-shadow: 0 12px 36px rgba(245,158,11,0.55), 0 0 0 2px rgba(245,158,11,0.35); }
.lottery-card.cc-midnight:hover  { box-shadow: 0 12px 36px rgba(30,41,59,0.85),   0 0 0 2px rgba(100,116,139,0.4); }
.lottery-card.cc-sunset:hover    { box-shadow: 0 12px 36px rgba(251,113,33,0.55), 0 0 0 2px rgba(251,113,33,0.35); }
.lottery-card.cc-ocean:hover     { box-shadow: 0 12px 36px rgba(14,165,233,0.55), 0 0 0 2px rgba(14,165,233,0.35); }
.lottery-card.cc-neon:hover      { box-shadow: 0 12px 36px rgba(16,185,129,0.7),  0 0 0 2px rgba(16,185,129,0.5); }

/* ── NEON countdown glow ── */
.lottery-card.cc-neon .countdown-value {
    color: #39ff8f;
    text-shadow: 0 0 8px #39ff8f, 0 0 20px rgba(57,255,143,0.5);
}
.lottery-card.cc-neon .live-dot {
    background: #39ff8f;
    box-shadow: 0 0 0 3px rgba(57,255,143,0.4), 0 0 12px rgba(57,255,143,0.6);
}

/* ── MIDNIGHT dark border accent ── */
.lottery-card.cc-midnight {
    border-color: rgba(148,163,184,0.2);
}
.lottery-card.cc-midnight .countdown-value { color: #94a3b8; text-shadow: none; }

/* ── SUNSET animated gradient ── */
@keyframes sunset-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.lottery-card.cc-sunset {
    background-size: 200% 200% !important;
    animation: card-in 0.32s ease both, sunset-shift 6s ease infinite;
}
