/* --- ENERGY RADIO OS: TACTICAL STYLESHEET --- */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700;800&family=Roboto+Mono:wght@400;700&display=swap');

:root {
  --sidebar-w: 260px;
  --bg-deep: #020205;
  --panel-bg: #0a0a0c;
  --border-line: rgba(255, 255, 255, 0.1); 
  --accent: #F37720;
  --cyan: #00f0ff;
  --text-main: #ffffff;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
  --danger: #ef4444;
  --diff-bg: rgba(0,0,0,0.3);
  --diff-border: rgba(255, 255, 255, 0.1);
  --diff-add-bg: rgba(0, 240, 255, 0.05);
  --diff-add-text: #00f0ff;
  --diff-del-bg: rgba(239, 68, 68, 0.05);
  --diff-del-text: #ef4444;
  --diff-same-text: #6b7280;
}

/* === CUSTOM TACTICAL SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); border-left: 1px solid var(--border-line); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) var(--bg-deep); }

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

html, body {
  width: 100%; max-width: 100vw; margin: 0; padding: 0;
  background-color: var(--bg-deep); 
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px; color: var(--text-main);
  font-family: 'Chakra Petch', sans-serif; overflow-x: hidden !important;
}
body { display: flex; height: 100vh; flex-direction: column; }

/* DUAL-STATE ARCHITECTURE LOGIC */
body.admin-active { flex-direction: row; }
#publicHeader { display: flex; }
.gl-sidebar, .mobile-topbar { display: none !important; }

/* Hide internal admin components from Public View */
body:not(.admin-active) .header-banner { display: none !important; }

/* Hide Public components from Admin View */
body.admin-active #publicHeader { display: none !important; }
body.admin-active .gl-sidebar { display: flex !important; }

/* CLIPPING & ANIMATIONS */
.clip-panel { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%); }
.clip-button { clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px); }
.clip-card { clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%); }
.marquee-container { width: 100%; overflow: hidden; white-space: nowrap; position: relative; }
.animate-marquee { display: inline-block; padding-left: 100%; animation: marquee 20s linear infinite; }
@keyframes marquee { 0% { transform: translate(0, 0); } 100% { transform: translate(-100%, 0); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }

/* SIDEBAR */
.gl-sidebar {
  width: var(--sidebar-w); background: var(--bg-deep); border-right: 1px solid var(--border-line);
  padding: 0; flex-direction: column; z-index: 2000; flex-shrink: 0;
}
.gl-brand { font-size: 1.5rem; font-weight: 800; letter-spacing: 2px; padding: 30px 25px 20px 25px; color: #fff; display: flex; flex-direction: column; }
.gl-brand-sub { font-size: 0.6rem; color: var(--accent); letter-spacing: 2px; font-family: 'Roboto Mono', monospace; margin-top: 5px; }
.gl-nav-header { font-size: 0.7rem; color: var(--text-muted); padding: 20px 25px 10px 25px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.gl-nav { display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none; }
.gl-nav::-webkit-scrollbar { display: none; }
.gl-nav a { color: var(--text-dim); text-decoration: none; padding: 12px 25px; font-size: 0.9rem; font-weight: 600; transition: all 0.2s ease; text-transform: uppercase; letter-spacing: 1px; border-left: 3px solid transparent; display: flex; align-items: center; gap: 15px; }
.gl-nav a:hover, .gl-nav a.active { background: rgba(255, 255, 255, 0.03); color: var(--text-main); border-left: 3px solid var(--accent); }
.sidebar-footer { margin-top: auto; font-family: 'Roboto Mono', monospace; font-size: 0.65rem; color: var(--text-muted); border-top: 1px solid var(--border-line); padding: 20px 25px; text-transform: uppercase; letter-spacing: 1px; }

/* MAIN CONTENT */
.gl-main { flex: 1; overflow-y: auto; padding: 40px 50px; width: 100%; }

/* HEADER BLOCK */
.header-banner { background: linear-gradient(90deg, rgba(243, 119, 32, 0.1) 0%, transparent 100%); border-left: 4px solid var(--accent); padding: 25px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.operator-id { color: var(--text-dim); font-size: 0.85rem; font-family: 'Roboto Mono', monospace; margin-bottom: 5px; text-transform: uppercase;}
.operator-id span { color: #fff; font-weight: 700; }
.header-banner h1 { margin: 0; font-size: 1.5rem; color: #fff; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.header-banner h1 span { color: var(--accent); }
.auth-box { display: flex; gap: 15px; align-items: center; font-size: 0.7rem; font-family: 'Roboto Mono', monospace; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: var(--text-dim);}
.auth-box span i { color: #22c55e; margin-right: 5px; animation: pulse 2s infinite; }

/* TELEMETRY TOP CARDS */
.telemetry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--panel-bg); border: 1px solid var(--border-line); padding: 25px; position: relative; transition: border-color 0.3s ease; }
.stat-card:hover { border-color: var(--accent); }
.stat-card .title { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 5px; }
.stat-card .value { font-size: 2.2rem; font-weight: 800; color: #fff; margin-bottom: 10px; line-height: 1; word-break: break-all;}
.stat-card .sub { font-size: 0.6rem; font-family: 'Roboto Mono', monospace; color: var(--accent); text-transform: uppercase; letter-spacing: 1px;}

/* CHARTS GRID */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 20px; margin-bottom: 30px; }
.chart-card { background: var(--panel-bg); border: 1px solid var(--border-line); padding: 5px; }
.chart-inner { background: rgba(0,0,0,0.3); padding: 25px; height: 100%; }
.chart-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-line); padding-bottom: 15px; margin-bottom: 25px; }
.chart-header h3 { margin: 0; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: #fff; display: flex; align-items: center; gap: 10px; }
.chart-header h3::before { content: ''; display: block; width: 4px; height: 16px; background: var(--accent); }
.chart-header .data-vis { font-size: 0.6rem; font-family: 'Roboto Mono', monospace; color: var(--text-muted); }
.chart-container { position: relative; height: 250px; width: 100%; display: flex; justify-content: center; }

/* STANDARD CARDS */
.card { background: var(--panel-bg); border: 1px solid var(--border-line); padding: 30px; margin-bottom: 25px; width: 100%; }
details.card > summary { list-style: none; cursor: pointer; outline: none; }
details.card > summary::-webkit-details-marker { display: none; }
h2 { font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: #fff; border-bottom: 1px solid var(--border-line); padding-bottom: 15px; margin-top: 0; margin-bottom: 25px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ''; display: block; width: 4px; height: 16px; background: var(--accent); }

/* BUTTONS */
button, .button { background: transparent; color: #fff; border: 1px solid var(--border-line); border-radius: 2px; padding: 10px 20px; cursor: pointer; font-family: 'Chakra Petch', sans-serif; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; transition: 0.2s; }
button:hover:not(:disabled) { background: rgba(243, 119, 32, 0.1); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.3; cursor: not-allowed; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.auth-box button { font-size: 0.7rem; padding: 6px 12px; }

/* TABS */
.backup-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-line); margin-bottom: 20px; }
.backup-tabs .tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-dim); padding: 12px 20px; text-transform: uppercase; font-family: 'Chakra Petch', sans-serif; cursor: pointer; font-weight: 700; font-size: 0.85rem; letter-spacing: 1px;}
.backup-tabs .tab:hover { color: #fff; border-color: transparent;}
.backup-tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane.hidden { display: none !important; }

/* FORMS & TABLES */
input, select, textarea { background: rgba(0,0,0,0.5); border: 1px solid var(--border-line); color: #fff; font-family: 'Roboto Mono', monospace; border-radius: 2px; padding: 12px 15px; transition: 0.3s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 15px 25px; align-items: center; margin-bottom: 15px;}
.form-grid > label { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 1px;}
.form-grid > .field { display: flex; gap: 10px; align-items: center; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table th { color: var(--text-dim); text-transform: uppercase; font-size: 0.7rem; font-weight: 700; padding-bottom: 15px; text-align: left; letter-spacing: 1px; border-bottom: 1px solid var(--border-line);}
table td { padding: 15px 10px; border-bottom: 1px solid var(--border-line); font-family: 'Roboto Mono', monospace; color: #fff; word-break: break-all;}
.reveal { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; }
.reveal .mask-dots { flex-grow: 1; }

/* UTILITIES */
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.admin-banner { display: block; border: 1px solid var(--accent); padding: 15px; background: rgba(243, 119, 32, 0.05); color: var(--accent); font-family: 'Roboto Mono', monospace; font-size: 0.85rem; border-radius: 2px; margin-bottom: 30px !important; }
.admin-banner.danger { border-color: var(--danger); background: rgba(239, 68, 68, 0.05); color: var(--danger); }
.warn-inline { color: var(--danger); border-left: 3px solid var(--danger); padding: 8px 12px; font-size: 0.85rem; margin-top: 10px; background: rgba(239, 68, 68, 0.05); font-family: 'Roboto Mono', monospace;}
.empty-note { color: var(--text-dim); font-family: 'Roboto Mono', monospace; font-size: 0.85rem;}
.row { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; width: 100%; align-items: center;}
.theme-toggle { display: none; }
#status { font-family: 'Roboto Mono', monospace; background: rgba(0,0,0,0.5); padding: 20px; border: 1px solid var(--border-line); max-height: 300px; overflow-y: auto; font-size: 0.85rem; color: var(--text-dim); white-space: pre-wrap;}
.inline-editor { border: 1px solid var(--border-line); padding: 25px; background: rgba(0,0,0,0.5); margin-top: 20px; border-left: 3px solid var(--cyan);}
.tag { font-family: 'Roboto Mono', monospace; font-size: 0.65rem; font-weight: 700; padding: 2px 6px; border: 1px solid var(--border-line); color: var(--text-dim); text-transform: uppercase; margin-right: 5px; display: inline-block;}

/* MOBILE OVERRIDE (< 1024px) */
@media (max-width: 1024px) {
  body.admin-active { display: block; height: auto; }
  
  body.admin-active .mobile-topbar { display: flex !important; justify-content: space-between; align-items: center; padding: 15px 20px; background: var(--panel-bg); border-bottom: 1px solid var(--border-line); position: sticky; top: 0; z-index: 1500; width: 100%; }
  body.admin-active .mobile-topbar .gl-brand { margin: 0; font-size: 1.2rem; padding: 0; font-weight: 800; letter-spacing: 2px; color: #fff;}
  body.admin-active .hamburger { background: transparent !important; border: none !important; color: var(--accent) !important; font-size: 1.5rem !important; padding: 0 !important; width: auto !important; min-height: auto !important; }
  
  .nav-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 1600; }
  .nav-overlay.open { display: block; }

  body.admin-active .gl-sidebar { position: fixed !important; top: 0; left: -280px; height: 100vh; width: 280px; transition: left 0.3s ease; box-shadow: 10px 0 50px #000; }
  body.admin-active .gl-sidebar.open { left: 0; }

  .gl-main { padding: 20px 15px; width: 100%; }
  .header-banner { flex-direction: column; align-items: flex-start; gap: 15px; }
  .auth-box { width: 100%; flex-wrap: wrap; justify-content: flex-start;}

  .chart-grid { grid-template-columns: 1fr; }
  .card { padding: 20px !important; margin-bottom: 20px !important; }

  table, thead, tbody, th, td, tr { display: block; width: 100%; }
  thead { display: none; } 
  tr { margin-bottom: 20px; border: 1px solid var(--border-line); padding: 15px; background: rgba(0,0,0,0.3); border-radius: 4px;}
  td { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border: none !important; padding: 10px 0 !important; border-bottom: 1px solid rgba(255,255,255,0.05) !important; font-size: 0.95rem; word-break: break-all;}
  td:last-child { border: none !important; padding-top: 15px !important; flex-direction: column; gap: 10px;}

  #worldsTable td:nth-child(1)::before, #worldsTable td:nth-child(2)::before, #worldsTable td:nth-child(3)::before, #worldsTable td:nth-child(4)::before, #backupsTable td:nth-child(1)::before, #backupsTable td:nth-child(2)::before, #gameBackupsTable td:nth-child(1)::before, #gameBackupsTable td:nth-child(2)::before { color: var(--text-dim); font-size: 0.65rem; font-weight: 700; margin-bottom: 2px; font-family: 'Chakra Petch', sans-serif; letter-spacing: 1px; }
  #worldsTable td:nth-child(1)::before { content: "SIGNATURE"; } #worldsTable td:nth-child(2)::before { content: "DESIGNATION"; } #worldsTable td:nth-child(3)::before { content: "PARAMETERS"; } #worldsTable td:nth-child(4)::before { content: "ENGINE"; }
  #backupsTable td:nth-child(1)::before, #gameBackupsTable td:nth-child(1)::before { content: "TIMESTAMP / ID"; } #backupsTable td:nth-child(2)::before, #gameBackupsTable td:nth-child(2)::before { content: "DATA MASS"; }

  .form-grid { display: flex !important; flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
  .form-grid > label { margin-bottom: -5px; }
  textarea { height: 140px !important; }
  
  /* --- FIXED: Safely exempt the top header button from standard mobile button stretching --- */
  input, select, button:not(.reveal-btn):not(#pubSignInBtn):not(#hamburgerBtn), .btn-link:not(.reveal-btn) { width: 100% !important; min-height: 48px; text-align: center;}
  
  .reveal-btn { width: auto !important; padding: 6px 16px !important; min-height: auto !important; }
  #pubSignInBtn { width: auto !important; min-height: 0 !important; }
  
  .backup-tabs .tab { width: 50% !important; padding: 10px; font-size: 0.75rem; text-align: center; }
  .row { flex-direction: column; gap: 10px; }
}
