:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-human: #38bdf8; /* Sky Blue */
    --accent-agent: #c084fc; /* Purple */
    --border-color: #334155;

    /* These were missing or not resolving */
    --success: #22c55e;      /* Green */
    --warning: #f59e0b;      /* Amber/Orange */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    overflow: hidden; /* Prevent scrolling on body, map scrolls internally */
    height: 100vh;
}

/* --- Layout Components --- */

.org-map {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: radial-gradient(circle at center, #1e293b 1px, transparent 1px) 0 0/20px 20px;
}

svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

path {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 2;
}

/* --- Sidebar --- */

.sidebar {
    position: absolute;
    right: 20px;
    top: 80px;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    height: 600px;
}

.drag-handle {
    background: #334155;
    padding: 10px;
    cursor: grab;
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}
.drag-handle:active { cursor: grabbing; }

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* --- Node / Card Styles --- */

.node {
    position: absolute;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 300px;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.5);
    z-index: 10;
    transition: border-color 0.2s;
}

.human-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.avatar {
    width: 32px;
    height: 32px;
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-human);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

/* --- Role Chips --- */

.role-chip {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.role-chip:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-agent);
}

.role-chip.active {
    border-color: var(--accent-human);
    background: rgba(56, 189, 248, 0.1);
}

.role-title {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.agent-status {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* --- Edit Mode & Toolbar --- */

.toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    border: 1px solid #334155;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    gap: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 1000;
}

.btn-tool {
    background: transparent;
    border: 1px solid #475569;
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-tool:hover { background: #334155; color: #fff; }
.btn-tool.primary { background: var(--accent-human); color: #0f172a; border-color: var(--accent-human); font-weight: bold; }
.btn-tool.active { background: var(--accent-agent); color: #fff; border-color: var(--accent-agent); }

.node-actions {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #334155;
    text-align: center;
}

.body-editing .node-actions { display: block; }
.body-editing .role-chip { border-style: dashed; }
.body-editing .node { border-color: var(--accent-agent); }

.btn-add-role {
    width: 100%;
    background: #1e293b;
    border: 1px dashed #475569;
    color: #94a3b8;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
}
.btn-add-role:hover { border-color: var(--accent-agent); color: var(--accent-agent); }

/* --- Modals --- */

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: none; justify-content: center; align-items: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
}
.modal {
    background: #1e293b;
    border: 1px solid #475569;
    width: 400px;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}
.modal h2 { margin-top: 0; color: #fff; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; color: #94a3b8; font-size: 0.8rem; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; box-sizing: border-box;
    background: #0f172a; border: 1px solid #334155;
    color: #fff; padding: 8px; border-radius: 4px;
    font-family: inherit;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* --- Evidence & Audit Logs --- */

.evidence-card {
    margin-top: 10px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    color: #cbd5e1;
}

.evidence-metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}
.bar-bg { width: 100%; height: 4px; background: #334155; margin-top:2px; }
.bar-fill { height: 100%; background: var(--accent-agent); }

/* Animation for updates */
@keyframes flash-green {
    0% { background-color: rgba(34, 197, 94, 0.4); }
    100% { background-color: transparent; }
}
.log-entry.new { animation: flash-green 1s ease-out; }


/* --- Drag & Drop Reassignment Styles --- */

/* The chip being dragged */
.role-chip.dragging {
    opacity: 0.5;
    border-color: var(--accent-human);
    background: rgba(56, 189, 248, 0.1);
}

/* The target node when hovering over it */
.node.drag-over {
    border-color: var(--success);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
    transform: scale(1.02);
}

/* Prevent the text inside chips from interfering with drag events */
.role-chip * {
    pointer-events: none;
}

/* --- Agent Simulation Styles --- */

/* The pulsing "Scanning" effect */
@keyframes pulse-purple {
    0% { box-shadow: 0 0 0 0 rgba(192, 132, 252, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(192, 132, 252, 0); }
    100% { box-shadow: 0 0 0 0 rgba(192, 132, 252, 0); }
}

.agent-scanning .status-dot {
    background: var(--accent-agent) !important;
    animation: pulse-purple 1.5s infinite;
}

.agent-scanning .agent-status {
    color: var(--accent-agent);
    font-style: italic;
}

/* --- Delete Role Button (Edit Mode) --- */
.btn-delete-role {
    display: none; /* Hidden by default */
    position: absolute;
    right: -8px;
    top: -8px;
    background: #ef4444;
    color: white;
    border: 1px solid #991b1b;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 20;
    align-items: center;
    justify-content: center;
}

/* Only show delete button in Edit Mode */
.body-editing .btn-delete-role {
    display: flex;
}
.body-editing .role-chip {
    position: relative; /* For absolute positioning of delete button */
}


/* --- Task Queue Styles (Sidebar) --- */
.task-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.task-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.task-input {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-add-task {
    background: #334155;
    color: #fff;
    border: 1px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 10px;
}
.btn-add-task:hover { background: var(--accent-human); color: #000; border-color: var(--accent-human); }

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid var(--text-muted);
    padding: 8px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-item.pending { border-left-color: var(--warning); }
.task-item.done { border-left-color: var(--success); opacity: 0.6; text-decoration: line-through; }

/* Task Badge on the Card */
.task-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-human);
    color: #000;
    font-size: 0.65rem;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #fff;
    z-index: 15;
}


/* --- DASHBOARD (PLAYER MODE) STYLES --- */

/* The main dashboard container (hidden by default) */
#dashboard-view {
    display: none; /* Hidden until login */
    padding: 40px;
    height: 100vh;
    box-sizing: border-box;
    overflow-y: auto;
    background: var(--bg-color);
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Main Content | Sidebar */
    gap: 20px;
}

/* Widgets */
.dash-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.dash-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 15px;
    font-weight: 600;
}

/* Agent Control Row */
.agent-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.03);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid var(--accent-agent);
}

.agent-control-row.warning { border-left-color: var(--warning); }
.agent-control-row.success { border-left-color: var(--success); }

/* Stats Big Numbers */
.stat-box {
    display: flex;
    gap: 40px;
    margin-bottom: 20px;
}
.stat-item { text-align: center; }
.stat-num { font-size: 2rem; font-weight: bold; color: var(--text-main); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* Back Button */
.btn-back {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
}
.btn-back:hover { background: #334155; color: #fff; }


/* --- STRATEGY LAYER STYLES --- */

/* The Container for Objectives (sits above the org chart) */
.strategy-layer {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 20px 0 60px 0; /* Extra bottom padding for connector space */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 5;
}

/* The Objective Card */
.objective-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--accent-human);
    border-top: 3px solid var(--accent-human);
    border-radius: 8px;
    width: 220px;
    padding: 15px;
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    position: relative; /* For connector anchoring */
}

.obj-title {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--accent-human);
}

.obj-progress-bg {
    background: #334155;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.obj-progress-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 1s ease-out;
}

.obj-meta {
    font-size: 0.7rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
}

/* Alignment Lines (Strategy -> Role) */
path.alignment-line {
    stroke: var(--accent-human);
    stroke-width: 1.5;
    stroke-dasharray: 5, 5; /* Dashed line */
    opacity: 0.4;
}

/* Add to your toolbar styles */
.btn-tool.strategy {
    border-color: var(--accent-agent);
    color: var(--accent-agent);
}
.btn-tool.strategy:hover {
    background: var(--accent-agent);
    color: #fff;
}


/* --- COCKPIT STYLES --- */

.cockpit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 120px);
}

.cockpit-col {
    background: #1e293b;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.col-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

.task-container {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

/* Card Styles */
.work-card {
    background: #0f172a;
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    position: relative;
    transition: transform 0.2s;
}

.work-card:hover { transform: translateY(-2px); border-color: var(--accent-human); }

.work-card.agent-card { border-left: 3px solid var(--accent-agent); }
.work-card.review-card { border-left: 3px solid var(--warning); }

.card-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
}

.badge {
    background: #334155;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}
.badge.warning { background: var(--warning); color: #000; }

.btn-block {
    width: 100%;
    padding: 15px;
    background: var(--accent-agent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 0 0 12px 12px;
}
.btn-block:hover { opacity: 0.9; }

.empty-state {
    color: #475569;
    text-align: center;
    font-style: italic;
    margin-top: 40px;
}