/* Incidents View - Thread-style incident grouping */

/* Incident Container */
.incidents-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Individual Incident Card */
.incident-card {
    background: var(--color-card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--color-shadow);
    overflow: hidden;
    transition: box-shadow 0.2s, background-color 0.3s ease;
}

.incident-card:hover {
    box-shadow: 0 4px 16px var(--color-shadow-strong);
}

/* Department color accents */
.incident-card.dept-fire {
    border-left: 5px solid #dc3545;
}

.incident-card.dept-ems {
    border-left: 5px solid #007bff;
}

.incident-card.dept-police {
    border-left: 5px solid #6f42c1;
}

.incident-card.dept-unknown {
    border-left: 5px solid #6c757d;
}

/* Incident Header (always visible) */
.incident-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    gap: 1rem;
}

.incident-header:hover {
    background-color: var(--color-date-header-bg);
}

.incident-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.incident-info {
    flex: 1;
    min-width: 0;
}

.incident-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.incident-title .dept-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.dept-badge.fire {
    background-color: #dc3545;
    color: white;
}

.dept-badge.ems {
    background-color: #007bff;
    color: white;
}

.dept-badge.police {
    background-color: #6f42c1;
    color: white;
}

.incident-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.incident-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.incident-preview {
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Expand/collapse indicator */
.incident-toggle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    gap: 0.15rem;
}

.incident-toggle-text {
    font-size: 0.65rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.incident-toggle {
    font-size: 1.25rem;
    color: #999;
    transition: transform 0.3s ease;
}

.incident-card.expanded .incident-toggle {
    transform: rotate(180deg);
}

/* Status indicator (active vs resolved) */
.incident-status {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.incident-status.active {
    background-color: #fff3cd;
    color: #856404;
    animation: pulse-status 2s ease-in-out infinite;
}

.incident-status.resolved {
    background-color: #d4edda;
    color: #155724;
}

.incident-status.no_followup {
    background-color: #e9ecef;
    color: #6c757d;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Incident Body (collapsible) */
.incident-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background-color: var(--color-bg-primary);
}

.incident-card.expanded .incident-body {
    max-height: 2000px;
    transition: max-height 0.5s ease-in;
}

/* Timeline within incident */
.incident-timeline {
    padding: 0.5rem 1.25rem 1.25rem 1.25rem;
    position: relative;
}

/* Vertical timeline rail */
.incident-timeline::before {
    content: '';
    position: absolute;
    left: 2.5rem;
    top: 0.5rem;
    bottom: 1.25rem;
    width: 2px;
    background: linear-gradient(to bottom, #ddd 0%, #ddd 85%, transparent 100%);
}

/* Individual transmission in timeline */
.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    position: relative;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* Compact summary card (2-row layout) */
.timeline-summary-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: white;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: box-shadow 0.2s, background-color 0.2s;
    min-width: 0;
}

.timeline-summary-card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    background-color: #f8f9fa;
}

.timeline-summary-card.priority-row {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

.timeline-summary-card.priority-row:hover {
    background-color: #ffeeee;
}

/* Top row: time, tags, play button */
.timeline-card-row-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Bottom row: summary text */
.timeline-card-row-bottom {
    display: flex;
    align-items: flex-start;
}

.timeline-time-compact {
    font-weight: 600;
    font-size: 0.8rem;
    color: #2c3e50;
    white-space: nowrap;
    flex-shrink: 0;
}

.timeline-inline-tags {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.dept-units-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background-color: #e3f2fd;
    color: #1565c0;
    font-weight: 500;
    white-space: nowrap;
}

.location-inline {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background-color: #d4edda;
    color: #155724;
    white-space: nowrap;
}

.timeline-summary-text {
    flex: 1;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.4;
}

.timeline-play-btn-compact {
    flex-shrink: 0;
    margin-left: auto;
    background-color: #28a745;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.timeline-play-btn-compact:hover {
    background-color: #218838;
    transform: scale(1.1);
}

.timeline-play-btn-compact.stop-mode {
    background-color: #dc3545;
}

.timeline-play-btn-compact.stop-mode:hover {
    background-color: #c82333;
}

/* Timeline dot */
.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ddd;
    border: 2px solid white;
    box-shadow: 0 0 0 2px #ddd;
    flex-shrink: 0;
    margin-top: 0.35rem;
    z-index: 1;
    transition: all 0.2s;
}

.timeline-item:first-child .timeline-dot {
    background-color: #28a745;
    box-shadow: 0 0 0 2px #28a745;
}

.timeline-item:last-child .timeline-dot {
    background-color: #2c3e50;
    box-shadow: 0 0 0 2px #2c3e50;
}

.timeline-item.priority .timeline-dot {
    background-color: #dc3545;
    box-shadow: 0 0 0 2px #dc3545;
}

/* Unread timeline items - accent colored dot and card highlight */
.timeline-item.unread .timeline-dot {
    background-color: var(--color-accent, #3b82f6);
    box-shadow: 0 0 0 2px var(--color-accent, #3b82f6),
                0 0 8px var(--color-accent, #3b82f6);
}

.timeline-item.unread .timeline-summary-card {
    border-left: 3px solid var(--color-accent, #3b82f6);
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
}

/* Priority + unread - keep priority colors but add glow */
.timeline-item.priority.unread .timeline-dot {
    background-color: #dc3545;
    box-shadow: 0 0 0 2px #dc3545,
                0 0 10px rgba(220, 53, 69, 0.6);
}

.timeline-item.priority.unread .timeline-summary-card {
    border-left: 3px solid #dc3545;
}

/* Priority siren emoji (between dot and card) */
.priority-siren {
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Priority content styling - matches timeline view priority cards */
.timeline-content.priority-content {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
}

/* Priority badge in timeline header */
.timeline-header .priority-badge {
    background: #dc3545;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Timeline content */
.timeline-content {
    flex: 1;
    min-width: 0;
    background: white;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}

.timeline-content:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-time {
    font-weight: 600;
    font-size: 0.9rem;
    color: #2c3e50;
}

.timeline-relative {
    font-size: 0.75rem;
    color: #999;
}

.timeline-tags {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.timeline-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    background-color: #e9ecef;
    color: #495057;
}

.timeline-tag.location {
    background-color: #d4edda;
    color: #155724;
}

.timeline-tag.unit {
    background-color: #fff3cd;
    color: #856404;
}

.timeline-tag.priority {
    background-color: #f8d7da;
    color: #721c24;
}

.timeline-transcript {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

.timeline-transcript .speaker {
    font-weight: 600;
    color: #2c3e50;
}

/* Play button in timeline */
.timeline-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
}

.timeline-play-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.timeline-play-btn:hover {
    background-color: #218838;
}

/* Duration bar */
.incident-duration-bar {
    height: 3px;
    background-color: #e9ecef;
    margin: 0 1.25rem;
}

.incident-duration-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #ffc107);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* View toggle */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--color-card-bg);
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--color-shadow);
    transition: background-color 0.3s ease;
}

.view-toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    /* Persistent button affordance: a visible grey background + border so
       inactive tabs always read as buttons (mobile users can't hover, so a
       hover-only border is invisible to them). */
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--color-text-secondary);
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

/* Hover deepens both bg and border slightly — still clearly the inactive
   button style, just with a "pressable" feel. */
.view-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.25);
}

.view-toggle-btn.active {
    background-color: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
    color: var(--color-text-inverse);
}

.view-toggle-btn.active:hover {
    background-color: var(--color-brand-hover);
    border-color: var(--color-brand-hover);
}

/* Empty state */
.no-incidents {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.no-incidents-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Refresh icon styling */
.refresh-icon {
    margin-left: 0.5rem;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.2s;
}

.refresh-icon:hover {
    transform: scale(1.2);
}

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

.more-segments {
    color: #888;
    font-style: italic;
    font-size: 0.85rem;
}

/* Separator between Active and Resolved incidents */
.incidents-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0 1rem 0;
    padding: 0 0.5rem;
}

.separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ccc, transparent);
}

.separator-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Resolved incidents - slightly faded */
.incident-card.resolved-incident {
    opacity: 0.85;
}

.incident-card.resolved-incident:hover {
    opacity: 1;
}

/* No followup incidents - more faded than resolved */
.incident-card.no-followup-incident {
    opacity: 0.7;
}

.incident-card.no-followup-incident:hover {
    opacity: 0.9;
}

.no-followup-separator .separator-text {
    color: #999;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .incident-header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .incident-icon {
        font-size: 1.5rem;
    }

    .incident-title {
        font-size: 0.95rem;
    }

    .incident-meta {
        font-size: 0.8rem;
        gap: 0.5rem;
    }

    .incident-timeline {
        padding: 0.5rem 1rem 1rem 1rem;
    }

    .incident-timeline::before {
        left: 2rem;
    }

    .timeline-content {
        padding: 0.6rem 0.75rem;
    }

    .timeline-time {
        font-size: 0.85rem;
    }

    .timeline-transcript {
        font-size: 0.85rem;
    }

    /* Compact summary card on mobile */
    .timeline-summary-card {
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
    }

    .timeline-card-row-top {
        gap: 0.4rem;
    }

    .timeline-time-compact {
        font-size: 0.75rem;
    }

    .dept-units-tag,
    .location-inline {
        font-size: 0.65rem;
        padding: 0.08rem 0.25rem;
    }

    .timeline-summary-text {
        font-size: 0.8rem;
    }

    .timeline-play-btn-compact {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
}
