/* ============================================
   Widi Games - Stylesheet utama
   Tema gelap, mobile-first, terinspirasi layout
   portal game modern (baris horizontal scroll).
   ============================================ */

:root {
    --bg: #0b0b14;
    --bg-elevated: #12121e;
    --card: #161624;
    --card-hover: #1e1e30;
    --accent: #7c3aed;
    --accent-2: #a78bfa;
    --text: #f1f1f6;
    --muted: #9a9ab0;
    --border: #24243a;
    --success: #4ade80;
    --danger: #f87171;
    --radius: 14px;
    --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: #2c2c44; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============ HEADER ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    background: rgba(11, 11, 20, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 20px;
    min-width: 0;
    flex-shrink: 1;
}

.brand img { height: 34px; width: 34px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.brand span.tag { color: var(--accent-2); }
.brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.search-form {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-form input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 14px;
}

.search-form input:focus { outline: none; border-color: var(--accent); }

.search-form .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-admin {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
.btn-admin:hover { background: #6d28d9; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}

.mobile-search {
    display: none;
}

@media (max-width: 480px) {
    .brand { font-size: 16px; gap: 7px; }
    .brand img { height: 28px; width: 28px; }
    .btn-admin { padding: 7px 12px; font-size: 12px; }
}

@media (max-width: 720px) {
    .search-form { display: none; }
    .hamburger { display: block; }
    .mobile-search {
        display: block;
        padding: 10px 16px 14px;
        border-bottom: 1px solid var(--border);
        background: var(--bg-elevated);
    }
    .mobile-search .search-form { display: block; max-width: none; }
}

/* ============ HERO / BANNER ============ */
.hero {
    margin: 20px 0 8px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
    padding: 28px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    overflow: hidden;
    position: relative;
}
.hero h1 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0; color: rgba(255,255,255,.85); font-size: 14px; }
.hero .emoji { font-size: 52px; opacity: .9; }

@media (max-width: 600px) {
    .hero { padding: 20px; }
    .hero h1 { font-size: 19px; }
    .hero p { font-size: 13px; }
    .hero .emoji { font-size: 38px; }
}

/* ============ SECTIONS ============ */
.section {
    margin: 32px 0;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.section-head h2 {
    font-size: 19px;
    margin: 0;
    font-weight: 800;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-head a.show-all {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .section-head h2 { font-size: 16px; }
}
.section-head a.show-all:hover { color: var(--accent-2); }

/* Row: horizontal scroll ala referensi */
.game-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.game-row .game-card { scroll-snap-align: start; flex: 0 0 auto; }

/* Grid: untuk halaman "semua game" */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

/* ============ GAME CARD ============ */
.game-card {
    width: 168px;
}

.game-card .thumb-wrap {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    background: var(--card);
    border: 1px solid var(--border);
    transition: transform .15s ease, box-shadow .15s ease;
}

.game-card:hover .thumb-wrap {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, .25);
    border-color: var(--accent);
}

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

.game-card .play-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.game-card .badge-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.game-card .title {
    margin-top: 8px;
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card .dev {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card .dev .dot {
    width: 14px; height: 14px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .game-card { width: 128px; }
    .game-card .title { font-size: 12.5px; }
    .game-card .dev { font-size: 11px; }
}

/* Categories chips */
.chip-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 14px;
}
.chip {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}
.chip.active, .chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============ GAME PLAYER PAGE ============ */
.player-wrap {
    max-width: 900px;
    margin: 16px auto;
    padding: 0 16px;
}

.player-frame-outer {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

/* Default: portrait phone-like ratio */
.player-frame-outer.orientation-portrait {
    aspect-ratio: 9 / 16;
    max-width: 420px;
}
.player-frame-outer.orientation-landscape {
    aspect-ratio: 16 / 9;
    max-width: 900px;
}

.player-frame-outer iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

.player-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0;
    gap: 10px;
}

.player-toolbar .btn {
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex: 0 0 auto;
}
.player-toolbar .btn:hover { border-color: var(--accent); }
.player-toolbar .btn.primary { background: var(--accent); border-color: var(--accent); }

@media (max-width: 380px) {
    .player-toolbar .btn { padding: 9px 12px; font-size: 12px; }
}

.game-meta h1 { font-size: 20px; margin: 18px 0 6px; }
.game-meta .stats { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.game-meta .desc { color: #cfcfe0; font-size: 14px; line-height: 1.7; }

.player-frame-outer:fullscreen { max-width: none; aspect-ratio: auto; border-radius: 0; }
.player-frame-outer:fullscreen iframe { width: 100vw; height: 100vh; }

/* ============ FOOTER ============ */
.site-footer {
    margin-top: 60px;
    border-top: 1px solid var(--border);
    padding: 28px 0 40px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.site-footer a { color: var(--accent-2); }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state .icon { font-size: 44px; margin-bottom: 12px; }

/* ============ MOBILE MENU ============ */
.mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,.6);
}
.mobile-menu.open { display: block; }
.mobile-menu .panel {
    position: absolute;
    top: 0; right: 0;
    width: 78%;
    max-width: 300px;
    height: 100%;
    background: var(--bg-elevated);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-menu .panel a, .mobile-menu .panel button {
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    padding: 12px 8px;
    border-radius: 8px;
}
.mobile-menu .panel a:hover, .mobile-menu .panel button:hover { background: var(--card); }
.mobile-menu .close-btn { align-self: flex-end; font-size: 22px; background: none; border: none; color: var(--text); margin-bottom: 10px; }

/* ============ ADMIN SHARED ============ */
.admin-body { background: var(--bg); color: var(--text); min-height: 100vh; }
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.admin-sidebar .brand { padding: 0 8px 20px; font-size: 18px; }
.admin-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
}
.admin-sidebar nav a:hover { background: var(--card); color: var(--text); }
.admin-sidebar nav a.active { background: var(--accent); color: #fff; }
.admin-main { flex: 1; padding: 24px 28px; min-width: 0; }

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.admin-topbar h1 { font-size: 22px; margin: 0; }

@media (max-width: 480px) {
    .admin-topbar h1 { font-size: 18px; }
    .admin-topbar > div:last-child { font-size: 12px; }
}

.card-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=file],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #1c1c2e;
    color: var(--text);
    font-size: 14px;
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

.btn-main {
    padding: 11px 22px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}
.btn-main:hover { background: #6d28d9; }
.btn-ghost {
    padding: 11px 22px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.btn-danger { background: var(--danger); color: #fff; border: none; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: rgba(74,222,128,.12); color: var(--success); border: 1px solid rgba(74,222,128,.3); }
.alert-error { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}
table.admin-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
table.admin-table img.thumb-sm { width: 46px; height: 60px; object-fit: cover; border-radius: 6px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge.active { background: rgba(74,222,128,.15); color: var(--success); }
.badge.inactive { background: rgba(248,113,113,.15); color: var(--danger); }
.badge.pending { background: rgba(251,191,36,.18); color: #fbbf24; }
.badge.flag { background: rgba(124,58,237,.2); color: var(--accent-2); margin-left: 4px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 34px; max-width: 380px; width: 100%; }
.login-box h1 { text-align: center; font-size: 20px; margin: 6px 0 22px; }
.login-box .logo { text-align: center; font-size: 36px; margin-bottom: 4px; }

.mobile-hamburger-admin { display: none; }
@media (max-width: 900px) {
    .admin-sidebar { position: fixed; left: -240px; z-index: 300; transition: left .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.5); }
    .admin-sidebar.open { left: 0; }
    .admin-main { padding: 16px; }
    .mobile-hamburger-admin { display: inline-flex; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 8px; font-size: 18px; cursor: pointer; }
    .admin-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 250; }
    .admin-overlay.open { display: block; }
    table.admin-table { display: block; overflow-x: auto; white-space: nowrap; }
}
