/* Agent Dashboard — extends portal.css */

/* Stats bar */
.agent-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.agent-stat-card {
    background: var(--sp-bg-card);
    border: 1px solid var(--sp-border);
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}

.agent-stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--sp-primary);
    line-height: 1;
}

.agent-stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--sp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.agent-stat-card.stat-critical .stat-value { color: #dc2626; }
.agent-stat-card.stat-high .stat-value { color: #ea580c; }

/* Filters */
.agent-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--sp-bg-card);
    border: 1px solid var(--sp-border);
    border-radius: 8px;
}

.agent-filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.agent-filter-group:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.agent-filter-group:last-child {
    margin-left: auto;
}

.agent-filter-select {
    flex: 0 1 180px;
    min-width: 140px;
    max-width: 220px;
    font-size: 13px;
    padding: 6px 10px;
    height: 36px;
    border-radius: var(--sp-radius-sm);
    border: 1px solid var(--sp-border);
    background: var(--sp-bg-input);
    color: var(--sp-text);
}

.agent-filter-select:focus {
    outline: none;
    border-color: var(--sp-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.agent-search {
    width: 240px;
    max-width: 100%;
    font-size: 13px;
    padding: 6px 12px;
    height: 36px;
    border-radius: var(--sp-radius-sm);
    border: 1px solid var(--sp-border);
    background: var(--sp-bg-input);
    color: var(--sp-text);
}

.agent-search:focus {
    outline: none;
    border-color: var(--sp-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Ticket table */
.agent-ticket-table-wrap {
    overflow-x: auto;
    background: var(--sp-bg-card);
    border: 1px solid var(--sp-border);
    border-radius: 8px;
}

.agent-ticket-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.agent-ticket-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sp-text-muted);
    background: var(--sp-bg);
    border-bottom: 1px solid var(--sp-border);
    white-space: nowrap;
}

.agent-ticket-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.agent-ticket-table tbody tr:hover {
    background: color-mix(in srgb, var(--sp-primary) 5%, transparent);
}

.agent-ticket-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--sp-border);
    vertical-align: middle;
}

.agent-ticket-table .ticket-id-cell {
    font-family: monospace;
    font-weight: 600;
    font-size: 12px;
    color: var(--sp-primary);
    white-space: nowrap;
}

.agent-ticket-table .ticket-subject-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-ticket-table .ticket-customer-cell {
    white-space: nowrap;
    color: var(--sp-text-muted);
    font-size: 12px;
}

.agent-ticket-table .ticket-project-cell {
    white-space: nowrap;
    font-size: 12px;
}

.agent-ticket-table .ticket-age-cell {
    white-space: nowrap;
    font-size: 12px;
    color: var(--sp-text-muted);
}

/* Severity badges in table */
.agent-severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.agent-severity-badge.sev-critical { background: #fef2f2; color: #dc2626; }
.agent-severity-badge.sev-high { background: #fff7ed; color: #ea580c; }
.agent-severity-badge.sev-medium { background: #fefce8; color: #ca8a04; }
.agent-severity-badge.sev-low { background: #f0fdf4; color: #16a34a; }

/* Detail view */
.agent-ticket-detail {
    animation: fadeIn 0.2s ease;
}

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

.agent-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.agent-detail-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.agent-detail-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    align-items: start;
}

.agent-detail-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.agent-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Card header/body for detail */
.sp-card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--sp-border);
}

.sp-card-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.sp-card-body {
    padding: 16px;
}

/* Notes badge */
.agent-note-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    color: var(--sp-text-muted);
    background: color-mix(in srgb, var(--sp-text-muted) 12%, transparent);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Reply and note items */
.agent-reply-item,
.agent-note-item {
    padding: 10px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--sp-border) 50%, transparent);
}

.agent-reply-item:last-child,
.agent-note-item:last-child {
    border-bottom: none;
}

.agent-reply-meta,
.agent-note-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.agent-reply-author,
.agent-note-author {
    font-weight: 600;
    font-size: 13px;
}

.agent-reply-type {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.agent-reply-type.type-staff { background: #dbeafe; color: #1d4ed8; }
.agent-reply-type.type-customer { background: #f0fdf4; color: #16a34a; }
.agent-reply-type.type-agent { background: #fef3c7; color: #d97706; }

.agent-reply-time,
.agent-note-time {
    font-size: 11px;
    color: var(--sp-text-muted);
    margin-left: auto;
}

.agent-reply-body,
.agent-note-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--sp-text);
}

/* Detail meta grid */
.agent-meta-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.agent-meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.agent-meta-item .meta-label {
    color: var(--sp-text-muted);
    font-weight: 500;
}

.agent-meta-item .meta-value {
    font-weight: 600;
    text-align: right;
}

/* Timeline */
.agent-timeline-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--sp-border) 30%, transparent);
}

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

.agent-timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sp-primary);
    margin-top: 4px;
    flex-shrink: 0;
}

.agent-timeline-text {
    flex: 1;
    color: var(--sp-text-muted);
}

.agent-timeline-text strong {
    color: var(--sp-text);
}

/* Ticket info card */
.agent-ticket-info-body {
    padding: 16px;
}

.agent-ticket-info-body h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.agent-ticket-info-body .description {
    font-size: 13px;
    line-height: 1.6;
    color: var(--sp-text);
}

.agent-ticket-info-body .description img {
    max-width: 100%;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 900px) {
    .agent-detail-body {
        grid-template-columns: 1fr;
    }
    .agent-detail-sidebar {
        order: -1;
    }
    .agent-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .agent-filter-group {
        flex-direction: column;
    }
    .agent-filter-select,
    .agent-search {
        min-width: unset;
        width: 100%;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .agent-severity-badge.sev-critical { background: rgba(220, 38, 38, 0.15); }
    .agent-severity-badge.sev-high { background: rgba(234, 88, 12, 0.15); }
    .agent-severity-badge.sev-medium { background: rgba(202, 138, 4, 0.15); }
    .agent-severity-badge.sev-low { background: rgba(22, 163, 74, 0.15); }
    .agent-reply-type.type-staff { background: rgba(29, 78, 216, 0.2); }
    .agent-reply-type.type-customer { background: rgba(22, 163, 74, 0.2); }
    .agent-reply-type.type-agent { background: rgba(217, 119, 6, 0.2); }
}
