:root {
  /* ARES AI DESIGN SYSTEM - Mission Control Aesthetics */
  --bg-core: #09090b;
  --bg-card: rgba(17, 17, 19, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --primary: #3b82f6; /* Tactical Blue */
  --secondary: #8b5cf6; /* Neural Purple */
  --success: #10b981; /* Metric Stable */
  --warning: #f59e0b; /* Anomaly Warning */
  --danger: #ef4444; /* Breach Threat */
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-width: clamp(220px, 18vw, 320px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-core);
  color: var(--text);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow: hidden; /* Main container handles scroll */
}

/* Luxury Biometric Overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('https://www.transparenttextures.com/patterns/carbon-fibre.png');
    opacity: 0.1;
    pointer-events: none;
    z-index: -1;
}

/* --- AUTH UI --- */
#login-container {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg-core);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 400px;
  padding: 3rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--panel-shadow);
  text-align: center;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-family: var(--font-main);
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

select option {
    background: #111;
    color: white;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.btn-secondary { background: var(--secondary); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); }

/* --- MAIN LAYOUT --- */
#dashboard-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-banner {
  height: 60px;
  background: rgba(10, 10, 12, 0.95);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 200;
}

.app-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: 
    linear-gradient(rgba(10, 10, 12, 0.9), rgba(10, 10, 12, 0.98)),
    url('brand/icon.svg'),
    url('https://www.transparenttextures.com/patterns/carbon-fibre.png');
  background-size: cover, cover, auto;
  background-position: center, center, center;
  background-repeat: no-repeat, no-repeat, repeat;
  border-right: 1px solid var(--glass-border);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  white-space: nowrap;
}

.sidebar.collapsed {
  width: 70px;
  padding: 2rem 0;
  align-items: center;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed #user-profile div:last-child,
.sidebar.collapsed .ai-hud {
  display: none;
}

.sidebar.collapsed .nav-item {
  padding: 0.8rem;
  justify-content: center;
  width: 45px;
}

.sidebar.collapsed .brand {
  justify-content: center;
  gap: 0;
}

.sidebar.collapsed #user-profile {
  justify-content: center;
  padding: 0.5rem 0;
}

.brand {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand span { color: var(--primary); }

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-item.active {
  color: var(--primary);
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 1rem 0 0.2rem 0.8rem;
    opacity: 0.7;
}

.nav-section-label:first-of-type {
    margin-top: 0;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}

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

.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

/* --- MACHINE VIEW --- */
.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
  gap: 2rem;
}

.machine-card {
  padding: 1.5rem;
  transition: 0.3s;
}

.machine-card:hover { border-color: rgba(59, 130, 246, 0.4); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-offline { background: var(--danger); }

.metric-mini {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.6rem;
  border-radius: 8px;
  text-align: center;
}

.metric-mini span:first-child { font-size: 0.6rem; color: var(--text-muted); display: block; text-transform: uppercase; }
.metric-mini span:last-child { font-size: 1rem; font-weight: 700; font-family: var(--font-mono); }

/* --- DATA TABLES --- */
.table-container {
  overflow-x: auto;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: auto !important;
}

th {
  text-align: left;
  padding: 0.45rem 0.6rem !important;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  cursor: pointer;
  line-height: 1.25 !important;
  vertical-align: middle !important;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
  box-sizing: border-box;
}

th:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.04);
}

tr {
  height: auto !important;
}

tbody tr:hover, tbody tr.clickable-row:hover {
  background: rgba(139, 92, 246, 0.12) !important;
  cursor: pointer;
}

td {
  padding: 0.45rem 0.6rem !important;
  border-top: 1px solid var(--glass-border);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  vertical-align: middle !important;
  line-height: 1.3 !important;
  font-size: 0.8rem !important;
  box-sizing: border-box;
}

/* Universal Log Trail Payload Wrapping */
td.payload-cell, .td-payload {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  max-width: none !important;
  line-height: 1.4 !important;
  vertical-align: middle !important;
}

/* High-Visibility Vibrant Pagination Buttons */
.btn-pagination {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  font-size: 0.8rem !important;
  padding: 0.5rem 1.4rem !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.btn-pagination:hover:not(:disabled) {
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.55) !important;
  filter: brightness(1.15) !important;
}

.btn-pagination:disabled {
  background: rgba(255, 255, 255, 0.08) !important;
  color: rgba(255, 255, 255, 0.35) !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: 0.45 !important;
}

.resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  cursor: col-resize;
  user-select: none;
  height: 100%;
  z-index: 10;
  transition: background-color 0.15s ease;
}

.resizer:hover, .resizing .resizer {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.dragging { opacity: 0.5; background: rgba(59, 130, 246, 0.1); }
.drag-over { border-left: 2px solid var(--primary) !important; }

.badge {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--primary); }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-crit { background: rgba(239, 68, 68, 0.2); color: var(--danger); box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }

/* --- MODALS --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 2.5rem;
  overflow-y: auto;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* --- LOGS --- */
.log-stream {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.4;
  height: 400px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  padding: 1rem;
  border-radius: 12px;
}

.log-entry { margin-bottom: 0.4rem; padding: 0.2rem 0; border-bottom: 1px solid rgba(255, 255, 255, 0.02); }
.log-ts { color: var(--primary); margin-right: 0.8rem; }
.log-src { color: var(--secondary); margin-right: 0.8rem; font-weight: 700; }

.hidden { display: none !important; }

/* AI HUD */
.ai-hud {
  width: 100%;
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.ai-pulse {
    width: 12px;
    height: 12px;
    background: var(--secondary);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--secondary);
    animation: brain-throb 3s infinite;
}

@keyframes brain-throb {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.4); opacity: 0.4; }
    100% { transform: scale(1); opacity: 0.8; }
}

.ai-thought {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.5;
  padding: 1.5rem;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 16px;
  position: relative;
}

.ai-thought:after {
  display: none;
}

/* User Submenu Styles */
.user-submenu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary);
}

.modal-overlay {
    backdrop-filter: blur(8px);
}

.modal {
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
}

/* --- SYSTEM STATUS ANIMATIONS --- */
@keyframes pulse-status {
  0% { transform: scale(1); box-shadow: 0 0 5px currentColor; }
  50% { transform: scale(1.3); box-shadow: 0 0 15px currentColor; }
  100% { transform: scale(1); box-shadow: 0 0 5px currentColor; }
}
