/* Genzcraft — Theme Variables (Dark / Light) */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

:root, [data-theme="dark"] {
    --bg-primary: #07070d;
    --bg-secondary: #0d0d17;
    --bg-card: rgba(255,255,255,.03);
    --bg-card-strong: rgba(13,13,23,.88);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255,255,255,.06);
    --border-accent: rgba(255,106,0,.2);
    --brand: #ff6a00;
    --brand-light: #ff8c38;
    --brand-glow: rgba(255,106,0,.15);
    --mc-green: #55ff55;
    --mc-green-dim: rgba(85,255,85,.12);
    --mesh-1: rgba(255,106,0,.12);
    --mesh-2: rgba(85,255,85,.06);
    --grid-line: rgba(255,106,0,.025);
    --shadow: rgba(0,0,0,.4);
    --input-bg: rgba(255,255,255,.04);
    --scrollbar-track: #0d0d17;
    --hero-overlay: linear-gradient(to bottom, rgba(7,7,13,.3) 0%, rgba(7,7,13,.85) 60%, #07070d 100%);
    --mc-border-light: #aaa;
    --mc-border-dark: #333;
    --mc-block-bg: #5a5a5a;
}

[data-theme="light"] {
    --bg-primary: #e8eef4;
    --bg-secondary: #f5f8fc;
    --bg-card: rgba(255,255,255,.85);
    --bg-card-strong: rgba(255,255,255,.95);
    --text-primary: #1a2332;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: rgba(0,0,0,.08);
    --border-accent: rgba(255,106,0,.25);
    --brand-glow: rgba(255,106,0,.1);
    --mc-green-dim: rgba(34,139,34,.1);
    --mesh-1: rgba(255,106,0,.08);
    --mesh-2: rgba(85,200,85,.08);
    --grid-line: rgba(0,0,0,.04);
    --shadow: rgba(0,0,0,.08);
    --input-bg: rgba(255,255,255,.9);
    --scrollbar-track: #dde4ec;
    --hero-overlay: linear-gradient(to bottom, rgba(232,238,244,.2) 0%, rgba(232,238,244,.75) 60%, #e8eef4 100%);
    --mc-border-light: #fff;
    --mc-border-dark: #8b8b8b;
    --mc-block-bg: #c6c6c6;
}

body {
    font-family: 'Kanit', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background .3s, color .3s;
}

.bg-mesh {
    position: fixed; inset: 0; z-index: -2; pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, var(--mesh-1), transparent),
        radial-gradient(ellipse 60% 40% at 80% 110%, var(--mesh-2), transparent),
        var(--bg-primary);
    transition: background .3s;
}

.bg-grid {
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
}

.bg-particles {
    position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 3px; }

.font-heading { font-family: 'Orbitron', sans-serif; }
.font-pixel { font-family: 'Press Start 2P', cursive; }

.glow-text { text-shadow: 0 0 24px var(--brand-glow), 0 0 48px rgba(255,106,0,.1); }
.text-gradient {
    background: linear-gradient(135deg, #ff8c38, #ff6a00, #55ff55);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    transition: background .3s, border-color .3s;
}
.glass-strong {
    background: var(--bg-card-strong);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-accent);
}
.glow-orange { box-shadow: 0 0 40px var(--brand-glow), 0 4px 24px var(--shadow); }

.card-hover { transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease; }
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px var(--brand-glow);
    border-color: rgba(255,106,0,.35);
}

.btn-primary {
    background: linear-gradient(135deg, #ff6a00, #ff8c38);
    color: #fff; font-weight: 600;
    transition: transform .2s, box-shadow .2s, opacity .2s;
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(255,106,0,.35);
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    transition: all .2s;
}
.btn-ghost:hover { background: var(--brand-glow); border-color: var(--border-accent); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--brand);
    color: var(--brand);
    transition: all .2s;
}
.btn-outline:hover { background: var(--brand-glow); }

.input-dark {
    background: var(--input-bg);
    border: 2px solid var(--border);
    color: var(--text-primary);
    transition: border-color .2s, box-shadow .2s;
}
.input-dark::placeholder { color: var(--text-muted); }
.input-dark:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
    outline: none;
}
.input-dark option,
.input-dark optgroup {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    outline: none;
}
.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-glow);
    cursor: pointer;
}
.range-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--brand);
    border: none;
    box-shadow: 0 0 0 4px var(--brand-glow);
    cursor: pointer;
}
.range-input::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: var(--border);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
}
.icon-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    color: var(--text-secondary);
    transition: border-color .2s, transform .2s;
}
.icon-tile:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}
.icon-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin: 0 auto 6px;
}
.icon-name {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown {
    background: var(--bg-card-strong);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.nav-dropdown-item {
    color: var(--text-secondary);
}
.nav-dropdown-item:hover {
    background: var(--brand-glow);
    color: var(--text-primary);
}
.nav-dropdown-item.active {
    color: var(--brand-light);
}

.nav-link {
    position: relative;
    padding: .5rem 1rem;
    border-radius: .5rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color .2s, background .2s;
    display: inline-flex; align-items: center; gap: .4rem;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--text-primary); background: var(--brand-glow); }
.nav-link.active::after {
    content: '';
    position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
    width: 20px; height: 2px; background: var(--brand); border-radius: 1px;
}
.nav-link.locked { opacity: .65; }

.theme-toggle {
    width: 2.5rem; height: 2.5rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: .75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--border-accent); }

.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-dot.offline { background: #ef4444; box-shadow: 0 0 8px #ef4444; animation: none; }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .6; transform: scale(1.2); }
}

.ip-box {
    background: var(--brand-glow);
    border: 2px dashed var(--border-accent);
    cursor: pointer;
    transition: all .2s;
}
.ip-box:hover { border-style: solid; background: rgba(255,106,0,.15); }
.ip-box.copied { border-color: #22c55e; background: rgba(34,197,94,.1); }

.table-dark tr:nth-child(even) { background: var(--bg-card); }
.table-dark tr:hover { background: var(--brand-glow); }

@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideInRight { from{opacity:0;transform:translateX(30px)} to{opacity:1;transform:translateX(0)} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes blockFall { 0%{transform:translateY(-20px) rotate(0);opacity:0} 10%{opacity:1} 100%{transform:translateY(100vh) rotate(360deg);opacity:0} }

.animate-float { animation: float 4s ease-in-out infinite; }
.page-enter { animation: fadeIn .35s ease; }
.toast-item { animation: slideInRight .3s ease; }

.modal-overlay {
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(6px);
    animation: fadeIn .2s ease;
}
.modal-content { animation: slideUp .3s ease; }

.cmd-card { transition: all .2s; }
.cmd-card:hover { border-color: var(--border-accent); }
.cmd-code {
    font-family: 'Consolas', 'Monaco', monospace;
    background: var(--bg-secondary);
    border: 1px solid var(--border-accent);
    color: var(--brand-light);
}

.rank-1 { background: linear-gradient(135deg, rgba(255,215,0,.15), var(--brand-glow)); border-color: rgba(255,215,0,.3)!important; }
.rank-2 { background: linear-gradient(135deg, rgba(192,192,192,.12), var(--bg-card)); border-color: rgba(192,192,192,.25)!important; }
.rank-3 { background: linear-gradient(135deg, rgba(205,127,50,.12), var(--brand-glow)); border-color: rgba(205,127,50,.25)!important; }

.tag { font-size: .65rem; padding: .15rem .5rem; border-radius: 9999px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tag-announce { background: rgba(59,130,246,.15); color: #3b82f6; }
.tag-update { background: rgba(34,197,94,.15); color: #16a34a; }
.tag-feature { background: var(--brand-glow); color: var(--brand); }
.tag-error { background: rgba(239,68,68,.15); color: #f87171; }

.filter-pill { transition: all .2s; cursor: pointer; color: var(--text-secondary); }
.filter-pill.active { background: var(--brand); color: #fff; }
.filter-pill:not(.active):hover { background: var(--bg-card); }
.filter-pill.active .count-badge { background: rgba(255,255,255,.25); color: #fff; }

.nav-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem;
    border-radius: 9999px; font-size: .6rem; font-weight: 700; line-height: 1.1rem;
    text-align: center; background: #ef4444; color: #fff;
    box-shadow: 0 0 0 2px var(--bg-body, #0f172a);
}
.nav-link .nav-badge { top: 2px; right: 2px; }

.count-badge {
    min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
    border-radius: 9999px; font-size: .65rem; font-weight: 700; line-height: 1.25rem;
    text-align: center;
}
.count-badge-warn { background: rgba(251,191,36,.2); color: #fbbf24; }
.count-badge-ok { background: rgba(34,197,94,.2); color: #22c55e; }

.tag-pending { background: rgba(251,191,36,.15); color: #fbbf24; text-transform: none; letter-spacing: 0; }
.tag-delivered { background: rgba(34,197,94,.15); color: #22c55e; text-transform: none; letter-spacing: 0; }

.stat-card-warn { border-color: rgba(251,191,36,.35)!important; background: linear-gradient(135deg, rgba(251,191,36,.08), var(--bg-card)); }
.row-pending { background: rgba(251,191,36,.06); }
.row-pending:hover { background: rgba(251,191,36,.1); }

.section-title::after {
    content: '';
    display: block; width: 60px; height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--mc-green), transparent);
    margin: .75rem auto 0; border-radius: 2px;
}

.activity-item { border-left: 3px solid var(--brand); padding-left: .75rem; }

.hero-banner-wrap { position: relative; min-height: 420px; overflow: hidden; }
.hero-banner-img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; object-position: center;
}
.hero-banner-overlay {
    position: absolute; inset: 0;
    background: var(--hero-overlay);
}
.hero-logo {
    filter: drop-shadow(0 8px 32px rgba(0,0,0,.5)) drop-shadow(0 0 40px rgba(255,106,0,.2));
    max-height: 180px; width: auto;
}

.logo-nav { height: 44px; width: auto; filter: drop-shadow(0 2px 8px rgba(0,0,0,.3)); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
    .hero-logo { max-height: 120px; }
}

/* System dashboard meters */
.sys-meter {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.sys-meter-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.sys-meter-ok { background: linear-gradient(90deg, #22c55e, #4ade80); }
.sys-meter-mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.sys-meter-high { background: linear-gradient(90deg, #ef4444, #f87171); }

/* Admin workspace */
.admin-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: var(--bg-card);
}
.admin-hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
}
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}
.admin-stat-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 74px;
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: var(--bg-card);
}
.admin-stat-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: .65rem;
    background: var(--bg-secondary);
}
.admin-workspace {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.admin-sidebar {
    position: sticky;
    top: 88px;
    display: flex;
    flex-direction: column;
    gap: .9rem;
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: var(--bg-card);
}
.admin-menu-title {
    margin-bottom: .4rem;
    padding: 0 .35rem;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.admin-menu-item {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .65rem .75rem;
    border-radius: .55rem;
    color: var(--text-secondary);
    font-size: .875rem;
    font-weight: 600;
    transition: background .2s, color .2s, transform .2s;
}
.admin-menu-left {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: .55rem;
}
.admin-menu-left i { width: 1rem; text-align: center; }
.admin-menu-item:hover {
    color: var(--text-primary);
    background: var(--brand-glow);
}
.admin-menu-item.active {
    color: #fff;
    background: var(--brand);
}
.admin-content { min-width: 0; }

@media (min-width: 768px) {
    .admin-stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
    .admin-stats-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .admin-hero { align-items: flex-start; flex-direction: column; }
    .admin-hero-actions { justify-content: flex-start; }
    .admin-workspace { display: block; }
    .admin-sidebar {
        position: static;
        margin-bottom: 1rem;
        overflow-x: auto;
        flex-direction: row;
        align-items: stretch;
    }
    .admin-menu-group { min-width: 190px; }
}

/* ── Floating Hardware Alert Badge ── */
@keyframes hw-slide-in {
    from { opacity: 0; transform: translateX(120%) scale(.9); }
    to   { opacity: 1; transform: translateX(0)   scale(1); }
}
@keyframes hw-glow-critical {
    0%, 100% { box-shadow: 0 0 10px 2px rgba(239,68,68,.45), 0 8px 32px rgba(0,0,0,.5); }
    50%       { box-shadow: 0 0 28px 8px rgba(239,68,68,.75), 0 8px 32px rgba(0,0,0,.5); }
}
@keyframes hw-glow-warn {
    0%, 100% { box-shadow: 0 0 10px 2px rgba(251,191,36,.35), 0 8px 32px rgba(0,0,0,.5); }
    50%       { box-shadow: 0 0 22px 6px rgba(251,191,36,.65), 0 8px 32px rgba(0,0,0,.5); }
}
@keyframes hw-dot-ping {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%       { transform: scale(2.2); opacity: 0; }
}

.hw-float-badge {
    animation: hw-slide-in .4s cubic-bezier(.34,1.56,.64,1) both;
}
.hw-float-badge.critical {
    animation: hw-slide-in .4s cubic-bezier(.34,1.56,.64,1) both,
               hw-glow-critical 2s ease-in-out 0.4s infinite;
}
.hw-float-badge.warn {
    animation: hw-slide-in .4s cubic-bezier(.34,1.56,.64,1) both,
               hw-glow-warn 2.5s ease-in-out 0.4s infinite;
}
.hw-float-dot {
    animation: hw-dot-ping 1.5s ease-in-out infinite;
}
