/* Traffic Monitoring Module Specific Styles v2 */

/* ---------------- AI Status Banner ---------------- */
.ai-status-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(59,130,246,0.08));
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: var(--radius-lg);
}
.ai-status-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.ai-icon-wrap {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: #fff;
    animation: aiPulse 2s infinite;
}
@keyframes aiPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139,92,246,0.4); }
    50% { box-shadow: 0 0 20px 6px rgba(139,92,246,0.15); }
}
.ai-info h3 {
    font-size: 0.95rem; font-weight: 700; margin-bottom: 4px;
    background: linear-gradient(90deg, #A78BFA, #60A5FA);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.ai-info p {
    font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4;
}
.ai-status-right {
    display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.ai-last-update {
    font-size: 0.8rem; color: var(--accent-green); font-weight: 600;
}
.ai-cycle {
    font-size: 0.75rem; color: var(--text-secondary);
}

.ai-source-tag {
    font-size: 0.7rem; color: rgba(139,92,246,0.7);
    margin-bottom: 12px; text-align: center;
}
.ai-source-tag i { margin-right: 4px; }

/* ---------------- Crowd Tracking Grid ---------------- */
.crowd-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .crowd-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

.crowd-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    border-top: 4px solid var(--border-color);
}

/* Base congestion colors */
.zone-green {
    border-top-color: var(--accent-green);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}
.zone-yellow {
    border-top-color: var(--accent-orange);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.1);
}
.zone-red {
    border-top-color: var(--accent-red);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1);
    animation: criticalPulse 2s infinite;
}

@keyframes criticalPulse {
    0% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1); }
    50% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4); }
    100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.1); }
}

.crowd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.crowd-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}
.zone-green .status-badge { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.zone-yellow .status-badge { background: rgba(245, 158, 11, 0.2); color: var(--accent-orange); }
.zone-red .status-badge { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

.crowd-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 8px;
}

.btn-count {
    width: 60px; height: 60px;
    border-radius: 50%; border: none;
    font-size: 2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.btn-count.minus { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
.btn-count.minus:hover { background: rgba(255, 255, 255, 0.2); }
.btn-count.plus { background: var(--accent-blue); }
.btn-count.plus:hover { background: #2563EB; }

.count-val {
    font-size: 4rem; font-weight: 700;
    line-height: 1; width: 100px;
}
.zone-green .count-val { color: var(--accent-green); }
.zone-yellow .count-val { color: var(--accent-orange); }
.zone-red .count-val { color: var(--accent-red); }

.crowd-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.limit-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
}
.zone-green .progress-bar-fill { background: var(--accent-green); }
.zone-yellow .progress-bar-fill { background: var(--accent-orange); }
.zone-red .progress-bar-fill { background: var(--accent-red); }


/* ================== CCTV 20개소 Grid ================== */
.cctv-section {
    padding: 24px;
    margin-bottom: 24px;
}

.cctv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.cctv-header h2 {
    font-size: 1.1rem; font-weight: 600;
}

.cctv-filter-tabs {
    display: flex; gap: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px; padding: 3px;
}
.cctv-tab {
    padding: 6px 14px; border: none;
    border-radius: 6px; font-size: 0.78rem;
    font-weight: 600; cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.cctv-tab.active {
    background: var(--accent-blue);
    color: #fff;
}
.cctv-tab:hover:not(.active) {
    background: rgba(255,255,255,0.08);
}

.pulse-indicator {
    display: flex; align-items: center;
    gap: 6px; color: var(--accent-red);
    font-size: 0.85rem; font-weight: 600;
}
.pulse-dot {
    width: 10px; height: 10px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: recPulse 1s infinite alternate;
}
@keyframes recPulse {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

/* View Mode Buttons */
.cctv-view-modes {
    display: flex; gap: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px; padding: 3px;
}
.view-mode-btn {
    padding: 6px 12px; border: none;
    border-radius: 6px; font-size: 0.78rem;
    font-weight: 600; cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 5px;
}
.view-mode-btn.active {
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    color: #fff;
}
.view-mode-btn:hover:not(.active) {
    background: rgba(255,255,255,0.08);
}

/* Auto Rotate Bar */
.auto-rotate-bar {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(239,68,68,0.05));
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: 10px;
    margin-bottom: 16px;
}
.auto-rotate-info {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.82rem; color: var(--text-primary); font-weight: 500;
    flex: 1;
}
.auto-rotate-info i { color: #F59E0B; }
.auto-rotate-progress {
    width: 120px; height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px; overflow: hidden;
}
.auto-rotate-fill {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, #F59E0B, #EF4444);
    border-radius: 4px;
    transition: width 1s linear;
}
.btn-stop-auto {
    padding: 5px 12px; border: 1px solid rgba(245,158,11,0.3);
    border-radius: 6px; background: rgba(245,158,11,0.1);
    color: #F59E0B; font-size: 0.78rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; gap: 4px;
    transition: all 0.2s;
}
.btn-stop-auto:hover { background: rgba(245,158,11,0.2); }

/* Live Grid (4-split / 9-split) */
.cctv-live-area {
    margin-bottom: 16px;
}
.cctv-live-grid {
    display: grid;
    gap: 12px;
}
.cctv-live-grid.quad { grid-template-columns: repeat(2, 1fr); }
.cctv-live-grid.nine { grid-template-columns: repeat(3, 1fr); }
.cctv-live-grid.snapshot-all { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 1200px) {
    .cctv-live-grid.snapshot-all { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
    .cctv-live-grid.quad { grid-template-columns: repeat(2, 1fr); }
    .cctv-live-grid.nine { grid-template-columns: repeat(2, 1fr); }
    .cctv-live-grid.snapshot-all { grid-template-columns: repeat(2, 1fr); }
}

/* Live Frame (larger) */
.cctv-frame-live {
    background: #0a0a0a;
    border: 2px solid rgba(59,130,246,0.3);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    transition: border-color 0.3s;
    cursor: pointer;
}
.cctv-frame-live:hover {
    border-color: var(--accent-blue);
}
.cctv-frame-live .live-badge {
    position: absolute; top: 8px; right: 8px;
    background: rgba(239,68,68,0.85); color: #fff;
    padding: 2px 8px; border-radius: 4px;
    font-size: 0.65rem; font-weight: 700;
    display: flex; align-items: center; gap: 4px;
    z-index: 10;
}
.cctv-frame-live .live-badge::before {
    content: ''; width: 6px; height: 6px;
    background: #fff; border-radius: 50%;
    animation: recPulse 1s infinite alternate;
}

/* Thumbnail Grid */
.cctv-thumb-area {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 16px;
}
.thumb-section-header {
    margin-bottom: 12px;
}
.thumb-section-header h3 {
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-secondary);
    display: flex; align-items: center; gap: 8px;
}
.cctv-thumb-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}
@media (max-width: 1400px) { .cctv-thumb-grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 900px) { .cctv-thumb-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 600px) { .cctv-thumb-grid { grid-template-columns: repeat(3, 1fr); } }

.cctv-thumb {
    background: #0a0a0a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}
.cctv-thumb:hover {
    border-color: var(--accent-blue);
    transform: scale(1.03);
    z-index: 2;
}
.cctv-thumb .snap-badge {
    position: absolute; top: 4px; right: 4px;
    background: rgba(0,0,0,0.6); color: #94A3B8;
    padding: 1px 5px; border-radius: 3px;
    font-size: 0.55rem; font-weight: 600;
    z-index: 10;
}
.cctv-thumb .snap-time {
    position: absolute; bottom: 4px; right: 4px;
    color: rgba(255,255,255,0.4);
    font-size: 0.55rem; font-weight: 600;
    z-index: 10;
}

.cctv-frame {
    background: #0a0a0a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    transition: border-color 0.3s, transform 0.2s;
}
.cctv-frame:hover {
    border-color: var(--accent-blue);
    transform: scale(1.02);
    z-index: 2;
}
.cctv-frame.hidden {
    display: none;
}

.cctv-label {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    z-index: 10;
    max-width: calc(100% - 50px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.privacy-tag {
    display: inline-block;
    background: rgba(239,68,68,0.3);
    color: #FCA5A5;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.6rem;
    margin-left: 4px;
}

.cctv-ai-count {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(139,92,246,0.8);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 10;
    display: flex; align-items: center; gap: 4px;
}
.cctv-ai-count::before {
    content: '\f544'; /* fa-robot */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.6rem;
}

.cctv-placeholder {
    color: rgba(255,255,255,0.25);
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.cctv-placeholder i {
    font-size: 1.6rem;
}

/* Privacy Blur */
.blurred-cam .cctv-placeholder {
    color: rgba(255,255,255,0.1);
    filter: blur(2px);
}
.blurred-cam {
    background: #111;
}

/* ---------------- Line Chart container ---------------- */
.traffic-chart {
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.chart-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}
.chart-body {
    flex: 1;
    position: relative;
    width: 100%;
}

/* AI Analysis Button Glow */
#btnAiAnalysis {
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    border: none;
    animation: btnGlow 3s infinite;
}
@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(139,92,246,0.3); }
    50% { box-shadow: 0 0 20px rgba(139,92,246,0.6); }
}

/* AI running animation */
.ai-running .ai-icon-wrap {
    animation: aiSpin 1s linear infinite;
}
@keyframes aiSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .ai-status-banner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    .ai-status-left { flex-direction: column; }
    .ai-status-right { align-items: center; }
}
