:root {
    --bg-primary: hsl(225, 25%, 8%);
    --bg-secondary: hsl(225, 20%, 12%);
    --bg-tertiary: hsl(225, 18%, 16%);
    --bg-glass: hsla(225, 20%, 18%, 0.6);
    --accent-primary: hsl(250, 80%, 65%);
    --accent-secondary: hsl(200, 80%, 55%);
    --accent-success: hsl(145, 65%, 50%);
    --accent-warning: hsl(35, 90%, 55%);
    --accent-danger: hsl(0, 75%, 55%);
    --text-primary: hsl(0, 0%, 92%);
    --text-secondary: hsl(225, 15%, 55%);
    --text-muted: hsl(225, 10%, 40%);
    
    --dept-c-suite: hsl(45, 90%, 55%);
    --dept-infra: hsl(180, 70%, 50%);
    --dept-dev: hsl(280, 70%, 60%);
    --dept-rev: hsl(145, 65%, 50%);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden; /* layout handles scrolling */
}

#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--bg-tertiary);
    display: flex;
    flex-direction: column;
}

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

.logo {
    font-size: 1.2rem;
    font-weight: 700;
}

.ws-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.ws-status.online { background-color: var(--accent-success); box-shadow: 0 0 8px var(--accent-success); }
.ws-status.offline { background-color: var(--accent-danger); }

.sidebar-nav {
    padding: 10px 0;
    flex: 1;
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.nav-item.active {
    border-left: 3px solid var(--accent-primary);
}

.nav-item .icon {
    margin-right: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at top right, hsla(250, 80%, 65%, 0.05), transparent 50%),
                radial-gradient(circle at bottom left, hsla(200, 80%, 55%, 0.05), transparent 50%);
}

#view-container {
    padding: 30px;
    height: 100%;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

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

/* Cards & Utilities */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid hsla(225, 20%, 25%, 0.4);
    border-radius: 12px;
    padding: 20px;
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
}

/* Dashboard View */
.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-card .value {
    font-size: 2rem;
    font-weight: 700;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.section-title {
    font-size: 1.1rem;
    margin-bottom: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Agent Badge Component */
.agent-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    transition: transform 0.2s;
}

.agent-card:hover {
    transform: translateY(-2px);
    border-color: var(--text-muted);
}

.agent-emoji {
    font-size: 2.5rem;
    margin-bottom: 10px;
    position: relative;
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.status-dot.idle { background: var(--accent-success); }
.status-dot.busy { background: var(--accent-warning); animation: pulse-busy 1.5s infinite; }
.status-dot.offline { background: var(--text-muted); }

@keyframes pulse-busy {
    0% { box-shadow: 0 0 0 0 hsla(35, 90%, 55%, 0.4); }
    70% { box-shadow: 0 0 0 8px hsla(35, 90%, 55%, 0); }
    100% { box-shadow: 0 0 0 0 hsla(35, 90%, 55%, 0); }
}

.agent-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.agent-dept {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Event Feed Component */
.event-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.event-item {
    display: flex;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.event-item:last-child {
    border-bottom: none;
}

.event-icon {
    font-size: 1.2rem;
}

.event-content {
    flex: 1;
}

.event-text {
    font-size: 0.85rem;
    line-height: 1.4;
}

.event-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Board View */
.board-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
    overflow-x: auto;
    padding-bottom: 10px;
}

.board-column {
    min-width: 300px;
    max-width: 300px;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bg-tertiary);
}

.column-header {
    padding: 16px;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-count {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.column-body {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Task Card */
.task-card {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.task-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.task-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.task-title {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 12px;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-agent {
    font-size: 1.1rem;
}

/* Badges & Colors */
.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-critical { color: var(--accent-danger); border: 1px solid var(--accent-danger); }
.priority-high { color: var(--accent-warning); }
.priority-medium { color: var(--text-secondary); }
.priority-low { color: var(--accent-success); }

.dept-c-suite { border-left-color: var(--dept-c-suite); }
.dept-infrastructure { border-left-color: var(--dept-infra); }
.dept-development { border-left-color: var(--dept-dev); }
.dept-revenue { border-left-color: var(--dept-rev); }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 8px;
    padding: 10px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background: hsl(250, 80%, 70%);
    border-color: hsl(250, 80%, 70%);
}

.priority-selector {
    display: flex;
    gap: 10px;
}

.priority-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.priority-btn.active.critical { background: hsla(0, 75%, 55%, 0.1); border-color: var(--accent-danger); color: var(--accent-danger); }
.priority-btn.active.high { background: hsla(35, 90%, 55%, 0.1); border-color: var(--accent-warning); color: var(--accent-warning); }
.priority-btn.active.medium { background: hsla(250, 80%, 65%, 0.1); border-color: var(--accent-primary); color: var(--accent-primary); }
.priority-btn.active.low { background: hsla(145, 65%, 50%, 0.1); border-color: var(--accent-success); color: var(--accent-success); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: hsla(225, 25%, 8%, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(0);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-primary);
}

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

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Drag and Drop states */
.task-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.board-column.drag-over {
    background: hsla(250, 80%, 65%, 0.05);
    border-color: var(--accent-primary);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
