/* Mosiang Online — ธีมกลาง (ดำ #0a0a0a / การ์ด #171717 / แดง #ef4444, #991b1b) */
:root {
    --bg: #0a0a0a;
    --card: #171717;
    --line: rgba(255, 255, 255, 0.08);
    --red: #ef4444;
    --red-dark: #991b1b;
    --text: #e5e7eb;
    --muted: #9ca3af;
}

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Kanit', 'Poppins', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* พื้นหลังภาพเกม (หน้าสมาชิก/login) */
.bg-game {
    background-image:
        radial-gradient(circle at 15% 20%, rgba(239, 68, 68, 0.10), transparent 35%),
        radial-gradient(circle at 85% 80%, rgba(153, 27, 27, 0.12), transparent 35%),
        linear-gradient(rgba(10, 10, 10, 0.82), rgba(10, 10, 10, 0.95)),
        url('../images/bg.jpg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}
@media (max-width: 768px) {
    /* iOS ไม่รองรับ fixed ดีนัก */
    .bg-game { background-attachment: scroll; }
}

::selection { background: var(--red); color: #fff; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- การ์ด ---------- */
.glass {
    background: rgba(23, 23, 23, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--line);
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
}
.panel {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 1rem;
}
.panel-soft {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.875rem;
}
.lift { transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease; }
.lift:hover {
    transform: translateY(-4px);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 20px 40px -12px rgba(239, 68, 68, 0.18);
}

.text-gradient {
    background: linear-gradient(135deg, #f87171, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- ปุ่ม ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 44px;
    padding: .7rem 1.4rem;
    border-radius: .75rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color .2s, border-color .2s, box-shadow .2s, transform .2s, color .2s;
    text-decoration: none;
    user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
    box-shadow: 0 10px 22px -12px rgba(239, 68, 68, .6);
}
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(239, 68, 68, .55); filter: brightness(1.08); }
.btn-ghost {
    background: var(--card);
    color: #f87171;
    border-color: rgba(153, 27, 27, .55);
}
.btn-ghost:hover { background: rgba(127, 29, 29, .3); border-color: rgba(239, 68, 68, .5); color: #fff; }
.btn-block { width: 100%; }

/* ---------- ฟอร์ม ---------- */
.field-label {
    display: block;
    margin-bottom: .5rem;
    font-size: .875rem;
    font-weight: 500;
    color: #d1d5db;
}
.input {
    width: 100%;
    min-height: 46px;
    padding: .7rem 1rem;
    background: rgba(10, 10, 10, .85);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: .75rem;
    color: #f3f4f6;
    font-size: 1rem; /* 16px กัน iOS zoom */
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
    outline: none;
}
.input::placeholder { color: #6b7280; }
.input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(239, 68, 68, .15); background: var(--bg); }
.input[readonly], .input:disabled { color: #6b7280; cursor: not-allowed; background: rgba(10, 10, 10, .5); }
select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.75rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}
select.input option { background: var(--bg); color: #e5e7eb; }
.input-icon { position: relative; }
.input-icon > i {
    position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
    color: var(--muted); pointer-events: none; font-size: 1.1rem;
}
.input-icon > .input { padding-left: 2.75rem; }

/* ---------- แจ้งเตือน ---------- */
.note {
    border-left: 4px solid var(--red);
    background: rgba(69, 10, 10, .35);
    color: #f87171;
    border-radius: 0 .6rem .6rem 0;
    padding: .8rem 1rem;
    font-size: .9rem;
}
.note-success { border-left-color: #22c55e; background: rgba(5, 46, 22, .4); color: #4ade80; }

/* ---------- ตาราง ---------- */
.table-wrap {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: 1rem; border: 1px solid var(--line);
    background: rgba(10, 10, 10, .55);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.table th {
    background: linear-gradient(180deg, #1a1a1a, #141414);
    color: var(--muted); font-weight: 500; font-size: .78rem; letter-spacing: .02em;
    padding: .6rem .9rem; text-align: left; white-space: nowrap;
    border-bottom: 1px solid rgba(239, 68, 68, .28);
}
.table td { padding: .55rem .9rem; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, .05); vertical-align: middle; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .015); }
.table tbody tr:hover { background: rgba(239, 68, 68, .05); }
.table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .cell-sub { font-size: .75rem; color: #6b7280; margin-left: .4rem; }

/* ป้ายสถานะ */
.badge {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .1rem .55rem; border-radius: 999px;
    font-size: .72rem; font-weight: 500; white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: #4ade80; background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .25); }
.badge-danger { color: #f87171; background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .25); }
.badge-muted { color: #d1d5db; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); }
.badge-muted::before { display: none; }

/* มือถือ: แต่ละแถวเป็นการ์ด (ใส่ .table-stack + data-label ที่ td) */
@media (max-width: 640px) {
    .table-wrap:has(.table-stack) { border: 0; background: transparent; overflow: visible; }
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-stack, .table-stack tbody { display: block; }
    .table-stack tbody tr {
        display: block; margin-bottom: .5rem; padding: .25rem 0;
        background: var(--card) !important; border: 1px solid var(--line); border-radius: .9rem;
    }
    .table-stack tbody tr:hover td:first-child { box-shadow: none; }
    .table-stack tbody td {
        display: flex; align-items: center; justify-content: space-between; gap: 1rem;
        padding: .5rem 1rem !important; border: 0 !important; text-align: right !important;
        background: transparent !important;
    }
    .table-stack tbody td::before { content: attr(data-label); color: #6b7280; font-size: .75rem; text-align: left; flex-shrink: 0; }
    .table-stack tbody td { padding: .28rem .9rem !important; }
    .table-stack tbody td:first-child { border-bottom: 1px solid var(--line) !important; padding-bottom: .45rem !important; margin-bottom: .2rem; }
    table.dataTable.table-stack tbody tr > td.sorting_1 { background: transparent !important; }
    table.dataTable.table-stack tbody tr, table.dataTable.table-stack tbody tr.even, table.dataTable.table-stack tbody tr:hover { background: var(--card) !important; }
    .table-stack tbody tr:hover { border-color: rgba(239, 68, 68, .35); }
    .table-stack tbody td.stack-hide { display: none; }
    .table-stack tbody td.dataTables_empty { justify-content: center; }
    .table-stack tbody td.dataTables_empty::before { display: none; }
    .table-stack .cell-sub { display: inline; margin: 0 0 0 .4rem; }
}

/* ---------- แถบนำทางสมาชิก ---------- */
.member-nav {
    position: sticky; top: 0; z-index: 40;
    background: rgba(10, 10, 10, .82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.nav-link {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .55rem .9rem; border-radius: .65rem;
    color: #d1d5db; font-weight: 500; white-space: nowrap;
    transition: background-color .2s, color .2s;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-link.is-active { background: rgba(127, 29, 29, .35); color: #fff; box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .35); }
.nav-link.is-active i { color: var(--red); }
/* แถบล่างมือถือ */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: rgba(10, 10, 10, .92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 58px; font-size: .72rem; color: var(--muted);
}
.tabbar a i { font-size: 1.15rem; }
.tabbar a.is-active { color: #fff; }
.tabbar a.is-active i { color: var(--red); }
@media (min-width: 768px) { .tabbar { display: none; } }
@media (max-width: 767px) { .has-tabbar { padding-bottom: calc(70px + env(safe-area-inset-bottom)); } }

/* ---------- DataTables ธีมมืด ---------- */
.dataTables_wrapper { color: #d1d5db; font-family: inherit; }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--muted) !important; padding-top: .6rem; font-size: .8rem; }
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--bg); color: #e5e7eb; border: 1px solid rgba(255, 255, 255, .12);
    border-radius: .5rem; padding: .35rem .6rem; margin: 0 .35rem;
}
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--red); outline: none; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #d1d5db !important; border: 1px solid transparent !important; border-radius: .5rem !important; background: transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: rgba(127, 29, 29, .35) !important; color: #fff !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--red) !important; color: #fff !important; border-color: var(--red) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover { color: #4b5563 !important; background: transparent !important; }
table.dataTable { border-collapse: separate !important; }
table.dataTable thead th, table.dataTable thead td { border-bottom: 1px solid rgba(239, 68, 68, .28) !important; }
table.dataTable.no-footer { border-bottom: 0 !important; }
table.dataTable tbody tr { background: transparent !important; }
table.dataTable tbody tr.even { background: rgba(255, 255, 255, .015) !important; }
table.dataTable tbody tr:hover { background: rgba(239, 68, 68, .05) !important; }
table.dataTable thead th, table.dataTable tbody td { padding: .55rem .9rem !important; }
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc {
    padding-right: 1.6rem !important; background-color: #171717; background-repeat: no-repeat !important; background-position: right .7rem center !important;
}
table.dataTable thead .sorting { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='12' viewBox='0 0 10 12'%3E%3Cpath d='M1 5h8L5 1zM1 7h8l-4 4z' fill='%234b5563'/%3E%3C/svg%3E") !important; }
table.dataTable thead .sorting_desc { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='12' viewBox='0 0 10 12'%3E%3Cpath d='M1 5h8L5 1z' fill='%234b5563'/%3E%3Cpath d='M1 7h8l-4 4z' fill='%23ef4444'/%3E%3C/svg%3E") !important; color: #f3f4f6; }
table.dataTable thead .sorting_asc { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='12' viewBox='0 0 10 12'%3E%3Cpath d='M1 5h8L5 1z' fill='%23ef4444'/%3E%3Cpath d='M1 7h8l-4 4z' fill='%234b5563'/%3E%3C/svg%3E") !important; color: #f3f4f6; }
/* คอลัมน์ที่กำลังเรียง: DataTables ใส่พื้นขาว (#f1f1f1) ให้เป็นธีมมืด */
table.dataTable tbody td.sorting_1,
table.dataTable tbody td.sorting_2,
table.dataTable tbody td.sorting_3,
table.dataTable.display tbody tr > .sorting_1,
table.dataTable.display tbody tr.odd > .sorting_1,
table.dataTable.display tbody tr.even > .sorting_1,
table.dataTable.order-column tbody tr > .sorting_1 { background-color: rgba(239, 68, 68, .04) !important; }
table.dataTable tbody td { white-space: nowrap; }
@media (max-width: 640px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { float: none !important; text-align: center !important; }
    .dataTables_wrapper .dataTables_filter input { width: 60%; }
}

/* ---------- SweetAlert2 ธีมมืด ---------- */
.swal2-popup { background: var(--card) !important; color: #e5e7eb !important; border: 1px solid var(--line); border-radius: 1rem !important; font-family: 'Kanit', sans-serif !important; }
.swal2-title, .swal2-html-container { color: #e5e7eb !important; }
.swal2-styled.swal2-confirm { background: linear-gradient(135deg, var(--red), var(--red-dark)) !important; border-radius: .65rem !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
