/**
 * Agent List Cards - Project-AgentsListUpgrade-1
 * New card-based layout for agent list with status indicators
 */

/* ============================================
   CARD CONTAINER
   ============================================ */

.agents-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px;
    padding: 12px;
    width: 100% !important;
}

.agents-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    width: 100% !important;
}

.agents-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 4px 0;
    padding-left: 4px;
}

/* Completed agents are slightly dimmed */
.completed-agents .agent-card {
    opacity: 0.75;
}

.completed-agents .agent-card:hover {
    opacity: 1;
}

/* ============================================
   AGENT CARD - Base
   ============================================ */

.agent-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0;
    background: var(--bg-secondary, #1a1a2e);
    border: 2px solid var(--border-color, #333);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.agent-card:hover {
    background: var(--bg-hover, #252540);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.agent-card.selected {
    border-color: var(--accent-primary, #00d9ff);
    box-shadow: 0 0 0 1px var(--accent-primary, #00d9ff);
}

/* ============================================
   STATUS-BASED BORDER COLORS
   ============================================ */

.agent-card.agent-status-running {
    border-color: #00d9ff;
}

.agent-card.agent-status-initializing {
    border-color: #00d9ff;
}

.agent-card.agent-status-paused {
    border-color: #ffd700;
}

.agent-card.agent-status-waiting {
    border-color: #ffa500;
}

.agent-card.agent-status-completed {
    border-color: #666;
}

.agent-card.agent-status-error {
    border-color: #ff4444;
}

.agent-card.agent-status-failed {
    border-color: #ff4444;
}

.agent-card.agent-status-cancelled {
    border-color: #888;
}

/* ============================================
   CARD LEFT - Status Ball + Metadata
   ============================================ */

.agent-card-left {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    position: relative;
}

/* Status Ball */
.agent-status-ball {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: #666;
    margin-top: 4px;
    transition: all 0.3s ease;
}

/* Running - Green with glow pulse */
.agent-status-running .agent-status-ball,
.agent-status-initializing .agent-status-ball {
    background: radial-gradient(circle at 30% 30%, #00ff88, #00cc66);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.6),
                0 0 30px rgba(0, 255, 136, 0.3);
    animation: pulse-green 2s ease-in-out infinite;
}

/* Paused/Waiting - Yellow with soft glow */
.agent-status-paused .agent-status-ball,
.agent-status-waiting .agent-status-ball {
    background: radial-gradient(circle at 30% 30%, #ffdd00, #ffaa00);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5),
                0 0 20px rgba(255, 215, 0, 0.2);
    animation: pulse-yellow 3s ease-in-out infinite;
}

/* Completed - Gray, no glow */
.agent-status-completed .agent-status-ball {
    background: radial-gradient(circle at 30% 30%, #888, #555);
    box-shadow: none;
}

/* Error/Failed - Red, no glow */
.agent-status-error .agent-status-ball,
.agent-status-failed .agent-status-ball {
    background: radial-gradient(circle at 30% 30%, #ff6666, #cc3333);
    box-shadow: none;
}

/* Cancelled - Dark gray */
.agent-status-cancelled .agent-status-ball {
    background: radial-gradient(circle at 30% 30%, #666, #444);
    box-shadow: none;
}

/* Pulse animations */
@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 15px rgba(0, 255, 136, 0.6),
                    0 0 30px rgba(0, 255, 136, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.8),
                    0 0 40px rgba(0, 255, 136, 0.4);
    }
}

@keyframes pulse-yellow {
    0%, 100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.5),
                    0 0 20px rgba(255, 215, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 16px rgba(255, 215, 0, 0.7),
                    0 0 28px rgba(255, 215, 0, 0.3);
    }
}

/* ============================================
   METADATA
   ============================================ */

.agent-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.agent-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-card-time {
    font-size: 12px;
    color: var(--text-secondary, #aaa);
}

.agent-card-duration {
    font-size: 12px;
    color: var(--text-secondary, #aaa);
}

/* Duration text color by status */
.agent-status-running .agent-card-duration {
    color: #00ff88;
}

.agent-status-paused .agent-card-duration,
.agent-status-waiting .agent-card-duration {
    color: #ffd700;
}

.agent-status-error .agent-card-duration,
.agent-status-failed .agent-card-duration {
    color: #ff6666;
}

.agent-card-id {
    font-size: 11px;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-muted, #666);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}

/* ============================================
   HUMAN INPUT BADGE
   ============================================ */

.agent-human-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 165, 0, 0.2);
    border: 1px solid rgba(255, 165, 0, 0.5);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 14px;
    color: #ffa500;
    animation: badge-pulse 2s ease-in-out infinite;
}

.agent-human-badge .badge-count {
    background: #ff6600;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes badge-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ============================================
   CARD RIGHT - Snippet
   ============================================ */

.agent-card-right {
    grid-column: 2;
    grid-row: 1;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100px;
}

.agent-card-snippet {
    font-size: 13px;
    color: var(--text-secondary, #ccc);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

/* Snippet type indicators */
.agent-card-snippet.snippet-comment {
    font-style: normal;
}

.agent-card-snippet.snippet-code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid #00d9ff;
}

.agent-card-snippet.snippet-error {
    color: #ff6666;
    border-left: 3px solid #ff4444;
    padding-left: 10px;
}

.agent-card-snippet.snippet-human {
    color: #ffa500;
    background: rgba(255, 165, 0, 0.1);
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid #ffa500;
}

.agent-card-snippet .snippet-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.agent-card-snippet .snippet-content {
    display: block;
}

/* ============================================
   CARD FOOTER
   ============================================ */

.agent-card-footer {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.agent-card-stats {
    font-size: 12px;
    color: var(--text-muted, #888);
}

.agent-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Hamburger/Menu button */
.agent-card .agent-hamburger-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-secondary, #aaa);
    transition: all 0.2s ease;
}

.agent-card .agent-hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary, #fff);
}

/* Delete button */
.agent-card .agent-delete-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-muted, #666);
    transition: all 0.2s ease;
    opacity: 0;
}

.agent-card:hover .agent-delete-btn {
    opacity: 1;
}

.agent-card .agent-delete-btn:hover {
    background: rgba(255, 68, 68, 0.15);
    border-color: rgba(255, 68, 68, 0.3);
    color: #ff4444;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.agents-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #888);
}

.agents-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.agents-empty h3 {
    margin: 0 0 8px 0;
    color: var(--text-secondary, #aaa);
}

.agents-empty p {
    margin: 0 0 20px 0;
    font-size: 14px;
}

/* ============================================
   LOADING STATE
   ============================================ */

.agent-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.agent-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 800px) {
    .agent-card {
        grid-template-columns: 1fr;
    }
    
    .agent-card-right {
        grid-column: 1;
        grid-row: 2;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .agent-card-footer {
        grid-row: 3;
    }
}

/* ============================================
   MENU DANGER ITEM STYLING
   ============================================ */

.menu-item.danger {
    color: #ff6666;
}

.menu-item.danger:hover:not(.disabled) {
    background: rgba(255, 68, 68, 0.15);
    color: #ff4444;
}

.menu-item.danger.disabled {
    color: #664444;
}