/**
 * BioEngine Shared Components
 * Reusable card, table, panel, and stat styles for all layouts.
 * Import AFTER module-theme.css or bioengine-style.css for theming variables.
 */

/* ===== Data Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255,255,255,0.03);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255,226,138,0.08);
}

.data-table thead th {
    background: rgba(255,226,138,0.06);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-gold, #ffe28a);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(255,226,138,0.1);
}

.data-table tbody td {
    padding: 10px 16px;
    font-size: 13px;
    border-top: 1px solid rgba(255,255,255,0.04);
    color: rgba(255,255,255,.75);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: rgba(96,165,250,0.04);
}

.data-table tbody tr:first-child td {
    border-top: none;
}

/* Sortable headers */
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: #fff; }
.data-table th[data-sort]::after { content: ' ↕'; opacity: .3; }
.data-table th[data-sort].asc::after  { content: ' ↑'; opacity: 1; }
.data-table th[data-sort].desc::after { content: ' ↓'; opacity: 1; }

/* Striped variant */
.data-table.striped tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.02);
}

/* Compact variant */
.data-table.compact td,
.data-table.compact th {
    padding: 8px 12px;
    font-size: 12px;
}


/* ===== Stat Cards ===== */
.stat-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 22px;
    border: 1px solid rgba(255,226,138,0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-gold, #ffe28a), var(--accent-blue, #60a5fa));
    opacity: 0;
    transition: opacity .3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: rgba(96,165,250,0.3);
}

.stat-card:hover::before { opacity: 1; }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255,226,138,0.08);
    border: 1px solid rgba(255,226,138,0.15);
    margin-bottom: 14px;
}

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    font-size: 12px;
    color: rgba(255,226,138,0.6);
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 600;
}

.stat-card .stat-change {
    font-size: 12px;
    margin-top: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.stat-change.positive { background: rgba(52,211,153,.15); color: #34d399; }
.stat-change.negative { background: rgba(248,113,113,.15); color: #f87171; }
.stat-change.neutral  { background: rgba(156,163,175,.12); color: #9ca3af; }


/* ===== Panels ===== */
.panel {
    background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,226,138,0.1);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 24px;
    transition: border-color .3s ease;
}

.panel:hover {
    border-color: rgba(255,226,138,0.2);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-gold, #ffe28a);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title .material-icons { font-size: 22px; opacity: .7; }

.panel-actions {
    display: flex;
    gap: 8px;
}

.panel-body {
    color: rgba(255,255,255,.8);
}


/* ===== Status Badges ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.ok,
.status-badge.success,
.status-badge.online  { background: rgba(16,185,129,.15); color: #34d399; }
.status-badge.warning  { background: rgba(245,158,11,.15); color: #fbbf24; }
.status-badge.error,
.status-badge.danger,
.status-badge.offline  { background: rgba(239,68,68,.15);  color: #f87171; }
.status-badge.info     { background: rgba(96,165,250,.15);  color: #60a5fa; }


/* ===== Status Dots ===== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.ok,
.status-dot.online  { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,.5); }
.status-dot.warning  { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,.5); }
.status-dot.error,
.status-dot.offline  { background: #f87171; box-shadow: 0 0 6px rgba(248,113,113,.5); }


/* ===== Grid Layouts ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}


/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: rgba(255,255,255,.4);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: .5;
}

.empty-state h3 {
    font-size: 18px;
    color: rgba(255,255,255,.6);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}


/* ===== Toast Notification Overrides ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,.4);
    animation: toastSlideIn .3s ease-out;
    backdrop-filter: blur(8px);
}

.toast-success { background: rgba(16,185,129,.92); }
.toast-error   { background: rgba(239,68,68,.92); }
.toast-warning { background: rgba(245,158,11,.92); }
.toast-info    { background: rgba(59,130,246,.92); }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}


/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.03); border-radius: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,226,138,.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,226,138,.25); }


/* ===== Responsive ===== */
@media (max-width: 640px) {
    .stats-grid,
    .cards-grid,
    .actions-grid {
        grid-template-columns: 1fr;
    }
    
    .panel { padding: 16px; }
    
    .data-table { font-size: 12px; }
    .data-table td, .data-table th { padding: 8px 10px; }
}

/* ===== Game Header Styles (for standalone Twig pages) ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-h, 56px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: linear-gradient(180deg, rgba(10,22,40,.95), rgba(10,22,40,.75));
    backdrop-filter: blur(14px) saturate(180%);
    border-bottom: 1px solid var(--tw-border, #33363c);
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

.h-left, .h-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.h-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 0 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.h-stats::-webkit-scrollbar { display: none; }

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a6f, #0e2441);
    border: 1px solid var(--tw-border, #33363c);
    box-shadow: 0 0 8px rgba(59,130,246,.15);
    font-weight: 700;
    flex: 0 0 auto;
    color: var(--tw-txt, #eee3b2);
}

.user-meta { line-height: 1.1; min-width: 0; max-width: 150px; }
.username { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.level { font-size: 11px; color: var(--tw-txt-muted, #888); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Squircle stat rings */
.stat-rings { display: flex; gap: 8px; }
.ring {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: conic-gradient(var(--ring-color, var(--tw-accent, #53e68c)) 0deg, var(--ring-color, var(--tw-accent, #53e68c)) calc(1deg * var(--pct, 0)), rgba(255,255,255,.08) 0);
    border: 1px solid var(--tw-border, #33363c);
    box-shadow: 0 0 8px rgba(59,130,246,.15);
    display: grid;
    place-items: center;
    overflow: hidden;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.ring::after {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(18,41,77,.75), rgba(18,41,77,.45));
    box-shadow: inset 0 0 10px rgba(0,0,0,.35);
}
.ring .lbl { position: relative; z-index: 1; font-size: 10px; color: var(--tw-txt-muted, #888); font-weight: 700; }
.ring.hp { background: conic-gradient(from 0deg, #ef4444 0deg, #f97316 calc(1deg * var(--pct, 0)), rgba(255,255,255,.08) 0); }
.ring.en { background: conic-gradient(from 0deg, #22c55e 0deg, #84cc16 calc(1deg * var(--pct, 0)), rgba(255,255,255,.08) 0); }
.ring.st { background: conic-gradient(from 0deg, #3b82f6 0deg, #60a5fa calc(1deg * var(--pct, 0)), rgba(255,255,255,.08) 0); }
.ring.xp { background: conic-gradient(from 0deg, #a78bfa 0deg, #60a5fa calc(1deg * var(--pct, 0)), rgba(255,255,255,.08) 0); }

/* Wallet tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--tw-border, #33363c);
    font-size: 13px;
    color: var(--tw-txt, #eee3b2);
    white-space: nowrap;
}
.tag .material-icons { font-size: 16px; color: var(--tw-gold, #ffe28a); }
.tag.small { padding: 4px 8px; font-size: 12px; }

/* Compact wallet for mobile - hidden on desktop */
.h-wallet-compact {
    display: none;
    gap: 4px;
}

/* Game icon buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--tw-txt, #eee3b2);
    background: rgba(255,255,255,.05);
    border: 1px solid var(--tw-border, #33363c);
    box-shadow: 0 0 8px rgba(59,130,246,.15);
    transition: all 0.2s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.08); }

/* Footer navigation */
.footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(10,22,40,.85), rgba(10,22,40,.95));
    backdrop-filter: blur(14px) saturate(180%);
    border-top: 1px solid var(--tw-border, #33363c);
    box-shadow: 0 -4px 20px rgba(0,0,0,.4);
}

.f-btn {
    flex: 1;
    max-width: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 12px;
    border: 1px solid var(--tw-border, #33363c);
    color: var(--tw-txt, #eee3b2);
    background: rgba(255,255,255,.05);
    box-shadow: 0 0 8px rgba(59,130,246,.15);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 13px;
}
.f-btn:hover { transform: translateY(-2px); background: rgba(255,255,255,.09); }
.f-btn .material-icons { font-size: 20px; }

/* Add padding at bottom for fixed footer */
body { padding-bottom: 70px; }

/* Responsive header */
@media (max-width: 960px) {
    .h-stats { gap: 4px; }
    .ring { width: 36px; height: 36px; }
    .ring .lbl { font-size: 9px; }
}
@media (max-width: 720px) {
    .h-stats { max-width: 200px; }
    .ring { width: 32px; height: 32px; }
    .h-left { gap: 6px; }
    .user-meta { font-size: 13px; max-width: 120px; }
}
@media (max-width: 480px) {
    .header { padding: 0 6px; gap: 6px; }
    .h-left { min-width: 0; flex: 0 0 auto; }
    .h-right { min-width: 0; flex: 0 0 auto; }
    .h-stats { display: none; }
    .avatar { width: 36px; height: 36px; font-size: 13px; }
    .icon-btn { min-width: 32px; height: 32px; padding: 0 6px; }
    .icon-btn .material-icons { font-size: 20px; }
    .user-meta { max-width: 80px; }
    .username { font-size: 13px; }
    .level { font-size: 10px; }
    .h-wallet-compact { display: flex !important; }
}
