:root {
    --bg-base: #080c14;
    --bg-surface: #0f172a;
    --bg-card: rgba(18, 26, 44, 0.75);
    --bg-card-hover: rgba(26, 38, 64, 0.85);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(239, 68, 68, 0.5);

    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-glow: rgba(239, 68, 68, 0.25);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at 15% 15%, #131d33 0%, #080c14 60%, #03060a 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

.svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.btn .svg-icon {
    margin-right: 0.2rem;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: all 0.25s ease;
}

/* Login Modal */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 10, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1.5rem;
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-glow);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 2.8rem;
    color: var(--accent-red);
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 12px var(--accent-red));
}

.login-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.2rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"] {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(0, 0, 0, 0.6);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.3rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary { background: var(--accent-red); box-shadow: 0 4px 15px var(--accent-glow); }
.btn-primary:hover:not(:disabled) { background: var(--accent-red-hover); box-shadow: 0 6px 25px rgba(239,68,68,0.4); }

.btn-secondary { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-subtle); }
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-main); }

.btn-success { background: var(--success); }
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled) { background: #d97706; color: #fff; }

.btn-danger { background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-block { width: 100%; }
.btn-xs { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.error-msg {
    color: var(--accent-red);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.glass-header {
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent-red);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand h1 span {
    color: var(--accent-red);
}

.badge-role {
    font-size: 0.65rem;
    font-weight: 800;
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.server-status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 700;
}

.server-ping-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--success);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.card-footer-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.9rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
}

.footer-metric-label {
    color: var(--text-muted);
}

.footer-metric-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--success);
}

.players-summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.player-stat-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-caption {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-number {
    font-size: 1.3rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-main);
}

.highlight-slots {
    color: #38bdf8;
}

.slot-bar {
    margin-bottom: 0.8rem;
}

.slot-fill {
    background: linear-gradient(90deg, #38bdf8, #818cf8);
}

.player-list-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.player-list-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.player-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 28px;
}

.player-badge {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #7dd3fc;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

.no-players-text {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-style: italic;
}

.compact-info {
    margin-top: 0.8rem;
}

.dashboard-content {
    padding: 1.8rem 2rem;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

/* Top Cards Grid */
.top-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.card-summary {
    padding: 1.4rem 1.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.badge-tag {
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.metric-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.metric-value-row {
    margin: 0.4rem 0;
}

.metric-num {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-main);
}

.progress-bar {
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    transition: width 0.4s ease;
}

.power-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.info-label {
    color: var(--text-muted);
}

.info-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-main);
}

.info-val.highlight {
    color: var(--warning);
}

/* Master Configuration Section */
.editor-section {
    padding: 1.6rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.editor-top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.2rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1.2rem;
}

.editor-title-group h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.section-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.editor-actions-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.select-wrapper select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 0.75rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    min-width: 260px;
    transition: all 0.2s ease;
}

.select-wrapper select:focus {
    border-color: var(--accent-red);
}

.select-wrapper select option {
    background: #0f172a;
    color: white;
}

/* Alert Banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.2rem;
    color: #fca5a5;
    font-size: 0.9rem;
    line-height: 1.4;
}

.alert-icon {
    font-size: 1.3rem;
}

/* GUI Toolbar (Search & Tabs) */
.gui-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.search-box input {
    padding-left: 2.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-tab-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-main);
}

.category-tab-btn.active {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
    box-shadow: 0 2px 10px var(--accent-glow);
}

/* Editor Workspace Area */
.editor-workspace {
    min-height: 480px;
    max-height: 750px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    background: rgba(5, 8, 15, 0.4);
    border: 1px solid var(--border-subtle);
    padding: 1.2rem;
}

.editor-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.editor-empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.editor-empty-state p {
    max-width: 500px;
    font-size: 0.9rem;
}

.editor-empty-state code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: var(--warning);
}

#fileEditor {
    width: 100%;
    height: 550px;
    background: #060911;
    color: #cbd5e1;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.92rem;
    line-height: 1.5;
    outline: none;
    resize: vertical;
}

/* GUI Container & Groups */
.gui-container {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

.gui-group {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
}

.gui-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.8rem;
    margin-bottom: 1.2rem;
}

.gui-group-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gui-group-count {
    font-size: 0.75rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

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

/* Option Card */
.option-card {
    background: rgba(10, 16, 28, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.8rem;
    transition: all 0.2s ease;
}

.option-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(15, 23, 42, 0.8);
    transform: translateY(-1px);
}

.option-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
}

.option-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.option-key {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.95rem;
    color: #e2e8f0;
}

.option-desc {
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.option-control {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Custom iOS/Mac Style Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

input:checked + .slider {
    background-color: var(--success);
    border-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Input Fields inside Card */
.option-input-num {
    max-width: 140px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.option-input-text {
    width: 100%;
}

/* Live Logs Terminal Section */
.logs-section {
    padding: 1.4rem 1.6rem;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.6rem;
}

.logs-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.terminal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.logs-title h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.terminal-body {
    background: #040711;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    height: 380px;
    overflow-y: auto;
}

pre#terminalOutput {
    color: #4ade80;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .glass-header {
        padding: 0.8rem 1rem;
    }
    .dashboard-content {
        padding: 1rem;
    }
    .editor-top-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .editor-actions-group {
        flex-direction: column;
        align-items: stretch;
    }
    .select-wrapper select {
        width: 100%;
        min-width: 0;
    }
    .gui-cards-grid {
        grid-template-columns: 1fr;
    }
}
