/* --- GENERAL AND DESIGN SYSTEM VARIABLES --- */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* HSL Tailored Colors */
  --bg-main: #0b0a0f;
  --bg-sidebar: #110f18;
  --bg-card: rgba(26, 23, 38, 0.4);
  --bg-card-hover: rgba(33, 29, 48, 0.65);
  
  --border-color: rgba(255, 255, 255, 0.06);
  --border-color-focus: rgba(99, 102, 241, 0.4);

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-bright: #ffffff;

  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --secondary: #06b6d4;
  --secondary-glow: rgba(6, 182, 212, 0.15);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  
  --sidebar-width: 260px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- BASE STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* --- APP LAYOUT --- */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 45%);
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  height: 100%;
  z-index: 10;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  padding: 0 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

.logo-area h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.logo-area h2 span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.nav-btn svg {
  transition: var(--transition-smooth);
}

.nav-btn:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.03);
}

.nav-btn.active {
  color: var(--text-bright);
  background: var(--primary-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

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

/* User profile widget in sidebar */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 8px;
  border-top: 1px solid var(--border-color);
}

.avatar {
  width: 40px;
  height: 40px;
  background: #2b253b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--secondary);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

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

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition-smooth);
}

.logout-btn:hover {
  color: var(--danger);
  background: var(--danger-glow);
}

/* --- MAIN CONTENT --- */
.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.content-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

/* --- GENERAL UTILS & COMPONENT SYSTEM --- */
.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.pulse-indicator::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  top: 0;
  left: 0;
  animation: pulse-ring 1.8s infinite;
}

.status-online { background-color: var(--success); }
.status-online::after { background-color: var(--success); }
.status-running { background-color: var(--secondary); }
.status-running::after { background-color: var(--secondary); }
.status-offline { background-color: var(--text-muted); }
.status-offline::after { display: none; }

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.8); opacity: 0; }
}

/* Glassmorphism Panel Container */
.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  backdrop-filter: blur(14px) saturate(160%);
  transition: var(--transition-smooth);
}

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

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
}

/* --- STATS GRID --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(14px) saturate(160%);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nodes-icon { background: var(--primary-glow); color: var(--primary); }
.profiles-icon { background: var(--secondary-glow); color: var(--secondary); }
.sessions-icon { background: var(--success-glow); color: var(--success); }
.slots-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.stat-content h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 2px;
}

/* --- LAYOUTS --- */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

.side-panel {
  display: flex;
  flex-direction: column;
}

/* --- ACTIVE SESSIONS GRID & CARDS --- */
.sessions-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 120px;
}

.session-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: var(--transition-smooth);
}

.session-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.2);
}

.session-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slot-badge {
  background: var(--secondary-glow);
  color: var(--secondary);
  border: 1px solid rgba(6, 182, 212, 0.25);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
}

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

.session-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-bright);
}

.session-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.session-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.session-stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-item .label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-item .val {
  font-weight: 600;
  color: var(--text-main);
  margin-top: 2px;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: var(--danger-glow);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-success {
  background: var(--success-glow);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.btn-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.25);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.btn-black {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: #555555;
  cursor: not-allowed;
}

.btn-black:hover:not(:disabled) {
  background: #000000;
  color: #555555;
  box-shadow: none;
  transform: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- NODE LOADS PANEL --- */
.node-loads-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.node-load-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.node-load-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
}

.node-load-info .name { color: var(--text-main); }
.node-load-info .load { color: var(--text-muted); }

.load-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.load-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  transition: width 0.4s ease;
}

/* --- BROWSER LIVE VIEW PANEL --- */
.browser-frame-container {
  margin-top: 24px;
  background: #0f0e15;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.browser-frame-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #181720;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.browser-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.browser-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-bright);
}

.browser-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.browser-iframe-wrapper {
  width: 100%;
  height: 600px;
  background: #000;
  position: relative;
}

.browser-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- TABLES --- */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.table th, .table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table td {
  color: var(--text-main);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: var(--success-glow); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-danger { background: var(--danger-glow); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-admin { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); margin-left: 8px; vertical-align: middle; }

/* --- MODALS (DIALOGS) --- */
.modal-dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  background: #14131d;
  color: var(--text-main);
  border-radius: 16px;
  padding: 0;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  outline: none;
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.modal-dialog.modal-lg {
  max-width: 800px;
}

.modal-dialog::backdrop {
  background: rgba(5, 4, 8, 0.65);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition-smooth);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-bright);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- FORMS & INPUTS --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-group input, .form-group select, .form-group textarea {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  transition: var(--transition-smooth);
  outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Modern Validation Styling */
.form-group input:not(:placeholder-shown):user-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-glow);
}

.form-group input:not(:placeholder-shown):user-valid {
  border-color: var(--success);
}

.input-helper {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- ANSIBLE LOG CONSOLE --- */
.log-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.log-console {
  background: #050508;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  height: 380px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: #38bdf8; /* Light sky blue console text */
  white-space: pre-wrap;
}

/* --- TABS TRANSITION / UTILS --- */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- AUTH OVERLAY STYLES --- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 8, 0.75);
  backdrop-filter: blur(24px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.auth-logo h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
}

.auth-logo h2 span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.auth-form h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
  line-height: 1.4;
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

.auth-switch {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.auth-switch a:hover {
  color: var(--secondary);
  text-decoration: underline;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: rgba(25, 23, 36, 0.85);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  padding: 16px 20px;
  border-radius: 12px;
  color: var(--text-bright);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 450px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-info {
  border-left: 4px solid var(--secondary);
}

/* --- SSO / MICROSOFT BUTTON STYLES --- */
.btn-sso {
  background: #2f2f2f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-bright);
  font-weight: 600;
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: var(--transition-smooth);
}

.btn-sso:hover {
  background: #3e3e3e;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-sso svg {
  width: 20px;
  height: 20px;
}

