:root {
  --bg-main: #05040a;
  --bg-sidebar: rgba(13, 12, 20, 0.8);
  --bg-card: rgba(22, 21, 31, 0.7);
  --text: #f0f0f8;
  --text-muted: #9494b8;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-grad: linear-gradient(135deg, #8b5cf6, #d946ef);
  --success: #10b981;
  --danger: #ef4444;
  --radius: 16px;
}

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

/* SKJUL SCROLLBARS FOR ET RENERE DESIGN */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(217, 70, 239, 0.05) 0px, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: auto; /* Tillad scroll sidelæns ved zoom */
}

/* ─── SCREENS ─── */
.screen { min-height: 100vh; display: flex; overflow: hidden; }

#dashboard-screen {
    width: 100%;
}

#login-screen {
  align-items: center; justify-content: center;
  background: radial-gradient(circle at center, #13111c 0%, #05040a 100%);
}

.login-box {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  padding: 48px;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  text-align: center;
  width: 100%;
  max-width: 420px;
}

.login-box h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  letter-spacing: -1px;
  margin-bottom: 12px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  backdrop-filter: blur(25px);
  border-right: 1px solid var(--border);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}

@media (max-width: 1100px) {
    .sidebar { width: 80px; padding: 20px 10px; }
}

.sidebar-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 48px;
  padding: 0 12px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-logo .badge {
  font-size: 0.65rem;
  background: var(--accent-grad);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 8px;
  font-family: 'Inter', sans-serif;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; }
.nav-item {
  color: var(--text-muted);
  text-decoration: none;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(4px);
}
.nav-item.active {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.3);
}

.btn--logout {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 12px;
  margin-top: auto;
  font-weight: 600;
  cursor: pointer;
}

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  padding: 40px 60px; /* Tilbage til normalt, luftigt design */
  overflow-y: auto;
  overflow-x: auto;
  height: 100vh;
  background: var(--bg-main);
  position: relative;
}

@media (max-width: 1100px) {
    .main-content { margin-left: 80px; padding: 30px; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 48px; /* Standard afstand */
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}
.topbar h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  font-weight: 800;
  color: #fff;
}
.status-badge {
    white-space: nowrap;
    margin-left: 20px;
}

/* ─── TABLE DESIGN ─── */
.table-container {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.agents-table {
  width: 100%;
  border-collapse: collapse;
}
.agents-table th {
  text-align: left;
  padding: 20px 24px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.agents-table td {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  vertical-align: middle;
}
.agents-table tr:last-child td { border-bottom: none; }
.agents-table tr:hover { background: rgba(255, 255, 255, 0.02); }

.td-avatar img {
  width: 48px; height: 48px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.td-name strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.td-name span { color: var(--text-muted); font-size: 0.85rem; }

/* ─── BUTTONS ─── */
.btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: 'Inter', sans-serif;
}
.btn--primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px 0 rgba(139, 92, 246, 0.39);
}
.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn-icon-tiny {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}
.btn-icon-tiny:hover {
    background: var(--accent);
    color: #fff;
}

.btn--danger {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
.btn--danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn--success {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}
.btn--success:hover { background: rgba(16, 185, 129, 0.2); }

.btn-tiny {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

/* ─── CONTROL CENTER GRID ─── */
.control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 20px;
    animation: fadeIn 0.5s ease-out;
}

/* ─── MODAL ─── */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}
.modal[aria-hidden="false"] { display: flex; }

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(4, 3, 10, 0.85);
  backdrop-filter: blur(16px);
}

.modal-box {
  position: relative;
  background: rgba(20, 18, 29, 0.95);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.8), 
              0 0 0 1px rgba(139, 92, 246, 0.1);
  border-radius: 28px;
  width: 100%;
  max-width: 850px;
  z-index: 1010;
  max-height: 92vh;
  overflow-y: auto;
  padding: 48px;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-box h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  margin-bottom: 32px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-box h4 {
  margin: 32px 0 16px;
  color: var(--accent);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 800;
}

/* ─── FORM ELEMENTS ─── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.form-group label i {
  font-style: normal;
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.6;
}

.form-group input, 
.form-group select, 
.form-group textarea {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
  padding: 16px !important;
  border-radius: 14px !important;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: all 0.15s ease;
  outline: none;
  resize: vertical !important; /* Force resizeable but vertical only */
  min-height: 50px;
}

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

/* Expansion Logic */
.modal-box.is-maximized {
    max-width: 98vw;
    width: 98vw;
    height: 95vh;
    max-height: 95vh;
}
.modal-box.is-maximized .form-grid,
.modal-box.is-maximized .form-divider,
.modal-box.is-maximized h3,
.modal-box.is-maximized h4,
.modal-box.is-maximized .form-group:not(.form-group--full) {
    display: none;
}
.modal-box.is-maximized .form-group--full {
    height: 100%;
}
.modal-box.is-maximized textarea {
    height: 70vh !important;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    line-height: 1.6;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ─── CUSTOM SCROLLBAR ─── */
.modal-box::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  background: transparent;
}
.modal-box::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 10px;
}
.modal-box::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ─── ANIMATIONS ─── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── HEARTBEAT CARDS ─── */
.log-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--agent-color, var(--accent));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slideIn 0.3s ease-out;
  box-shadow: 0 4px 15px -10px var(--agent-color, transparent);
}
.log-card:hover { 
  transform: translateX(8px); 
  background: rgba(255, 255, 255, 0.04); 
  box-shadow: 0 10px 30px -15px var(--agent-color, rgba(0,0,0,0.5));
}

.log-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.log-time {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.log-msg {
    line-height: 1.5;
    font-size: 0.9rem;
    color: var(--text);
}

/* ─── STATUS PILLS ─── */
.status-pill {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 6px;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
    vertical-align: middle;
}
.status-pill--success { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.status-pill--info { background: rgba(139, 92, 246, 0.15); color: var(--accent); border: 1px solid rgba(139, 92, 246, 0.3); }
.status-pill--warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.status-pill--danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* ─── LIVE PULSE ─── */
.status-badge.live {
    position: relative;
    padding-left: 28px;
}
.status-badge.live::before {
    content: '';
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    width: 8px; height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-card--info { border-left-color: var(--accent); }
.log-card--success { border-left-color: var(--success); }
.log-card--warning { border-left-color: #f59e0b; }
.log-card--danger { border-left-color: var(--danger); }

/* ─── PREMIUM ERROR / LOCKED STATE (v3.4.4) ─── */
.error-card-premium {
    background: rgba(239, 68, 68, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.error-icon-box {
    width: 64px; height: 64px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-size: 2rem;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
    animation: pulse-red 2s infinite;
}

.error-card-premium h3 {
    background: linear-gradient(135deg, #fff, #9494b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.error-card-premium p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.btn--retry {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.btn--retry:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-20px); }

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ─── RESPONSIVE ZOOM CORRECTIONS ─── */
@media (max-width: 1100px) {
    .sidebar { width: 80px; padding: 20px 10px; }
    .sidebar-logo, .nav-item span { display: none; }
    .nav-item { justify-content: center; font-size: 1.5rem; }
}

@media (max-height: 700px) {
    .topbar { margin-bottom: 24px; }
    .main-content { padding: 24px; }
}
    width: 100%;
    height: 1200px;
    background: radial-gradient(circle at center, #0f0e1a 0%, #05040a 100%);
    border-radius: 24px;
    border: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 20px;
    padding-bottom: 50px;
}

/* Forbindelses-linjer (SVG) */
.engine-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.engine-line {
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-opacity: 0.3;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: dash 5s linear forwards;
}

@keyframes dash {
  to { stroke-dashoffset: 0; }
}

    /* Layout logic for nodes */
    .agent-node {
        cursor: pointer;
        transition: transform 0.2s, filter 0.2s;
        z-index: 10;
    }
    .agent-node:hover {
        transform: scale(1.05);
        filter: brightness(1.2);
    }
    .agent-node:active {
        transform: scale(0.98);
    }
    
    /* Resizable textarea for prompts */
    .modal-body textarea {
        min-height: 400px;
        resize: vertical;
        line-height: 1.5;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.85rem;
    }

/* Agent Noder */
.agent-node {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.agent-node:hover {
    transform: scale(1.15);
    z-index: 100;
}

.node-avatar {
    width: 50px; height: 50px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    object-fit: cover;
    background: #000;
    transition: transform 0.3s;
}

.node-box {
    margin-top: -15px;
    width: 140px;
    background: rgba(15, 14, 26, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px 8px 8px 8px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.node-name {
    font-size: 0.75rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-role {
    font-size: 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* C-SUITE SPECIFIK */
.node-c-suite .node-box {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.1);
}

.node-c-suite .node-avatar {
    width: 60px; height: 60px;
}

/* CEO Node (SPECIAL) */
.ceo-node { width: 160px; }
.ceo-node .node-avatar {
    width: 80px; height: 80px;
    border-color: #fff;
    box-shadow: 0 0 30px rgba(255,255,255,0.4);
}
.ceo-node .node-box {
    width: 160px;
    border-color: #fff;
    padding-top: 25px;
}
.ceo-node .node-role { color: #fff; }

/* ─── ENGINE POPUP REMASTERED ─── */
.engine-popup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    background: rgba(18, 17, 28, 0.9);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 28px;
    padding: 32px;
    z-index: 2000;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8), 0 0 20px rgba(139, 92, 246, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-header-premium {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.popup-avatar {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    object-fit: cover;
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.popup-header-text h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    margin: 0;
    color: #fff;
}

.popup-title {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-log {
    margin: 24px 0;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.6;
}

.popup-log strong {
    color: #fff;
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.popup-actions {
    margin-top: 24px;
}

/* ─── BADGE COLORS ─── */
.cand-badge--available { background: var(--success) !important; color: white !important; }
.cand-badge--top { background: #f59e0b !important; color: white !important; }
.cand-badge--busy { background: var(--danger) !important; color: white !important; }

/* ─── SELECT REPAIR ─── */
select option {
  color: #000; /* Sikrer sort tekst i den lyse system-dropdown */
  background: #fff;
}
