/* Dashboard-specific styles — SytronSAS */
/* Fixed viewport layout - no page-level scrolling (TrackSense pattern) */

.main-area {
    height: 100vh;
    min-height: unset;
    overflow: hidden;
}

.page-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    max-width: none;
    margin: 0;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    flex-shrink: 0;
    margin-bottom: 10px;
}

.stats-row .stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.stats-row .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stats-row .stat-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.stats-row .stat-label {
    font-size: 0.68em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-row .stat-value {
    font-size: 1.4em;
    font-weight: 700;
}

.stats-row .stat-card:nth-child(1) .stat-value { color: var(--success); }
.stats-row .stat-card:nth-child(2) .stat-value { color: var(--danger); }
.stats-row .stat-card:nth-child(3) .stat-value { color: var(--accent); }
.stats-row .stat-card:nth-child(4) .stat-value { color: var(--warning); }

/* Dashboard Grid: cameras left, events right */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: 1fr auto;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.dash-center {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}

/* 2x2 Camera Grid */
.camera-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    flex: 1;
    min-height: 0;
}

/* Individual camera slot */
.cam-slot {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.cam-slot-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-card);
}

.cam-slot-toolbar .cam-slot-num {
    font-size: 0.68em;
    font-weight: 700;
    color: var(--accent);
    min-width: 14px;
}

.cam-slot-toolbar select {
    flex: 1;
    padding: 3px 6px;
    font-size: 0.72em;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    min-width: 0;
}

.cam-slot-toolbar select:focus { border-color: var(--accent); }

.cam-slot-toolbar .cam-slot-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cam-slot-toolbar .cam-slot-status.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.cam-slot-toolbar .cam-slot-status.offline {
    background: var(--text-muted);
}

/* Dashboard camera start/stop buttons */
.dash-cam-btn {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.68em;
    padding: 2px 8px;
    line-height: 1;
    flex-shrink: 0;
}
.dash-cam-start {
    background: var(--success);
    color: #fff;
}
.dash-cam-start:hover { opacity: 0.85; }
.dash-cam-stop {
    background: var(--danger);
    color: #fff;
}
.dash-cam-stop:hover { opacity: 0.85; }

.cam-slot-view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.cam-slot-view img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cam-slot-view .cam-placeholder {
    color: var(--text-muted);
    font-size: 0.75em;
    text-align: center;
    padding: 16px;
}

.cam-slot-view .cam-placeholder svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    display: block;
    margin: 0 auto 6px;
}

/* Events Panel (TrackSense pattern) */
.events-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.events-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.88em;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.events-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    min-height: 0;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    transition: background 0.15s;
    cursor: pointer;
}

.event-item:hover { background: rgba(255,255,255,0.03); }

.event-thumb {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #333;
    background: #111;
    flex-shrink: 0;
}

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

.event-type {
    font-weight: 600;
    font-size: 0.82em;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-meta {
    font-size: 0.65em;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-severity {
    font-size: 0.62em;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.event-severity.critical { background: rgba(220,38,38,0.15); color: var(--danger); }
.event-severity.high     { background: rgba(245,158,11,0.15); color: var(--warning); }
.event-severity.warning  { background: rgba(251,191,36,0.15); color: #fbbf24; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 12px;
    font-size: 0.82em;
}

/* Copyright */
.copyright-text {
    text-align: center;
    font-size: 0.72em;
    color: var(--text-muted);
    padding: 2px 0;
    flex-shrink: 0;
}

/* Light theme overrides */
[data-theme="light"] .event-item:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .event-thumb { border-color: var(--border-color); background: var(--bg-tertiary); }
[data-theme="light"] .cam-slot { background: var(--bg-tertiary); }

/* ==================== Responsive ==================== */

@media (max-width: 1400px) {
    .dashboard-grid { grid-template-columns: 1fr 300px; }
}

@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr 260px; }
}

@media (max-width: 1024px) {
    .page-content {
        height: auto;
        overflow: auto;
    }
    .main-area {
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .camera-grid-2x2 {
        min-height: 50vh;
    }
    .events-panel { max-height: 50vh; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .stats-row .stat-card { padding: 6px 8px; gap: 6px; }
    .stats-row .stat-icon { width: 28px; height: 28px; }
    .stats-row .stat-icon svg { width: 14px; height: 14px; }
    .stats-row .stat-label { font-size: 0.58em; }
    .stats-row .stat-value { font-size: 1.1em; }
    .camera-grid-2x2 { grid-template-columns: 1fr; grid-template-rows: auto; gap: 4px; }
    .cam-slot-view { min-height: 25vh; }
    .events-panel { max-height: 60vh; }
    .events-header { font-size: 0.82em; padding: 8px 10px; }
    .event-item { padding: 5px; gap: 6px; }
    .event-thumb { width: 40px; height: 30px; }
    .event-type { font-size: 0.78em; }
    .event-meta { font-size: 0.6em; }
}
