/* Shared Events dashboard styles — panel chrome + live grid + panel internals.
   Loaded globally so both the live page (/events) and the customize editor
   (/events/customize) render panels identically. */

/* ── Live grid ─────────────────────────────────────────────────────────────
   Panels are positioned by saved X/Y/W/H on a 12-column grid; rows use 1fr so
   the grid fills the available height exactly (the page does not scroll). */
.evt-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(var(--evt-rows, 11), 1fr);
    gap: 3px;
    overflow: hidden;
}

.evt-grid-cell {
    min-width: 0;
    min-height: 0;
    display: flex;
}

/* ── Panel chrome ──────────────────────────────────────────────────────────
   A framed card with a horizontal header bar and a flexible body. */
.evt-panel {
    box-sizing: border-box;
    width: 100%;
    background: var(--cas-canvas);
    border: 1px solid var(--cas-line);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

.evt-panel-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--cas-line);
    color: var(--cas-navy-700);
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 38px;
}

.evt-panel-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.evt-panel-header-spacer {
    flex: 1 1 auto;
}

.evt-panel-header .mud-input-root {
    margin: 0;
}

.evt-panel-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--cas-surface);
    position: relative;
}

.evt-panel-body .events-table-wrapper,
.evt-panel-body .events-stream-tray {
    flex: 1;
    min-height: 0;
}

/* ── Header chips & status ─────────────────────────────────────────────────── */
.events-section-caption {
    margin: 0;
}

.events-live-badge {
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.events-filter-chip {
    font-size: 0.65rem !important;
    cursor: default;
}

.events-filter-chip .mud-chip {
    height: 22px !important;
    padding: 0 8px !important;
    font-size: 0.65rem !important;
}

.events-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: events-live-pulse 1.5s ease-in-out infinite;
}

@keyframes events-live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.events-paused-chip {
    font-size: 0.6rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em;
    animation: events-paused-pulse 2s ease-in-out infinite;
}

@keyframes events-paused-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.events-pause-banner {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: color-mix(in srgb, var(--mud-palette-warning) 14%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-warning) 40%, transparent);
    color: var(--mud-palette-warning-darken);
    font-size: 0.72rem;
    font-weight: 500;
}

.events-pause-banner-icon {
    flex-shrink: 0;
    color: var(--mud-palette-warning-darken);
}

/* ── Events / alarms tables ────────────────────────────────────────────────── */
.events-table-wrapper {
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.events-table-wrapper > div {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.events-table-wrapper .mud-table-container {
    height: 100%;
    min-height: 0;
    overflow: auto;
}

.events-table-wrapper .mud-table th,
.events-table-wrapper .mud-table td {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.events-table-wrapper .mud-table {
    table-layout: fixed;
}

.events-table-wrapper .mud-table-body .mud-table-cell {
    overflow: hidden;
}

.events-table-wrapper .mud-table-body .mud-table-cell > div,
.events-table-wrapper .mud-table-body .mud-table-cell > span {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.events-table-wrapper .mud-table-cell {
    vertical-align: middle !important;
    padding-top: 4px;
    padding-bottom: 4px;
}

.events-table-wrapper .mud-table-head .mud-table-cell {
    vertical-align: middle !important;
    padding-top: 6px;
    padding-bottom: 6px;
}

.events-table-wrapper .mud-table-body .mud-table-row .mud-table-cell {
    vertical-align: middle !important;
}

.events-table-wrapper .mud-table-body .mud-table-cell > div,
.events-table-wrapper .mud-table-body .mud-table-cell > span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    vertical-align: middle;
}

.events-table-wrapper .events-td-info .mud-tooltip-inner,
.events-table-wrapper .events-td-info .mud-icon-root {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.events-th-time,
.events-td-time {
    width: 1%;
    max-width: 152px;
    white-space: nowrap;
}

.events-th-location,
.events-td-location {
    width: 50%;
    min-width: 140px;
}

.events-location-cell {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 100%;
}

.events-th-event-desc,
.events-td-event-desc {
    width: 50%;
    min-width: 140px;
}

.events-th-info,
.events-td-info {
    width: 1%;
    max-width: 64px;
}

.events-event-desc-text {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

/* ── Card image strip ──────────────────────────────────────────────────────── */
.events-stream-tray {
    background: rgba(0, 0, 0, 0.04);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding: 2px;
}

.image-stream-container {
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    margin: 0;
}

.image-stream-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-height: 100%;
}

.image-stream-item-inner {
    position: relative;
    display: block;
    max-width: 80px;
    max-height: 100%;
    height: 100%;
}

.image-stream-item-inner .image-stream-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 3/4;
    border-radius: 4px;
    object-fit: contain;
    vertical-align: top;
}

.image-stream-overlay-top,
.image-stream-overlay-bottom {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: 100%;
    padding: 1px 4px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.6rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    border-radius: 2px;
}

.image-stream-overlay-top {
    top: 0;
}

.image-stream-overlay-bottom {
    bottom: 0;
}

.image-stream-img {
    flex: 1 1 auto;
    min-height: 0;
    width: auto;
    max-width: 80px;
    max-height: 100%;
    aspect-ratio: 3/4;
    border-radius: 3px;
    object-fit: cover;
}

.image-stream-thumb {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ── Hover popups ──────────────────────────────────────────────────────────── */
.card-hover-popup {
    padding: 6px;
    min-width: 200px;
}

.card-hover-popup-details {
    font-size: 0.75rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.card-hover-popup-details div {
    margin-bottom: 1px;
}

.card-hover-popup-image {
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.card-hover-popup-image img {
    max-width: 200px;
    max-height: 240px;
    object-fit: contain;
}
