/* ═══════════════════════════════════════════════════════════════════════════
   SOLVUH CONSOLE - CSS
   Unified console styling with tabbed tree sidebar
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR TABS
   ═══════════════════════════════════════════════════════════════════════════ */
.tab-btn {
    color: #71717a;
    position: relative;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: #a1a1aa;
    background: rgba(39, 39, 42, 0.5);
}

.tab-btn.active {
    color: #e4e4e7;
    border-bottom-color: #22C55E;
    background: linear-gradient(to bottom, rgba(34, 197, 94, 0.1), transparent);
}

.tab-btn .tab-badge {
    display: block;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TREE STRUCTURE
   ═══════════════════════════════════════════════════════════════════════════ */
.tree-node {
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.tree-node-header:hover {
    background: rgba(39, 39, 42, 0.8);
}

.tree-node-header.active {
    background: rgba(34, 197, 94, 0.15);
    border-left: 2px solid #22C55E;
    margin-left: -2px;
}

.tree-node-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.tree-node-chevron {
    width: 16px;
    height: 16px;
    color: #52525b;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.tree-node-chevron.expanded {
    transform: rotate(90deg);
}

.tree-node-label {
    flex: 1;
    font-size: 13px;
    color: #d4d4d8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node-badge {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(39, 39, 42, 0.8);
    color: #a1a1aa;
    flex-shrink: 0;
}

.tree-node-badge.urgent {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.tree-node-badge.warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.tree-node-badge.success {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.tree-node-badge.info {
    background: rgba(6, 182, 212, 0.2);
    color: #06b6d4;
}

.tree-node-children {
    padding-left: 16px;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
}

.tree-node-children.collapsed {
    max-height: 0;
}

/* Indent lines for tree */
.tree-node-children {
    position: relative;
}

.tree-node-children::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 8px;
    width: 1px;
    background: #27272a;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AGENT STATUS INDICATORS
   ═══════════════════════════════════════════════════════════════════════════ */
.agent-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

.agent-status.working {
    background: rgba(6, 182, 212, 0.2);
    color: #06b6d4;
}

.agent-status.complete {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.agent-status.blocked {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.agent-status.idle {
    background: rgba(113, 113, 122, 0.2);
    color: #71717a;
}

.agent-status.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Pulsing dot for active agents */
.agent-status .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BARS
   ═══════════════════════════════════════════════════════════════════════════ */
.progress-bar {
    height: 4px;
    background: #27272a;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease-out;
}

.progress-bar-fill.animated {
    background: linear-gradient(90deg, #22C55E 0%, #4ADE80 50%, #22C55E 100%);
    background-size: 200% 100%;
    animation: progress-flow 1.5s linear infinite;
}

@keyframes progress-flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   APPROVAL CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.approval-card {
    transition: border-color 0.2s, transform 0.15s;
}

.approval-card:hover {
    transform: translateY(-1px);
}

.approval-card.urgent {
    border-left: 3px solid #f87171;
}

.approval-card.warning {
    border-left: 3px solid #fbbf24;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VIEW TRANSITIONS
   ═══════════════════════════════════════════════════════════════════════════ */
.view-enter {
    animation: view-slide-in 0.2s ease-out;
}

@keyframes view-slide-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-exit {
    animation: view-slide-out 0.15s ease-in;
}

@keyframes view-slide-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND PALETTE
   ═══════════════════════════════════════════════════════════════════════════ */
#command-palette.visible {
    display: flex;
}

#command-palette .command-item {
    transition: background-color 0.1s;
}

#command-palette .command-item.selected {
    background: rgba(34, 197, 94, 0.15);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    #sidebar {
        position: fixed;
        left: -100%;
        top: 56px;
        bottom: 32px;
        z-index: 40;
        transition: left 0.3s ease-out;
    }

    #sidebar.open {
        left: 0;
    }

    #sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 35;
    }

    #sidebar-backdrop.visible {
        display: block;
    }

    .mobile-menu-btn {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    /* Stack stat cards */
    #dashboard-view .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stack two-column layout */
    #dashboard-view .grid-cols-2 {
        grid-template-columns: 1fr;
    }

    /* Adjust header */
    #app-header {
        padding-left: 12px;
        padding-right: 12px;
    }

    #role-name {
        display: none;
    }
}

@media (max-width: 480px) {
    /* Single column stats */
    #dashboard-view .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    /* Compact tabs */
    .tab-btn .tab-badge {
        display: none;
    }

    /* Compact footer */
    #app-footer > *:not(:first-child):not(:last-child) {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIER COLORS (AI Workforce)
   ═══════════════════════════════════════════════════════════════════════════ */
.tier-t1 {
    color: #a855f7;
}

.tier-t2 {
    color: #06b6d4;
}

.tier-t3 {
    color: #22c55e;
}

.tier-badge-t1 {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.tier-badge-t2 {
    background: rgba(6, 182, 212, 0.2);
    color: #06b6d4;
}

.tier-badge-t3 {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RISK TIERS (MCP Swarm)
   ═══════════════════════════════════════════════════════════════════════════ */
.risk-1 { color: #22c55e; }
.risk-2 { color: #3b82f6; }
.risk-3 { color: #f59e0b; }
.risk-4 { color: #f97316; }
.risk-5 { color: #ef4444; }

.risk-badge-1 { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.risk-badge-2 { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.risk-badge-3 { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.risk-badge-4 { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.risk-badge-5 { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/* ═══════════════════════════════════════════════════════════════════════════
   DEFCON LEVELS
   ═══════════════════════════════════════════════════════════════════════════ */
.defcon-1 {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.1));
    border-color: #ef4444;
    color: #fca5a5;
}

.defcon-3 {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.1));
    border-color: #fbbf24;
    color: #fde68a;
}

.defcon-5 {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.1));
    border-color: #22c55e;
    color: #86efac;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════════════════ */
.skeleton {
    background: linear-gradient(90deg, #27272a 25%, #3f3f46 50%, #27272a 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #27272a;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOOLTIPS
   ═══════════════════════════════════════════════════════════════════════════ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    color: #d4d4d8;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SSE LIVE UPDATES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Badge update animation */
.badge-updated {
    animation: badge-pop 0.3s ease-out;
}

@keyframes badge-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Live indicator in footer */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toast-in 0.3s ease-out forwards;
    max-width: 360px;
}

.toast.toast-exit {
    animation: toast-out 0.3s ease-in forwards;
}

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

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

/* Connection status indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-dot.connected {
    background-color: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.connection-dot.disconnected {
    background-color: #ef4444;
}

.connection-dot.reconnecting {
    background-color: #fbbf24;
    animation: pulse 1s ease-in-out infinite;
}
