/* ================================================================
   MC Orchestrator — Dark Theme
   ================================================================ */

:root {
    --bg-base: #0c0c0f;
    --bg-surface: #141419;
    --bg-elevated: #1a1a22;
    --bg-input: #111116;
    --border: #26262e;
    --border-hover: #3a3a44;
    --text-primary: #e8e8ed;
    --text-secondary: #8e8e9a;
    --text-muted: #5a5a66;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --green-dim: #166534;
    --red: #ef4444;
    --red-dim: #7f1d1d;
    --yellow: #eab308;
    --yellow-dim: #713f12;
    --blue: #3b82f6;
    --purple: #a855f7;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --transition: 150ms ease;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100%;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* === Layout === */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === Header === */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* === Back Link === */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: color var(--transition);
}
.back-link:hover { color: var(--text-primary); }

/* === Status === */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-running  { background: var(--green);  box-shadow: 0 0 10px rgba(34,197,94,0.5); }
.status-stopped  { background: var(--red);    box-shadow: 0 0 10px rgba(239,68,68,0.4); }
.status-changing { background: var(--yellow); box-shadow: 0 0 10px rgba(234,179,8,0.4); animation: pulse 1.2s ease-in-out infinite; }

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

.status-text {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.status-badge-running  { background: rgba(34,197,94,0.12); color: var(--green); }
.status-badge-stopped  { background: rgba(239,68,68,0.1); color: #f87171; }
.status-badge-changing { background: rgba(234,179,8,0.1); color: var(--yellow); }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.25; cursor: not-allowed; pointer-events: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-start   { background: var(--green-dim); color: var(--green); }
.btn-start:hover:not(:disabled) { background: #1a7a3a; }

.btn-stop    { background: var(--red-dim); color: #f87171; }
.btn-stop:hover:not(:disabled)  { background: #991b1b; }

.btn-restart { background: var(--yellow-dim); color: var(--yellow); }
.btn-restart:hover:not(:disabled) { background: #854d0e; }

.btn-send    { background: rgba(59,130,246,0.15); color: var(--blue); }
.btn-send:hover:not(:disabled) { background: rgba(59,130,246,0.25); }

.btn-upload  { background: rgba(168,85,247,0.15); color: var(--purple); }
.btn-upload:hover:not(:disabled) { background: rgba(168,85,247,0.25); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--border-hover); color: var(--text-primary); }

.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.75rem; }
.btn-icon-only { padding: 0.35rem 0.5rem; }

/* === Controls Row === */
.controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

/* === Section Labels === */
.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* === Cards / Panels === */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

/* === Console === */
.console-box {
    background: #09090b;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 420px;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}
.console-box::-webkit-scrollbar { width: 5px; }
.console-box::-webkit-scrollbar-track { background: transparent; }
.console-box::-webkit-scrollbar-thumb { background: #2a2a34; border-radius: 10px; }

.log-line { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-info  { color: #71717a; }
.log-warn  { color: var(--yellow); }
.log-error { color: var(--red); }

/* === Command Bar === */
.command-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.command-input {
    flex: 1;
    padding: 0.55rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    transition: border-color var(--transition);
}
.command-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.command-input:disabled { opacity: 0.3; }
.command-input::placeholder { color: var(--text-muted); }

/* === Inputs === */
input[type="text"].form-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color var(--transition);
}
input[type="text"].form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
input[type="text"].form-input::placeholder { color: var(--text-muted); }

/* === Upload Section === */
.upload-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.file-input-wrapper {
    flex: 1;
    position: relative;
}

input[type="file"] {
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-secondary);
    width: 100%;
}
input[type="file"]:disabled { opacity: 0.3; }
input[type="file"]::file-selector-button {
    font-family: inherit;
    font-weight: 600;
    font-size: 0.78rem;
    padding: 0.4rem 0.8rem;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-right: 0.75rem;
    transition: all var(--transition);
}
input[type="file"]::file-selector-button:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* === Progress Bar === */
.progress-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 100px;
    margin: 0.75rem 0 0.35rem 0;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 100px;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* === Upload Messages === */
.upload-message { margin-top: 0.5rem; font-size: 0.82rem; font-weight: 500; }
.upload-ok  { color: var(--green); }
.upload-err { color: var(--red); }

/* === Disk Usage === */
.disk-usage {
    margin-top: 0.85rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* === Port Badge === */
.port-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    border: 1px solid var(--border);
}

/* ================================================================
   Create Section (Worlds page)
   ================================================================ */
.create-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.75rem;
}

.create-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.create-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    font-family: inherit;
}
.create-tab:hover { color: var(--text-secondary); }
.create-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.create-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.create-input {
    flex: 1;
    padding: 0.55rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color var(--transition);
}
.create-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.create-input::placeholder { color: var(--text-muted); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.empty-state i {
    display: block;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

/* ================================================================
   World List & Cards
   ================================================================ */
.world-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.world-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.world-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.world-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.world-name {
    font-weight: 600;
    color: #fff;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.world-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.world-card-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.world-card-info i { font-size: 0.85rem; }

.world-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

/* === Rename Inline === */
.rename-input {
    padding: 0.3rem 0.55rem;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    width: 180px;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
.rename-input:focus { outline: none; }

.btn-icon {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--border); color: var(--text-primary); }

/* === Blazor Error UI === */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--red-dim);
    color: #fca5a5;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--red-dim);
    padding: 1rem;
    color: #fca5a5;
    border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ================================================================
   Header Nav Links
   ================================================================ */
.header-nav-links {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

/* ================================================================
   File Browser
   ================================================================ */

/* Upload Bar */
.file-upload-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.file-upload-bar input[type="file"] {
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Breadcrumb */
.file-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.breadcrumb-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all var(--transition);
    white-space: nowrap;
}
.breadcrumb-item:hover { color: var(--text-primary); background: var(--bg-elevated); }
.breadcrumb-item.active { color: var(--accent); font-weight: 600; }

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 0.65rem;
    margin: 0 0.1rem;
}

/* File List */
.file-list-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.file-item {
    display: grid;
    grid-template-columns: 2rem 1fr 5.5rem 10rem 5.5rem;
    align-items: center;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    transition: background var(--transition);
    gap: 0.5rem;
}
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-elevated); }

.file-item-parent { cursor: pointer; color: var(--text-muted); }
.file-item-parent:hover { color: var(--text-primary); }

.file-item-dir .file-name-link { font-weight: 600; }

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.file-name-link {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    text-align: left;
    padding: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--transition);
}
.file-name-link:hover { color: var(--accent); }

.file-size {
    text-align: right;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    white-space: nowrap;
}

.file-modified {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.file-actions-col {
    display: flex;
    justify-content: flex-end;
    gap: 0.3rem;
}

/* === Focus styles === */
h1:focus { outline: none; }

/* === Responsive === */
@media (max-width: 640px) {
    .app-container { padding: 1rem 0.75rem; }
    .header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .world-card-actions { gap: 0.3rem; }
    .create-row { flex-direction: column; align-items: stretch; }
    .console-box { height: 300px; }
}
