* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    overflow-x: hidden;
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #2c2c2c;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
    position: relative;
    z-index: 100;
}

header h1 {
    color: #00ff88;
    font-size: 24px;
    font-weight: bold;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.camera-selector {
    position: relative;
}

.selector-btn {
    padding: 10px 16px;
    background-color: #444;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    min-width: 140px;
    justify-content: space-between;
}

.selector-btn:hover {
    background-color: #555;
}

.selector-btn.active {
    background-color: #00ff88;
    color: #000;
}

.selected-count {
    color: #00ff88;
    font-weight: bold;
    font-size: 12px;
}

.selector-btn.active .selected-count {
    color: #000;
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.selector-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.selector-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    min-width: 280px;
    max-height: 350px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.selector-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 15px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #333;
    border-radius: 8px 8px 0 0;
}

.dropdown-header span {
    color: #00ff88;
    font-weight: bold;
    font-size: 14px;
}

.dropdown-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 4px 8px;
    background-color: #444;
    border: none;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    transition: background-color 0.3s ease;
}

.action-btn:hover {
    background-color: #555;
}

.camera-options {
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
}

.camera-option {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-bottom: 2px;
}

.camera-option:hover {
    background-color: rgba(0, 255, 136, 0.1);
}

.camera-option input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    transform: scale(1.1);
}

.camera-option label {
    color: #fff;
    cursor: pointer;
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.camera-location {
    color: #aaa;
    font-size: 11px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.grid-controls {
    display: flex;
    gap: 10px;
}

.view-controls {
    display: flex;
    gap: 10px;
}

.grid-btn {
    padding: 8px 16px;
    background-color: #444;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.grid-btn:hover {
    background-color: #555;
}

.grid-btn.active {
    background-color: #00ff88;
    color: #000;
}

.view-btn {
    padding: 8px 16px;
    background-color: #444;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.view-btn:hover {
    background-color: #555;
}

/* 視訊適應模式控制 */
.video-fit-controls {
    display: flex;
    gap: 5px;
}

.fit-btn {
    padding: 8px 12px;
    background-color: #444;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.fit-btn.active {
    background-color: #00ff88;
    color: #000;
}

.fit-btn:hover {
    background-color: #555;
}

.fit-btn.active:hover {
    background-color: #00cc6a;
}

.view-btn.active {
    background-color: #00ff88;
    color: #000;
}

.main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 80px);
}

.camera-section {
    flex: 2;
    padding: 20px;
    background-color: #1e1e1e;
}

.camera-grid {
    display: grid;
    gap: 15px;
    height: 100%;
    width: 100%;
}

.camera-grid.grid-1x1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.camera-grid.grid-1x2 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, 1fr);
}

.camera-grid.grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.camera-grid.grid-2x3 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.camera-grid.grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.camera-item {
    background-color: #2a2a2a;
    border: 2px solid #444;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: border-color 0.3s ease;
    min-height: 200px;
}

.camera-item:hover {
    border-color: #00ff88;
}

.camera-item.offline {
    border-color: #ff4444;
}

.camera-video {
    flex: 1;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 150px;
}

.camera-video img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-placeholder {
    color: #666;
    font-size: 18px;
    text-align: center;
}

.camera-info {
    background-color: rgba(0, 0, 0, 0.9);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #444;
    min-height: 50px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.camera-name {
    font-weight: bold;
    color: #00ff88;
    font-size: 14px;
}

.camera-weight {
    font-size: 14px;
    color: #ffff00;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.weight-value {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

.weight-unit {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

/* 重量狀態樣式 */
.weight-display {
    position: relative;
    transition: all 0.3s ease;
}

.weight-display.weight-stable {
    color: #00ff88; /* 綠色 - 穩定 */
}

.weight-display.weight-weighing {
    color: #ffaa00; /* 橙色 - 稱重中 */
    animation: weight-blink 1.5s infinite;
}

.weight-display.weight-error {
    color: #ff4444; /* 紅色 - 異常 */
    animation: weight-pulse 1s infinite;
}

/* 重量狀態動畫 */
@keyframes weight-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

@keyframes weight-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 資料來源指示器 */
.data-source {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    line-height: 1;
}

.data-source.live-data {
    background-color: #00ff88;
    color: #000;
}

.data-source.demo-data {
    background-color: #666;
    color: #fff;
}

.status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #00ff88;
}

.status-indicator.offline {
    background-color: #ff4444;
}

.event-section {
    flex: 1;
    background-color: #262626;
    border-left: 2px solid #444;
    display: flex;
    flex-direction: column;
}

.section-header {
    padding: 20px;
    border-bottom: 2px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    color: #00ff88;
    font-size: 20px;
}

.event-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    background-color: #2a2a2a;
    border-bottom: 2px solid #444;
    padding: 0 20px;
}

.tab-btn {
    padding: 12px 20px;
    background-color: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #fff;
    background-color: rgba(0, 255, 136, 0.1);
}

.tab-btn.active {
    color: #00ff88;
    border-bottom-color: #00ff88;
    background-color: rgba(0, 255, 136, 0.1);
}

.tab-count {
    background-color: #00ff88;
    color: #000;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.tab-count.warning {
    background-color: #ff4444;
    color: #fff;
}

.tab-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.tab-panel.active {
    opacity: 1;
    visibility: visible;
}

.event-list {
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
}

.event-list.card-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: auto;
    gap: 10px;
    padding-right: 10px;
    align-content: start;
}

.event-item {
    display: flex;
    gap: 15px;
    padding: 10px;
    margin: 5px 0;
    background-color: #333;
    border-radius: 8px;
    border-left: 3px solid #00ff88;
    transition: all 0.3s ease;
}

.event-item:hover {
    background-color: #333;
    transform: translateX(5px);
}

.event-item.warning {
    border-left-color: #ff4444;
}

.event-item.warning .event-type {
    color: #ff4444;
}

.event-thumbnail {
    width: 80px;
    height: 60px;
    background-color: #000;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
}

.event-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.event-camera {
    font-weight: bold;
    color: #00ff88;
    font-size: 14px;
}

.event-time {
    color: #aaa;
    font-size: 12px;
}

.event-description {
    color: #ddd;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 5px;
}

.event-type {
    color: #00ff88;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: bold;
}

/* 卡片檢視模式樣式 */
.event-list.card-view .event-item {
    flex-direction: column;
    padding: 10px;
    min-height: 100px;
    margin: 0;
}

.event-list.card-view .event-thumbnail {
    width: 100%;
    height: 50px;
    margin-bottom: 8px;
}

.event-list.card-view .event-details {
    gap: 5px;
}

.event-list.card-view .event-header {
    margin-bottom: 5px;
}

.event-list.card-view .event-camera {
    font-size: 12px;
}

.event-list.card-view .event-time {
    font-size: 10px;
}

.event-list.card-view .event-description {
    font-size: 11px;
    margin-bottom: 5px;
    flex: 1;
    line-height: 1.3;
}

.event-list.card-view .event-type {
    font-size: 10px;
}

/* 事件區塊樣式 */
.event-section-warning,
.event-section-others {
    margin-bottom: 20px;
}

.event-section-warning:last-child,
.event-section-others:last-child {
    margin-bottom: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: #2a2a2a;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: bold;
    color: #00ff88;
    border-bottom: 2px solid #444;
}

.event-count {
    background-color: #444;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.event-section-warning .event-count {
    background-color: #ff4444;
}

.event-section-warning .event-list,
.event-section-others .event-list {
    background-color: #333;
    border-radius: 0 0 8px 8px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.event-section-warning .event-list.card-view,
.event-section-others .event-list.card-view {
    grid-template-columns: repeat(3, 1fr);
    align-content: start;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background-color: #333;
}

::-webkit-scrollbar-thumb {
    background-color: #666;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #888;
}