/* =========================================================================
   DuckmanMC panel: dark UI house style
   Rules: dark only, colors only as :root variables, px/% units only,
   border-radius max 4px (circles excepted), flat 1px borders.
   ========================================================================= */

:root {
    color-scheme: dark;

    --TaskbarColor: #16161a;            /* sidebar, cards, inputs */
    --DashboardColor: #0e0e10;          /* page background */
    --SurfaceColor: rgba(255, 255, 255, 0.05);   /* hover surfaces */
    --BorderColor: rgba(255, 255, 255, 0.10);
    --TextColor: #ececef;
    --MutedText: #8a8a93;
    --AccentColor: #5b8def;
    --AccentColorHover: #7aa3f5;
    --AccentColorSoft: rgba(91, 141, 239, 0.20);
    --ButtonColor: #ececef;             /* primary button / active nav */
    --ButtonColorHover: #ffffff;
    --ButtonTextColor: #111111;
    --ButtonDisabledColor: #3a3a42;
    --DangerBg: rgba(239, 68, 68, 0.12);
    --DangerText: #f87171;
    --ShadowColor: rgba(0, 0, 0, 0.4);
    --RadiusSmall: 2px;
    --RadiusLarge: 4px;

    /* Extensions for this panel */
    --SuccessBg: rgba(74, 222, 128, 0.12);
    --SuccessText: #4ade80;
    --WarningBg: rgba(250, 204, 21, 0.12);
    --WarningText: #facc15;
    --ConsoleColor: #0a0a0c;
    --ConsoleText: #c9c9d1;
    --BrandColor: #4ade80;              /* grass-green block in the logo */
    --BrandColorDark: #3f8f3a;
}

/* ---------- Base reset ---------- */

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--DashboardColor);
    color: var(--TextColor);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

#app {
    height: 100%;
}

*, *::before, *::after {
    box-sizing: border-box;
}

h1, h2, h3, p {
    margin: 0;
}

a {
    color: var(--AccentColor);
}

a:hover {
    color: var(--AccentColorHover);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--AccentColor);
    outline-offset: 2px;
}

.muted {
    color: var(--MutedText);
}

/* ---------- Page shell ---------- */

.ml-page {
    display: flex;
    min-height: 100%;
    background: var(--DashboardColor);
}

.ml-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--TaskbarColor);
    border-right: 1px solid var(--BorderColor);
    padding: 20px 12px;
    overflow-y: auto;
}

.ml-brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--TextColor);
    text-decoration: none;
    padding: 0 8px;
}

.ml-brand {
    margin-bottom: 24px;
}

.ml-brand:hover {
    color: var(--TextColor);
}

.ml-brand-mark {
    width: 20px;
    height: 20px;
    border-radius: var(--RadiusSmall);
    background: var(--BrandColor);
    border-bottom: 6px solid var(--BrandColorDark);
}

.ml-nav {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-grow: 1;
}

.ml-nav-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ml-nav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--MutedText);
    padding: 0 10px 4px 10px;
}

.ml-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--RadiusSmall);
    color: var(--MutedText);
    font-size: 14px;
    text-decoration: none;
}

.ml-nav-link:hover {
    background: var(--SurfaceColor);
    color: var(--TextColor);
}

.ml-nav-link.active {
    background: var(--ButtonColor);
    color: var(--ButtonTextColor);
}

.ml-sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 8px 0 8px;
    margin-top: 16px;
    border-top: 1px solid var(--BorderColor);
}

.ml-user {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ml-user-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ml-user-role {
    font-size: 12px;
    color: var(--MutedText);
}

.ml-version {
    padding: 12px 8px 0 8px;
    font-size: 11px;
    color: var(--MutedText);
}

.ml-main-content {
    flex-grow: 1;
    margin-left: 240px;
    padding: 24px;
    min-width: 0;
}

.empty-layout {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
}

.page-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

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

.back-link {
    display: inline-block;
    font-size: 12px;
    color: var(--MutedText);
    text-decoration: none;
    margin-bottom: 4px;
}

.back-link:hover {
    color: var(--TextColor);
}

/* ---------- Cards ---------- */

.card {
    background: var(--TaskbarColor);
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    box-shadow: 0 1px 4px var(--ShadowColor);
    padding: 24px;
}

.card-flush {
    padding: 0;
    overflow-x: auto;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.card-title:not(:first-child) {
    margin-top: 24px;
}

.form-card {
    margin-bottom: 16px;
}

.form-narrow {
    max-width: 480px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--ButtonColor);
    color: var(--ButtonTextColor);
    border: 1px solid transparent;
    border-radius: var(--RadiusSmall);
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: var(--ButtonColorHover);
    color: var(--ButtonTextColor);
}

.btn:disabled {
    background: var(--ButtonDisabledColor);
    color: var(--MutedText);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--TaskbarColor);
    color: var(--TextColor);
    border-color: var(--BorderColor);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--TaskbarColor);
    color: var(--AccentColor);
    border-color: var(--AccentColor);
}

.btn-danger {
    background: var(--DangerBg);
    color: var(--DangerText);
    border-color: var(--DangerText);
}

.btn-danger:hover:not(:disabled) {
    background: var(--DangerText);
    color: var(--ButtonTextColor);
}

.btn-secondary:disabled,
.btn-danger:disabled {
    background: var(--ButtonDisabledColor);
    color: var(--MutedText);
    border-color: transparent;
}

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ---------- Forms ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.form-grid .field {
    flex: 1 1 240px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--MutedText);
}

.input,
.filter-group input,
.filter-group select {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    font-family: inherit;
    font-size: 14px;
    color: var(--TextColor);
    background: var(--DashboardColor);
    outline: none;
}

.input:hover:not(:disabled) {
    border-color: var(--MutedText);
}

.input:focus,
.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--AccentColor);
    box-shadow: 0 0 0 2px var(--AccentColorSoft);
}

.input:disabled {
    color: var(--MutedText);
    background: var(--SurfaceColor);
    cursor: not-allowed;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    cursor: pointer;
    user-select: none;
}

.checkbox:hover {
    background: var(--SurfaceColor);
}

.checkbox input {
    accent-color: var(--AccentColor);
    margin: 0;
}

.checkbox input:focus-visible {
    outline: 2px solid var(--AccentColor);
    outline-offset: 2px;
}

/* ---------- Filter bar ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

/* ---------- Alerts ---------- */

.alert-danger,
.alert-warning {
    padding: 12px 16px;
    border-radius: var(--RadiusSmall);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-danger {
    background: var(--DangerBg);
    color: var(--DangerText);
    border-left: 3px solid var(--DangerText);
}

.alert-warning {
    background: var(--WarningBg);
    color: var(--WarningText);
    border-left: 3px solid var(--WarningText);
    margin: 12px 0 0 0;
}

/* ---------- Loading spinner ---------- */

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loading-spinner svg {
    width: 128px;
    height: 128px;
    margin: 160px auto 16px auto;
}

.ml-main-content .loading-spinner svg {
    width: 64px;
    height: 64px;
    margin: 80px auto 16px auto;
}

.spinner-track {
    stroke: var(--BorderColor);
}

.spinner-progress {
    stroke: var(--AccentColor);
    stroke-linecap: round;
}

.loading-text {
    color: var(--MutedText);
}

/* ---------- Notifications ---------- */

.notification-host {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    max-width: 400px;
}

.notification {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--TaskbarColor);
    border: 1px solid var(--BorderColor);
    border-left-width: 3px;
    border-radius: var(--RadiusSmall);
    box-shadow: 0 1px 4px var(--ShadowColor);
}

.notification-success {
    border-left-color: var(--SuccessText);
}

.notification-error {
    border-left-color: var(--DangerText);
    color: var(--DangerText);
}

.notification-info {
    border-left-color: var(--AccentColor);
}

.notification-close {
    background: none;
    border: none;
    color: var(--MutedText);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.notification-close:hover {
    color: var(--TextColor);
}

/* ---------- Status badge ---------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: var(--RadiusSmall);
    font-size: 12px;
    font-weight: 600;
    background: var(--SurfaceColor);
    color: var(--MutedText);
    white-space: nowrap;
}

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

.status-online {
    background: var(--SuccessBg);
    color: var(--SuccessText);
}

.status-online .status-dot {
    background: var(--SuccessText);
}

.status-busy {
    background: var(--WarningBg);
    color: var(--WarningText);
}

.status-busy .status-dot {
    background: var(--WarningText);
}

.status-failed {
    background: var(--DangerBg);
    color: var(--DangerText);
}

.status-failed .status-dot {
    background: var(--DangerText);
}

/* ---------- Dashboard ---------- */

.server-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.server-card {
    flex: 1 1 320px;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.server-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.server-card-title {
    font-size: 16px;
    font-weight: 600;
}

.server-card-address {
    font-size: 12px;
    color: var(--MutedText);
}

.server-card-stats {
    display: flex;
    gap: 12px;
}

.stat {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--DashboardColor);
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--MutedText);
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
}

.server-card-motd {
    font-size: 12px;
    color: var(--MutedText);
    white-space: pre-line;
}

.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.player-chip,
.action-badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    font-size: 12px;
    background: var(--SurfaceColor);
    white-space: nowrap;
}

.server-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--BorderColor);
}

.server-card-open {
    margin-left: auto;
}

/* ---------- Server detail ---------- */

.detail-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.detail-grid > .card,
.detail-grid > .detail-column {
    flex: 1 1 260px;
    min-width: 0;
}

.detail-grid > .console-card {
    flex: 2 1 480px;
}

.detail-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-list {
    display: grid;
    grid-template-columns: 110px auto;
    gap: 8px 12px;
    margin: 0;
}

.info-list dt {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--MutedText);
}

.info-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.console {
    display: flex;
    flex-direction: column-reverse;   /* keeps the newest line in view without JS */
    height: 420px;
    overflow-y: auto;
    padding: 12px;
    background: var(--ConsoleColor);
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--ConsoleText);
}

.console-line {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.command-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.command-prefix {
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
    font-size: 16px;
    color: var(--MutedText);
}

.command-input {
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
}

.quick-commands {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.quick-commands .field-label {
    margin-right: 4px;
}

.quick-command {
    padding: 2px 8px;
    border: 1px dashed var(--BorderColor);
    border-radius: var(--RadiusSmall);
    background: none;
    color: var(--MutedText);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.quick-command:hover {
    border-color: var(--AccentColor);
    color: var(--AccentColor);
}

.command-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    max-height: 240px;
    overflow-y: auto;
}

.command-history-entry {
    padding: 8px 12px;
    background: var(--DashboardColor);
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
    font-size: 12px;
}

.command-history-command {
    color: var(--AccentColor);
}

.command-history-output {
    white-space: pre-wrap;
    color: var(--ConsoleText);
}

.command-history-output.failed {
    color: var(--DangerText);
}

/* ---------- Quick actions ---------- */

.quick-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-group + .quick-group {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--BorderColor);
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.quick-say {
    display: flex;
    gap: 8px;
}

.player-chip-button {
    color: var(--TextColor);
    font-family: inherit;
    cursor: pointer;
}

.player-chip-button:hover {
    border-color: var(--AccentColor);
    color: var(--AccentColor);
}

.player-chip-button.selected {
    background: var(--AccentColorSoft);
    border-color: var(--AccentColor);
}

.field-hint {
    font-size: 12px;
    color: var(--MutedText);
}

.field-hint.error {
    color: var(--DangerText);
}

/* ---------- Tables ---------- */

.tasks-table {
    width: 100%;
    border-collapse: collapse;
}

.tasks-table thead th {
    background: var(--DashboardColor);
    color: var(--TextColor);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--BorderColor);
    text-align: left;
    white-space: nowrap;
}

.tasks-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.tasks-table thead th.sortable:hover {
    color: var(--AccentColor);
}

.tasks-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--BorderColor);
    font-size: 14px;
    color: var(--TextColor);
    vertical-align: top;
}

.tasks-table tbody tr:hover {
    background: var(--SurfaceColor);
}

.tasks-table td.muted {
    color: var(--MutedText);
}

.cell-strong {
    font-weight: 600;
}

.cell-nowrap {
    white-space: nowrap;
}

.cell-detail {
    overflow-wrap: anywhere;
    min-width: 240px;
}

.col-actions {
    text-align: right;
    white-space: nowrap;
}

.col-actions .btn + .btn,
.col-actions .btn + a,
.col-actions a + .btn {
    margin-left: 4px;
}

.confirm-text {
    margin-right: 8px;
    color: var(--DangerText);
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--RadiusSmall);
    font-size: 12px;
    font-weight: 600;
    background: var(--SurfaceColor);
    color: var(--MutedText);
}

.role-admin {
    background: var(--AccentColorSoft);
    color: var(--AccentColorHover);
}

.access-line {
    display: flex;
    gap: 8px;
}

.access-server {
    font-weight: 600;
    min-width: 90px;
}

/* ---------- Pager ---------- */

.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.pager-info {
    color: var(--MutedText);
    font-size: 12px;
}

/* ---------- Permission editor ---------- */

.permission-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.permission-row {
    padding: 16px;
    background: var(--DashboardColor);
    border: 1px solid var(--BorderColor);
    border-radius: var(--RadiusSmall);
}

.permission-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.permission-server {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.permission-server-name {
    font-size: 16px;
    font-weight: 600;
}

.preset-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.preset-buttons .field-label {
    margin-right: 4px;
}

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

.command-editor {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--BorderColor);
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}

.command-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 8px;
    background: var(--AccentColorSoft);
    color: var(--TextColor);
    border-radius: var(--RadiusSmall);
    font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace;
    font-size: 12px;
}

.chip-remove {
    background: none;
    border: none;
    color: var(--MutedText);
    font-size: 14px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.chip-remove:hover {
    color: var(--DangerText);
}

.command-add {
    display: flex;
    gap: 8px;
    max-width: 400px;
}

/* ---------- Login ---------- */

.login-card {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-brand {
    padding: 0;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
}

.login-card .alert-danger {
    margin-bottom: 0;
}

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: 12px 24px;
    background: var(--DangerBg);
    color: var(--DangerText);
    border-top: 1px solid var(--DangerText);
    z-index: 1000;
}

#blazor-error-ui .reload {
    margin-left: 8px;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 24px;
    top: 12px;
    cursor: pointer;
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
    .ml-sidebar {
        position: static;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--BorderColor);
    }

    .ml-page {
        flex-direction: column;
    }

    .ml-main-content {
        margin-left: 0;
        padding: 16px;
    }

    .detail-grid {
        flex-direction: column;
        align-items: stretch;
    }
}
