/*
 * Block Shipper - run and manage Minecraft servers from a web dashboard.
 * Copyright (C) 2025-2026 zauberen
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* Header Bar */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
}

.app-logo span {
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-green) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-logo-icon {
    width: 2rem;
    height: 2rem;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username {
    color: var(--text-secondary);
    font-weight: 500;
}

.header-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.settings-icon:hover {
    color: var(--accent-green);
    transform: rotate(90deg);
}

.logout-icon:hover {
    color: var(--accent-red);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    width: 280px;
    height: calc(100vh - 70px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.nav-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-button.active {
    background: var(--accent-green);
    color: white;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.section-divider {
    border-top: 1px solid var(--border-color);
    margin: 1rem 0 0.75rem 0;
    padding-top: 0.75rem;
}

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

.section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.shutdown-button {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.375rem 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.75rem;
    font-weight: 500;
}

.shutdown-button:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.shutdown-icon {
    width: 14px;
    height: 14px;
}

.server-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.server-status.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.server-status.offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.server-status.listening {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.4);
}

/* Main Content */
.main-content {
    margin-left: 280px;
    margin-top: 70px;
    padding: 2rem;
    height: calc(100vh - 70px);
    overflow-y: auto;
    background: var(--bg-primary);
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.server-widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: var(--transition);
}

.server-widget:hover {
    border-color: var(--accent-green);
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.1);
}

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

.widget-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.widget-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.125rem;
}

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        margin-left: 250px;
    }

    .server-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding: 1rem;
    }
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Block Shipper components ---- */

a { color: var(--accent-green); }
.muted { color: var(--text-muted); }
.header-icon { display: block; }
.user-section a { display: flex; align-items: center; color: inherit; }

.server-status.disabled { background: var(--text-muted); }
.nav-button .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-button.active .server-status { box-shadow: 0 0 0 2px rgba(255,255,255,0.6); }

.dashboard-title.compact { margin-bottom: 0.25rem; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem; border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
    transition: var(--transition); background: var(--bg-tertiary); color: var(--text-primary);
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--accent-green); color: #062b14; }
.btn-secondary { background: transparent; border-color: var(--border-color); color: var(--text-secondary); }
.btn-secondary:hover { border-color: var(--accent-green); color: var(--text-primary); }
.btn-danger { background: transparent; border-color: var(--accent-red); color: var(--accent-red); }
.btn-danger:hover { background: var(--accent-red); color: white; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Alerts */
.alert { border-radius: 8px; padding: 0.75rem 1rem; margin: 0.75rem 0; border: 1px solid; font-size: 0.9rem; }
.alert ul { margin-left: 1.25rem; }
.alert.error { border-color: var(--accent-red); background: rgba(239, 68, 68, 0.1); color: #fecaca; }
.alert.success { border-color: var(--accent-green); background: rgba(74, 222, 128, 0.08); color: #bbf7d0; }
.alert.info { border-color: var(--accent-yellow); background: rgba(234, 179, 8, 0.08); color: #fef08a; }

/* Dialogs (confirm/prompt, see bsDialog in main.js) */
.bs-dialog {
    margin: auto; width: min(420px, calc(100vw - 2rem)); padding: 1.5rem;
    background: var(--bg-secondary); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 4px 20px var(--shadow-soft);
}
.bs-dialog[open] { animation: bs-dialog-in 0.15s ease-out; }
.bs-dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
.bs-dialog form { display: flex; flex-direction: column; gap: 1rem; }
.bs-dialog h2 { font-size: 1.05rem; font-weight: 600; }
.bs-dialog p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }
.bs-dialog .bs-dialog-error { color: var(--accent-red); font-size: 0.85rem; margin-top: -0.5rem; }
.bs-dialog .form-actions { margin-top: 0.25rem; }
@keyframes bs-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.spinner {
    display: inline-block; width: 0.9rem; height: 0.9rem; margin-right: 0.5rem; vertical-align: -2px;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: bs-spin 0.8s linear infinite;
}
@keyframes bs-spin { to { transform: rotate(360deg); } }

/* Cards and grids */
.card {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 1.25rem 1.5rem;
}
.card + .card { margin-top: 1.5rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card-header h2 { font-size: 1.05rem; font-weight: 600; }
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.panel-grid .card + .card { margin-top: 0; }
.span-2 { grid-column: span 2; }
.chart-container.tall { height: 260px; }
.chart-empty { height: 100%; display: flex; align-items: center; justify-content: center; }
.widget-stats.vertical { flex-direction: column; gap: 1rem; }
a.server-widget { display: block; color: inherit; text-decoration: none; }
.empty-state { padding: 3rem; text-align: center; border: 1px dashed var(--border-color); border-radius: 12px; }

/* Server page */
.server-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.server-subtitle { font-size: 0.9rem; }
.server-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.server-controls .alert { flex-basis: 100%; margin: 0; }
.status-pill {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem;
    border-radius: 999px; background: var(--bg-tertiary); font-size: 0.85rem; font-weight: 600;
}
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border-color); margin: 1rem 0 1.5rem; overflow-x: auto; }
.tab {
    padding: 0.65rem 1rem; color: var(--text-secondary); text-decoration: none; font-weight: 500;
    border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-green); border-bottom-color: var(--accent-green); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table th, .table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td.actions { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--bg-tertiary); color: var(--text-secondary); }
.badge.online { background: rgba(74, 222, 128, 0.15); color: var(--accent-green); }
.badge.banned { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge.op { background: rgba(96, 165, 250, 0.15); color: var(--accent-blue); }
.badge.inherited { background: rgba(234, 179, 8, 0.15); color: var(--accent-yellow); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 640px; }
.form-field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); }
.form-hint { font-size: 0.8rem; color: var(--text-muted); }
.form-input {
    background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 0.55rem 0.75rem; font-size: 0.95rem; font-family: inherit; width: 100%;
}
.form-input:focus { outline: none; border-color: var(--border-focus); }
.form-input.inline { width: auto; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; align-items: center; }
.checkbox { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.checkbox input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent-green); }
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form .form-input { width: auto; flex: 1; min-width: 10rem; }
.upload-progress { width: 100%; accent-color: var(--border-focus); }
fieldset.form-group { border: 1px solid var(--border-color); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
fieldset.form-group legend { padding: 0 0.4rem; font-weight: 600; color: var(--text-secondary); }
details.advanced summary { cursor: pointer; color: var(--text-secondary); font-weight: 600; margin-bottom: 0.75rem; }

/* Logs and console */
.log-view {
    background: #050505; border: 1px solid var(--border-color); border-radius: 8px;
    padding: 0.75rem; height: 320px; overflow-y: auto; font-size: 0.8rem; line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}
.log-view.console { height: calc(100vh - 380px); min-height: 300px; }
.log-line.command { color: var(--accent-green); }

/* Copy field */
.copy-field { display: flex; align-items: stretch; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; margin: 0.75rem 0; }
.copy-value { flex: 1; padding: 0.5rem 0.75rem; background: var(--bg-primary); font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; }
.copy-button { border: none; border-left: 1px solid var(--border-color); background: var(--bg-tertiary); color: var(--text-primary); padding: 0 1rem; cursor: pointer; font-weight: 600; }
.copy-button:hover { background: var(--accent-green); color: #062b14; }

/* Public dashboard */
body.public-body { overflow: auto; height: auto; min-height: 100vh; }
.public-main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.public-top { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 2rem; }
.public-top .dashboard-title { margin: 0; }
.public-logo { display: flex; }
.public-logo .app-logo-icon { width: 2.5rem; height: 2.5rem; }
.public-login { margin-left: auto; }
.public-hint { margin: -1.25rem 0 1.5rem; }
.public-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.public-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 1.25rem 1.5rem; }
.public-card .widget-header { flex-direction: column; align-items: flex-start; gap: 0.25rem; margin-bottom: 0.75rem; }
.public-card .widget-name { overflow-wrap: anywhere; }
.public-status { color: var(--text-secondary); font-size: 0.85rem; padding-left: calc(12px + 0.75rem); }
.public-footer { display: flex; justify-content: flex-end; align-items: center; }
.public-card > :last-child { margin-bottom: 0; }

/* Settings pages */
.settings-layout { max-width: 900px; }

@media (max-width: 1024px) {
    .panel-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
}
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.checkbox-grid .checkbox { font-size: 0.9rem; }
