/* ===========================================
   Agent Status Indicator (topbar icon + dropdown)
   Shows active CC-tool agents with badge count
   and a dropdown panel listing agent details.
   =========================================== */

.agent-status {
    position: relative;
    align-self: center;
}

/* Grey out the indicator when no agents are active */
.agent-status--empty .agent-status__trigger,
.agent-status--inactive .agent-status__trigger {
    color: var(--color-text-muted, #999);
    opacity: 0.5;
}

/* Active state — full color */
.agent-status--active .agent-status__trigger {
    color: var(--color-accent);
    opacity: 1;
}

/* ---- Trigger button ---- */

.agent-status__trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: var(--space-1);
    cursor: pointer;
    color: var(--color-accent);
    font-size: 1.35em;
    border-radius: 6px;
    transition: color 0.15s ease, transform 0.15s ease, opacity 0.3s ease;
    position: relative;
}

/* ---- Atom icon (inline SVG) ---- */

.agent-status__atom-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
}

.agent-status__atom-icon .atom-svg {
    width: 1em;
    height: 1em;
    display: block;
}

.agent-status__trigger:hover {
    color: var(--color-text);
    transform: scale(1.1);
}

.agent-status__trigger:active {
    transform: scale(0.95);
}

.agent-status.open .agent-status__trigger {
    color: var(--color-text);
}

/* ---- Badge (active agent count) ---- */

.agent-status__badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    background: var(--color-accent);
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    border-radius: 8px;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.agent-status__badge--hidden {
    opacity: 0;
    transform: scale(0);
}

/* Pulsing badge when an agent is WAITING */
.agent-status__badge--waiting {
    background: #FFA500;
    animation: agent-status-pulse 1.5s ease-in-out infinite;
}

@keyframes agent-status-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.85; }
}

/* At max concurrent capacity — dimmed appearance */
.agent-status__badge--at-capacity {
    background: var(--color-text-muted, #999);
    opacity: 0.75;
}

/* ---- Dropdown panel ---- */

.agent-status__panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 380px;
    background: var(--color-surface-elevated);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 99999;
    opacity: 0;
    transform: translateY(-6px);
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    display: flex;
    flex-direction: column;
    max-height: 520px;
    overflow: hidden;
}

.agent-status.open .agent-status__panel {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

/* ---- Header ---- */

.agent-status__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.agent-status__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

/* ---- Agent list ---- */

.agent-status__list {
    overflow-y: auto;
    flex: 1;
}

/* ---- Agent item ---- */

.agent-status__item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    transition: background 0.12s ease;
    border-bottom: 1px solid var(--color-border);
}

.agent-status__item:last-child {
    border-bottom: none;
}

.agent-status__item:hover {
    background: var(--color-surface-hover);
}

/* WAITING state — highlighted */
.agent-status__item--waiting {
    background: color-mix(in srgb, #FFA500 8%, var(--color-surface-elevated) 92%);
}

.agent-status__item--waiting:hover {
    background: color-mix(in srgb, #FFA500 14%, var(--color-surface-elevated) 86%);
}

/* Terminal state — slightly muted */
.agent-status__item--terminal {
    opacity: 0.75;
}

.agent-status__item--terminal:hover {
    opacity: 1;
}

/* ---- Item icon ---- */

.agent-status__item-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-top: 2px;
}

.agent-status__item-icon .atom-svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ---- Item content ---- */

.agent-status__item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.agent-status__item-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
}

.agent-status__item-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.agent-status__item-time {
    font-size: 10px;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.agent-status__item-prompt {
    font-size: 11.5px;
    color: var(--color-text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-status__item-meta {
    font-size: 10px;
    color: var(--color-text-muted);
    opacity: 0.7;
    margin-top: 1px;
}

/* ---- Chevron (expand/collapse indicator) ---- */

.agent-status__item-chevron {
    flex-shrink: 0;
    width: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--color-text-muted, #999);
    margin-top: 4px;
    transition: transform 0.15s ease;
}

/* ---- Expanded item ---- */

.agent-status__item--expanded {
    border-bottom: none;
}

/* ---- Detail panel (expanded) ---- */

.agent-status__detail {
    padding: 0 var(--space-3) var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface, var(--color-surface-elevated));
}

.agent-status__detail-section {
    margin-bottom: var(--space-2);
}

.agent-status__detail-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.agent-status__detail-label--error {
    color: #ff4444;
}

.agent-status__detail-text {
    font-size: 11.5px;
    color: var(--color-text, #333);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}

.agent-status__detail-text--error {
    color: #ff4444;
}

.agent-status__detail-files {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-status__detail-files li {
    font-size: 11.5px;
    color: var(--color-text, #333);
    padding: 2px 0;
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
}

.agent-status__detail-file-size {
    font-size: 10px;
    color: var(--color-text-muted, #aaa);
}

/* ---- Action buttons ---- */

.agent-status__detail-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
    flex-wrap: wrap;
}

.agent-status__action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    background: none;
    color: var(--color-text-muted, #888);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.agent-status__action-btn:hover {
    background: var(--color-surface-hover, rgba(0,0,0,0.04));
    color: var(--color-text);
}

.agent-status__action-btn--primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.agent-status__action-btn--primary:hover {
    opacity: 0.85;
    color: #fff;
}

.agent-status__action-btn--danger {
    border-color: #ff4444;
    color: #ff4444;
}

.agent-status__action-btn--danger:hover {
    background: #ff4444;
    color: #fff;
}

/* ---- Empty state ---- */

.agent-status__empty {
    padding: var(--space-6) var(--space-3);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* ===========================================
   Mobile: full-screen overlay
   =========================================== */
@media (max-width: 768px) {

    .agent-status__panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        z-index: 100000;
    }

    .agent-status__list {
        flex: 1;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .agent-status__item {
        padding: var(--space-3);
        min-height: var(--touch-target-min);
    }

    .agent-status__item-label {
        font-size: 13px;
    }

    .agent-status__item-prompt {
        font-size: 12px;
    }
}
