﻿/* =========================================================
   GestionBot dashboard - cleaned global stylesheet
   ========================================================= */

:root {
  --bg: #000;
  --surface: #0d0d0d;
  --surface-2: #121212;
  --surface-3: #191919;
  --panel: rgba(14, 14, 14, 0.96);
  --line: #2b2b2b;
  --line-soft: #1b1b1b;
  --red: #e50914;
  --red-2: #ff3341;
  --red-dark: #9f0710;
  --green: #36e28a;
  --green-soft: rgba(54, 226, 138, 0.16);
  --purple: #9a66ff;
  --text: #fff;
  --muted: #b8b8b8;
  --muted-2: #858585;
  --shadow-red: 0 0 6px rgba(255, 60, 60, 0.9), 0 0 12px rgba(229, 9, 20, 0.78);
  --shadow-green: 0 0 8px rgba(54, 226, 138, 0.9), 0 0 18px rgba(54, 226, 138, 0.36);
  --radius: 8px;
  --admin-menu-height: 170px;
  --admin-gap: 16px;
  --admin-left-width: 284px;
  --admin-right-width: 344px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 22px;
  background: radial-gradient(circle at 50% -12%, rgba(229, 9, 20, 0.1), transparent 36%), var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
}

body:not(.minecraft-view) {
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
#info,
.glow-text,
.bot-name,
.bot-status-dot,
.right-panel-section,
.history-entry,
#full-history-list,
.bot-card strong {
  color: var(--text);
  font-weight: 700;
  text-shadow: var(--shadow-red);
}

h1 {
  margin: 18px 0 8px;
  font-size: 2rem;
}

#info {
  margin: 0 0 16px;
  color: var(--muted);
}

button,
a.button-like,
.discord-dev-actions a {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--red);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  text-shadow: var(--shadow-red);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

button:hover,
a.button-like:hover,
.discord-dev-actions a:hover {
  background: var(--red-dark);
  border-color: var(--red-2);
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #4a4a4a;
  border-radius: 6px;
  background: #202020;
  color: var(--text);
  font: inherit;
  outline: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--red-2);
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.22);
}

select option { background: #151515; color: var(--text); }

pre {
  margin: 0;
  text-align: left;
  font-family: Consolas, 'Courier New', monospace;
}

/* Popup and session */
.popup {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 5000;
  display: none;
  max-width: min(720px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: rgba(18, 18, 18, 0.96);
  box-shadow: 0 0 18px rgba(229, 9, 20, 0.45);
  transform: translateX(-50%);
}

.popup.show { display: block; animation: popupIn 0.18s ease; }

@keyframes popupIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

#session-timer-box {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 2600;
  width: 276px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(14, 14, 14, 0.94);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: left;
}

#session-timer.low { color: #ff6f78; font-weight: 700; }

/* Common layout */
#page-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  gap: 18px;
  width: 100%;
}

.left-panel,
.right-panel,
.center-panel { min-width: 0; }

.left-panel,
.right-panel { text-align: left; }

#search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
}

#clear-search { background: #3b3b3b; }
#clear-search:hover { background: #565656; }

#bot-list {
  display: grid;
  gap: 16px;
  width: 100%;
  margin-top: 18px;
}

/* Admin top menu */
body.admin-view:not(.minecraft-view) {
  padding: calc(var(--admin-menu-height) + var(--admin-gap)) 18px 36px;
  overflow-y: auto;
}

body.admin-view:not(.minecraft-view) > h1,
body.admin-view:not(.minecraft-view) > #info,
body.admin-view:not(.minecraft-view) > #login,
body.admin-view:not(.minecraft-view) > #logout,
body.admin-view:not(.minecraft-view) > #minecraft-btn {
  display: none !important;
}

#admin-top-menu {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2400;
  height: var(--admin-menu-height);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.96);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8);
}

.admin-menu-inner {
  width: min(1880px, calc(100vw - 28px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(480px, 720px) minmax(320px, 1fr);
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "user search actions"
    "user tabs actions"
    "user filters actions";
  gap: 8px 18px;
  align-items: center;
  padding: 9px 0;
}

.admin-menu-top {
  display: contents;
}

.admin-menu-user {
  grid-area: user;
  display: grid;
  gap: 14px;
  justify-items: start;
  align-content: center;
  text-align: left;
}

.admin-menu-user #info { margin: 0; }
.admin-menu-user #logout { margin: 0 0 0 62px; min-width: 150px; }

.admin-menu-actions,
.admin-preview-switch,
.admin-menu-filters,
#status-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-menu-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(3, max-content);
  grid-auto-rows: 34px;
  gap: 12px;
  justify-content: end;
  align-content: center;
}

.admin-menu-tabs {
  grid-area: tabs;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.admin-main-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-main-tabs button {
  min-height: 34px;
  margin: 0;
  background: #1b1b1b;
  border-color: #595959;
}

.admin-main-tabs button.active {
  background: var(--red);
  border-color: var(--red-2);
  box-shadow: 0 0 10px rgba(229, 9, 20, 0.5);
}

.admin-menu-actions button,
.admin-preview-switch button,
.add-bot-tile { margin: 0; }

.admin-menu-actions #show-add-bot {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.admin-menu-actions #minecraft-btn {
  grid-column: 2;
  grid-row: 2;
}

.admin-menu-actions #view-full-history {
  grid-column: 3;
  grid-row: 2;
}

.admin-preview-switch {
  grid-column: 1 / 4;
  grid-row: 3;
  display: flex;
  justify-content: end;
  gap: 10px;
  padding-left: 0;
  border-left: 0;
}

.admin-preview-switch button,
.status-filter-btn {
  background: #1b1b1b;
  border-color: #595959;
}

.admin-preview-switch button.active,
.status-filter-btn.active {
  background: var(--red);
  border-color: var(--red-2);
  box-shadow: 0 0 10px rgba(229, 9, 20, 0.5);
}

.admin-menu-search #search-bar {
  grid-area: search;
  display: grid !important;
  width: min(720px, 100%);
  margin: 0 auto;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
}

.admin-menu-search #search-input {
  height: 36px;
}

.admin-menu-search #clear-search {
  height: 36px;
  min-width: 110px;
}

.admin-menu-filters {
  grid-area: filters;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.is-hidden {
  display: none !important;
}

.admin-menu-filters #status-filters { justify-content: center; }
.admin-menu-filters .add-bot-tile { min-width: 150px; background: #101010; border-color: var(--red); }

/* Admin shell */
body.admin-view:not(.minecraft-view) #page-layout {
  display: block;
  margin: 0;
}

body.admin-view:not(.minecraft-view) .left-panel,
body.admin-view:not(.minecraft-view) .right-panel {
  position: fixed;
  top: calc(var(--admin-menu-height) + var(--admin-gap));
  bottom: 18px;
  z-index: 1200;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(11, 11, 11, 0.98), rgba(4, 4, 4, 0.98));
}

body.admin-view:not(.minecraft-view) .left-panel::-webkit-scrollbar,
body.admin-view:not(.minecraft-view) .right-panel::-webkit-scrollbar { display: none; }

body.admin-view:not(.minecraft-view) .left-panel {
  left: 12px;
  width: var(--admin-left-width);
  padding: 14px 16px 18px;
  border-radius: 0 8px 8px 0;
}

body.admin-view:not(.minecraft-view) .right-panel {
  right: 12px;
  width: var(--admin-right-width);
  padding: 12px;
  border-radius: 8px 0 0 8px;
}

body.admin-view:not(.minecraft-view) .center-panel {
  display: block;
  margin-left: calc(var(--admin-left-width) + 18px);
  margin-right: calc(var(--admin-right-width) + 18px);
  text-align: left;
}

body.admin-view:not(.minecraft-view) .center-panel > #search-bar { display: none !important; }

/* Sidebar */
#status-indicator { margin: 2px 0 4px; }
#status-indicator.online { color: var(--green); text-shadow: var(--shadow-green); }
#status-indicator.offline { color: #ff6770; }
#status-indicator.live { color: var(--purple); text-shadow: 0 0 8px rgba(154, 102, 255, 0.85); }
#status-summary { margin: 0 0 14px; font-size: 0.93rem; }

.managed-process-sidebar {
  margin: 0 0 20px;
  padding: 10px;
  border: 1px solid rgba(54, 226, 138, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(19, 52, 36, 0.32), rgba(8, 8, 8, 0.94));
}

.managed-sidebar-label,
.sidebar-category-title {
  margin: 16px 0 10px;
  color: #ddd;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: none;
}

.managed-process-sidebar .managed-sidebar-label {
  margin: 0 0 10px;
  color: #dfffee;
}

.sidebar-category-title:not(.is-empty)::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 18px;
  margin-right: 8px;
  border-radius: 3px;
  background: var(--red);
  vertical-align: -4px;
}

.sidebar-category-title.is-empty,
.sidebar-bot-status.is-empty { display: none !important; }

.sidebar-bot-status {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.bot-status-line {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 20px;
  gap: 9px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.managed-process-sidebar .bot-status-line {
  grid-template-columns: 18px minmax(0, 1fr) 18px;
  background: rgba(0, 0, 0, 0.18);
}

.bot-status-line:hover { background: rgba(255, 255, 255, 0.055); }

.avatar-small {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.bot-status-icon {
  width: 16px;
  color: var(--green);
  text-align: center;
  text-shadow: var(--shadow-green);
}

.bot-name {
  min-width: 0;
  overflow: hidden;
  color: #f5f5f5;
  font-size: 0.88rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bot-status-dot {
  text-align: right;
  font-size: 1rem;
  text-shadow: var(--shadow-green);
}

.sidebar-spacer { height: 28px; }

/* Right panel */
.right-panel-row {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
}

.right-panel-section {
  width: 100%;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.98), rgba(10, 10, 10, 0.98));
}

.right-panel-section h3 {
  margin: 0 0 14px;
  font-size: 1.08rem;
}

.right-panel-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.right-panel-section li {
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.right-panel-section li:last-child { border-bottom: 0; }
#history-log { max-height: calc(100vh - var(--admin-menu-height) - 300px); overflow: auto; scrollbar-width: none; }
#history-log::-webkit-scrollbar { display: none; }

/* Managed process dashboard */
.managed-processes-panel {
  grid-column: 1 / -1;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}

.managed-processes-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.managed-processes-panel h2 { margin: 0; }

.managed-process-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 12px;
}

.managed-process-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111;
}

.managed-process-card.running { border-color: rgba(54, 226, 138, 0.78); }
.managed-process-card.stopped { border-color: rgba(229, 9, 20, 0.82); }

.managed-process-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.managed-process-card h3 { margin: 0; font-size: 1.08rem; }
.managed-process-head span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }

.managed-process-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.managed-process-meta span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #050505;
  font-size: 0.78rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.managed-process-error {
  padding: 8px;
  border: 1px solid var(--red);
  border-radius: 6px;
  background: rgba(229, 9, 20, 0.13);
  color: #ffb3b8;
  font-size: 0.82rem;
}

.managed-process-actions,
.stream-bot-controls,
.managed-overview-actions,
.managed-single-actions,
.editor-actions,
.discord-dev-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.managed-process-actions button,
.stream-bot-controls button,
.managed-overview-actions button,
.managed-single-actions button,
.editor-actions button,
.discord-dev-actions button { margin: 0; }

.managed-process-console,
.mini-console,
.bot-card-console .mini-console {
  height: 92px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #020202;
  color: #f2f2f2;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: pre-wrap;
}

.admin-ops-panel {
  grid-column: 1 / -1;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 17, 17, 0.98), rgba(7, 7, 7, 0.98));
  text-align: left;
}

.admin-tab-panel {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

.tab-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.tab-panel-header h2,
.tab-panel-header p {
  margin: 0;
}

.tab-panel-header p {
  color: var(--muted);
  text-shadow: none;
}

.admin-history-panel,
.admin-minecraft-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 520px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.history-toolbar .filter-button-group {
  justify-content: flex-start;
}

.history-toolbar #history-search {
  width: 100%;
  max-width: none;
}

.admin-history-panel #full-history-list {
  display: grid;
  gap: 10px;
  margin-top: 0;
}

.admin-ops-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-ops-header h2,
.admin-ops-header p { margin: 0; }
.admin-ops-header p { color: var(--muted); font-size: 0.88rem; }

.admin-ops-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 12px;
}

.admin-ops-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101010;
}

.admin-ops-card h3,
.admin-ops-card h4 {
  margin: 0 0 10px;
}

.admin-ops-card h4 {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  text-shadow: none;
}

.ops-kpi,
.ops-kpi-grid {
  margin-bottom: 10px;
}

.ops-kpi {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.ops-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ops-kpi-grid span {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #050505;
  font-size: 0.82rem;
}

.ops-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  text-shadow: none;
}

.ops-pill.ok {
  background: rgba(54, 226, 138, 0.16);
  color: #8fffc2;
  border: 1px solid rgba(54, 226, 138, 0.42);
}

.ops-pill.warn {
  background: rgba(229, 9, 20, 0.16);
  color: #ffadb4;
  border: 1px solid rgba(229, 9, 20, 0.55);
}

.ops-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ops-list li {
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.24);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ops-list small,
.ops-empty {
  color: var(--muted);
  text-shadow: none;
}

.ops-list button {
  min-height: 28px;
  margin-top: 7px;
}

.announcement-preview {
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #050505;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  white-space: pre-wrap;
  text-shadow: none;
}

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

.message-actions button {
  min-height: 30px;
}

.variables-help {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.7;
  text-shadow: none;
}

.variables-help code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #050505;
  color: #fff;
}

/* Bot stream cards */
body.admin-view:not(.minecraft-view) #bot-list {
  grid-template-columns: repeat(2, minmax(560px, 1fr));
  align-items: start;
  gap: 18px;
  margin-top: 0;
}

.bot-card {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #121212, #0d0d0d);
  box-shadow: 0 0 10px rgba(229, 9, 20, 0.48);
  text-align: left;
}

body.admin-view:not(.minecraft-view) .bot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: 14px;
  min-height: 280px;
}

.bot-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.bot-header h2,
.bot-card h2 { margin: 0; font-size: 1.26rem; line-height: 1.08; overflow-wrap: anywhere; }

.avatar-large,
.avatar.avatar-large {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-glow {
  display: inline-flex;
  border-radius: 50%;
}
.glow-online { box-shadow: var(--shadow-green); }
.glow-offline { box-shadow: 0 0 12px rgba(255, 80, 88, 0.8); }

.bot-card > button {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  min-width: 140px;
  margin: 0;
}

.bot-card > ul {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  max-height: none;
  margin: 0;
  padding: 10px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #070707;
  list-style: none;
}

.bot-card > ul li {
  min-width: 0;
  min-height: 22px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.stream-bot-controls {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0b0b;
}

.stream-bot-controls span { margin-right: auto; color: var(--muted); font-weight: 700; }

.bot-card-console {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.bot-card-console h3 { margin: 0; font-size: 0.96rem; }
.bot-card-console .mini-console { height: 130px; }

.bot-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-items: center;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(229, 9, 20, 0.16), rgba(0, 0, 0, 0.42));
  pointer-events: none;
}
.bot-card.is-refreshing .bot-loading-overlay { display: grid; }
.bot-loader-ring {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.16);
  border-top-color: var(--red-2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal and editors */
.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
}

.editor-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}

.editor-modal-panel {
  position: relative;
  width: min(1180px, calc(100vw - 44px));
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: #0c0c0c;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.82), 0 0 18px rgba(229, 9, 20, 0.45);
}

.editor-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.editor-modal-header h2 { margin: 0; }
.editor-modal-header button { margin: 0; background: #252525; }
.editor-modal-body { min-height: 0; overflow: auto; padding: 18px; text-align: left; }

.bot-edit-layout,
.discord-dev-wizard,
.managed-bot-panel,
.managed-single-streamer,
.user-stream-editor {
  display: grid;
  gap: 16px;
}

.bot-edit-section,
.discord-setup-panel,
.managed-bot-panel,
.managed-single-streamer,
.user-stream-editor,
.stream-row,
.managed-stream-row {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111;
}

.bot-edit-section h3,
.bot-edit-section-head h3 { margin: 0 0 10px; }

.bot-edit-grid,
.discord-field-grid,
.managed-bot-grid,
.stream-row,
.managed-stream-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: start;
}

.field,
label,
.managed-messages,
.stream-messages-field {
  display: grid;
  gap: 6px;
}

label span,
.field span,
.stream-messages-field > span,
.managed-messages > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-help,
.field small,
small {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.82rem;
  line-height: 1.35;
}

.bot-edit-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.bot-edit-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 10, 10, 0.96);
}

.channel-list,
.announcement-message-list,
.message-list { display: grid; gap: 10px; }

.message-item,
.announcement-message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151515;
}

.message-item button,
.announcement-message-row button { margin: 0; background: #272727; }

.stream-messages-field,
.managed-messages { grid-column: 1 / -1; }

.discord-dev-actions { margin: 12px 0; }
.discord-token-result,
.discord-invite-box,
.discord-resource-loader {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080808;
}
.discord-token-result.success { color: var(--green); border-color: var(--green); }
.discord-token-result.error { color: #ff8b92; border-color: var(--red); }
.discord-token-result img { width: 30px; height: 30px; border-radius: 50%; }
.discord-invite-box { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.discord-resource-loader { display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(130px, auto); gap: 10px; align-items: end; }

/* Manager and streamer role views */
body.manager-view:not(.minecraft-view),
body.streamer-view:not(.minecraft-view) {
  height: 100vh;
  overflow: hidden;
  padding: 90px 28px 24px;
}

body.manager-view:not(.minecraft-view) > h1,
body.streamer-view:not(.minecraft-view) > h1,
body.manager-view:not(.minecraft-view) > #info,
body.streamer-view:not(.minecraft-view) > #info { display: none !important; }

#role-top-menu {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2400;
  height: 72px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.96);
}

.role-menu-inner {
  width: min(1120px, calc(100vw - 48px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.role-menu-user #info { margin: 0; text-align: left; }
.role-menu-actions { display: flex; gap: 10px; align-items: center; }
.role-menu-actions button { margin: 0; }

body.manager-view:not(.minecraft-view) .left-panel,
body.manager-view:not(.minecraft-view) .right-panel,
body.manager-view:not(.minecraft-view) #search-bar,
body.streamer-view:not(.minecraft-view) .left-panel,
body.streamer-view:not(.minecraft-view) .right-panel,
body.streamer-view:not(.minecraft-view) #search-bar { display: none !important; }

body.manager-view:not(.minecraft-view) #page-layout,
body.streamer-view:not(.minecraft-view) #page-layout { display: block; height: 100%; }
body.manager-view:not(.minecraft-view) .center-panel,
body.streamer-view:not(.minecraft-view) .center-panel { width: min(1120px, calc(100vw - 56px)); height: 100%; margin: 0 auto; }
body.manager-view:not(.minecraft-view) #bot-list,
body.streamer-view:not(.minecraft-view) #bot-list { height: 100%; margin: 0; overflow: hidden; }
body.manager-view:not(.minecraft-view) .bot-card,
body.streamer-view:not(.minecraft-view) .bot-card { height: 100%; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr); }

.managed-overview,
.streamer-overview { min-height: 0; display: grid; gap: 12px; overflow: auto; scrollbar-width: none; }
.managed-overview::-webkit-scrollbar,
.streamer-overview::-webkit-scrollbar { display: none; }

.managed-overview-head,
.managed-stream-preview,
.streamer-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111;
}

.managed-stream-preview button,
.streamer-preview button { min-width: 120px; margin: 0; }

/* History page */
.history-full-view {
  width: min(1320px, calc(100vw - 72px));
  min-height: calc(100vh - 76px);
  margin: 38px auto;
  padding: 26px 34px 20px;
  display: grid;
  grid-template-columns: 1fr auto minmax(260px, 480px) 1fr;
  gap: 14px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}

.history-full-view h2 {
  grid-column: 1 / -1;
  margin: 0 0 8px;
  text-align: center;
}

.history-full-view .back-button {
  grid-column: 2;
  justify-self: end;
}

.history-full-view .back-button,
#history-search {
  grid-row: 2;
}

.history-full-view .back-button { margin-right: 0; }

.history-controls,
.filter-button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.filter-button-group {
  grid-column: 1 / -1;
}

#history-search {
  grid-column: 3;
  width: min(480px, 100%);
  max-width: none;
  justify-self: stretch;
}

#full-history-list {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 4px;
}

.history-entry {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111;
}
.entry-date { display: block; margin-bottom: 6px; color: var(--muted-2); font-size: 0.82rem; }
.pagination-controls {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

/* Auth/guest */
body:not(.admin-view):not(.manager-view):not(.streamer-view):not(.minecraft-view) #page-layout { display: none; }
body:not(.admin-view):not(.manager-view):not(.streamer-view):not(.minecraft-view) {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  padding-bottom: 9vh;
}

body:not(.admin-view):not(.manager-view):not(.streamer-view):not(.minecraft-view) h1 {
  margin-top: 0;
}

#login { margin-top: 14px; }

/* Minecraft view */
body.minecraft-view {
  height: 100vh;
  overflow: hidden;
  padding: 0;
  background: #000;
  text-align: left;
}

.minecraft-full-view {
  height: 100vh;
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px 18px;
}

.minecraft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.minecraft-header h2 { margin: 0 0 6px; }
.mc-status { display: inline-flex; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-weight: 700; }
.mc-status.online { color: var(--green); border-color: var(--green); }
.mc-status.offline { color: #ff6972; border-color: var(--red); }
.back-button { margin: 0; background: #242424; border-color: #555; }
.minecraft-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.minecraft-actions button { margin: 0; min-width: 140px; }
.minecraft-grid { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.8fr); gap: 14px; }
.minecraft-section { min-width: 0; min-height: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #101010; box-shadow: 0 0 10px rgba(229, 9, 20, 0.32); }
.minecraft-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.minecraft-section-head h3 { margin: 0; }
.minecraft-section-head span { color: var(--muted-2); font-size: 0.8rem; }
.minecraft-console-section { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.minecraft-console,
.minecraft-restore-output { overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: #020202; color: #eee; white-space: pre-wrap; font-size: 0.86rem; line-height: 1.3; scrollbar-width: none; }
.minecraft-console::-webkit-scrollbar,
.minecraft-restore-output::-webkit-scrollbar { display: none; }
.minecraft-command-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
.minecraft-command-row button { margin: 0; }
.minecraft-backup-form { display: grid; gap: 10px; }
.minecraft-restore-output { height: 150px; margin-top: 10px; }

/* Preview toolbar */
#preview-toolbar {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.92);
  box-shadow: 0 0 12px rgba(229, 9, 20, 0.5);
}
#preview-toolbar button { margin: 0; background: #191919; border-color: #555; }
#preview-toolbar button.active { background: var(--red); border-color: var(--red-2); }
body.preview-view #minecraft-btn { display: none !important; }

/* Responsive */
@media (max-width: 1500px) {
  :root { --admin-left-width: 270px; --admin-right-width: 320px; }
  body.admin-view:not(.minecraft-view) #bot-list { grid-template-columns: 1fr; }
  .managed-process-grid { grid-template-columns: repeat(2, minmax(300px, 1fr)); }
}

@media (max-width: 1180px) {
  body.admin-view:not(.minecraft-view) { padding: calc(var(--admin-menu-height) + 14px) 14px 28px; }
  .admin-menu-inner { width: calc(100vw - 28px); }
  body.admin-view:not(.minecraft-view) .left-panel,
  body.admin-view:not(.minecraft-view) .right-panel {
    position: static;
    width: auto;
    max-height: none;
    margin-bottom: 14px;
    border-radius: var(--radius);
  }
  body.admin-view:not(.minecraft-view) .center-panel { margin: 0; }
  .managed-process-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --admin-menu-height: 210px; }
  body { padding: 14px; }
  .admin-menu-inner { gap: 8px; }
  .admin-menu-top,
  .admin-menu-search #search-bar,
  .admin-menu-filters,
  #search-bar,
  .discord-resource-loader,
  .discord-invite-box,
  .message-item,
  .announcement-message-row,
  .minecraft-grid,
  .minecraft-command-row { grid-template-columns: 1fr; }
  .admin-menu-actions,
  .admin-menu-filters,
  #status-filters { justify-content: flex-start; }
  .bot-card,
  body.admin-view:not(.minecraft-view) .bot-card { grid-template-columns: 1fr; }
  .bot-card > button { grid-column: 1; grid-row: auto; width: 100%; }
  .managed-process-meta { grid-template-columns: 1fr; }
  .editor-modal-panel { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  body.manager-view:not(.minecraft-view),
  body.streamer-view:not(.minecraft-view) { padding: 88px 12px 16px; }
}
