/* =============================================================================
   TASKS APP
   Automated Intelligent Task Management Interface
   ============================================================================= */

/* =============================================================================
   LAYOUT STRUCTURE
   ============================================================================= */

.tasks-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(
        --font-family,
        system-ui, -apple-system, sans-serif
    );
}

/* =============================================================================
   TOP HEADER BAR
   ============================================================================= */

.tasks-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* New Intent Button */
.btn-new-intent {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: var(--accent-foreground, #000000);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.btn-new-intent:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 20px var(--primary-light);
}

.btn-new-intent svg {
    width: 16px;
    height: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

/* Tasks List Title Row */
.tasks-list-title {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tasks-list-title h1 {
    margin: 0;
}

.topbar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 16px;
}

.topbar-nav {
    display: flex;
    gap: 4px;
}

.topbar-nav-item {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topbar-nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.topbar-nav-item.active {
    background: var(--surface-hover);
    color: var(--primary);
}

.topbar-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.topbar-search {
    position: relative;
    width: 100%;
}

.topbar-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
    pointer-events: none;
}

.topbar-search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s ease;
}

.topbar-search-input::placeholder {
    color: var(--text-secondary);
}

.topbar-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.topbar-icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.topbar-icon-btn .notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
}

.topbar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.topbar-profile:hover {
    border-color: var(--border);
}

.topbar-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), #a5d622);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 12px;
    font-weight: 600;
}

.topbar-profile-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.topbar-profile-arrow {
    color: var(--text-secondary);
    font-size: 12px;
}

/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */

.tasks-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* =============================================================================
   TASK LIST PANEL (LEFT)
   ============================================================================= */

.tasks-list-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
    min-height: 0;
}

.tasks-list-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.tasks-list-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tasks-list-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.tasks-count {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Status Filter Pills */
.status-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-pill:hover {
    border-color: var(--border);
    color: var(--text);
}

.status-pill.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.status-pill.complete.active {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.status-pill.active-intents.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--info);
    color: var(--info);
}

.status-pill.awaiting.active {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--warning);
    color: var(--warning);
}

.status-pill.paused.active {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--warning);
    color: var(--warning);
}

.status-pill.blocked.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
    color: var(--error);
}

.status-pill .pill-count {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-pill.active .pill-count {
    background: rgba(255, 255, 255, 0.15);
}

/* Task List Scroll Container */
.tasks-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Task Card */
.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-card:hover {
    border-color: var(--border);
    transform: translateX(4px);
}

.task-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

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

.task-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.task-card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.task-card-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.task-card-status.running {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.task-card-status.complete {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.task-card-status.awaiting {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.task-card-status.paused {
    background: rgba(139, 92, 246, 0.15);
    color: var(--warning);
}

.task-card-status.blocked {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Task Progress */
.task-card-progress {
    margin-bottom: 12px;
}

.task-progress-bar {
    height: 6px;
    background: var(--surface-hover);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.task-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.task-progress-fill.success {
    background: var(--success);
}

.task-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.task-progress-percent {
    color: var(--primary);
    font-weight: 600;
}

.task-progress-steps {
    color: var(--text-secondary);
}

/* Task Card Meta */
.task-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.task-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =============================================================================
   TASK DETAIL PANEL (RIGHT)
   ============================================================================= */

.task-detail-panel {
    width: 480px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.task-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.task-detail-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.task-detail-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
}

.task-detail-actions {
    display: flex;
    gap: 8px;
}

.task-detail-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-detail-action-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.task-detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.task-detail-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.task-detail-meta-item .icon {
    color: var(--text-secondary);
}

/* Task Detail Scroll */
.task-detail-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* Decision Required Section */
.decision-required-section {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.decision-required-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.decision-required-icon {
    width: 28px;
    height: 28px;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--warning);
    font-size: 14px;
}

.decision-required-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.decision-required-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.decision-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.decision-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.decision-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.decision-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.decision-option-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.decision-option.selected .decision-option-radio {
    border-color: var(--primary);
}

.decision-option.selected .decision-option-radio::after {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.decision-option-content {
    flex: 1;
}

.decision-option-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.decision-option-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.decision-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.decision-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.decision-btn-primary {
    background: var(--primary);
    border: none;
    color: #000;
}

.decision-btn-primary:hover {
    background: #d4ff4a;
    box-shadow: 0 0 20px var(--primary-light);
}

.decision-btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.decision-btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Progress Log Section */
.progress-log-section {
    margin-bottom: 20px;
}

.progress-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.progress-log-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-log-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.progress-log-toggle:hover {
    color: var(--text);
}

/* Step Items */
.step-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-hover);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.step-item:first-child {
    border-radius: 8px 8px
        6px 6px;
}

.step-item:last-child {
    border-radius: 6px 6px
        8px 8px;
}

.step-item:only-child {
    border-radius: 8px;
}

.step-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 12px;
    flex-shrink: 0;
}

.step-item.completed .step-icon {
    background: var(--success);
    color: #000;
}

.step-item.active .step-icon {
    background: var(--primary);
    color: #000;
    animation: pulse 2s infinite;
}

.step-item.pending .step-icon {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.step-item.error .step-icon {
    background: var(--error);
    color: #fff;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.step-item.pending .step-name {
    color: var(--text-secondary);
}

.step-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

.step-time {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* =============================================================================
   LIVE AGENT ACTIVITY (TERMINAL)
   ============================================================================= */

.agent-activity-section {
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.agent-activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.agent-activity-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.agent-activity-actions {
    display: flex;
    gap: 8px;
}

.agent-activity-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-activity-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.agent-activity-log {
    padding: 16px 24px;
    max-height: 180px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
}

.activity-line {
    display: flex;
    gap: 12px;
    padding: 3px 0;
}

.activity-timestamp {
    color: var(--text-secondary);
    min-width: 65px;
    flex-shrink: 0;
}

.activity-message {
    color: var(--text-secondary);
}

.activity-line.success .activity-message {
    color: var(--success);
}

.activity-line.warning .activity-message {
    color: var(--warning);
}

.activity-line.error .activity-message {
    color: var(--error);
}

.activity-line.accent .activity-message {
    color: var(--primary);
}

.activity-line.info .activity-message {
    color: var(--info);
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 280px;
}

/* =============================================================================
   LOADING STATE
   ============================================================================= */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-hover);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
    .task-detail-panel {
        width: 380px;
    }
}

@media (max-width: 768px) {
    .tasks-main {
        flex-direction: column;
    }

    .tasks-list-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }

    .task-detail-panel {
        width: 100%;
        flex: 1;
    }

    .topbar-center {
        display: none;
    }

    .topbar-nav {
        display: none;
    }
}

/* =============================================================================
   HTMX LOADING STATES
   ============================================================================= */

.htmx-request .task-card {
    opacity: 0.6;
}

.htmx-request .status-pill {
    pointer-events: none;
    opacity: 0.7;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

.task-card {
    animation: fadeIn 0.3s ease;
}

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