/* NexHome Security Monitor Page */

.security-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Camera Section */
.camera-section {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.camera-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: var(--text-primary);
}

.camera-header h3 i {
  color: var(--accent-cyan);
}

.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  overflow: hidden;
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.camera-status {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

.camera-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.camera-status .status-dot.active {
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Right Panel */
.security-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-card-header h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.panel-card-header h4 i {
  color: var(--accent-cyan);
  font-size: 0.85rem;
}

.panel-card-body {
  padding: 14px 18px;
}

/* Face Library */
.face-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
}

.face-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.face-item-photo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-cyan);
  flex-shrink: 0;
}

.face-item-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.face-item-info {
  flex: 1;
  min-width: 0;
}

.face-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.face-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Add Face Form */
.add-face-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
}

.add-face-preview {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.add-face-preview video,
.add-face-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.add-face-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-form-row {
  display: flex;
  gap: 8px;
}

.face-form-row input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.face-form-row input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* Alert List */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.alert-item.dismissed {
  opacity: 0.5;
  border-color: var(--border-subtle);
}

.alert-snapshot {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.alert-info {
  flex: 1;
  min-width: 0;
}

.alert-info .alert-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 6px;
}

.alert-info .alert-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Dashboard Alert Toast */
.face-alert-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: var(--bg-elevated);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 14px;
  padding: 16px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideInRight 0.3s ease;
}

.face-alert-toast-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.face-alert-toast-header i {
  color: var(--color-danger);
  font-size: 1.2rem;
}

.face-alert-toast-header span {
  font-weight: 600;
  color: var(--color-danger);
  font-size: 0.9rem;
}

.face-alert-toast-header .close-btn {
  margin-left: auto;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.face-alert-toast img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 10px;
}

.face-alert-toast .alert-actions {
  display: flex;
  gap: 8px;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 900px) {
  .security-layout {
    grid-template-columns: 1fr;
  }
}

/* ========== AI Camera Monitor ========== */

.camera-manage-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.camera-manage-bar select {
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  min-width: 140px;
}

.camera-live-view {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-live-view video,
.camera-live-view img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-live-view .no-feed {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.camera-live-view .no-feed i {
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.3;
}

.monitor-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.monitor-badge.active {
  background: rgba(52, 211, 153, 0.15);
  color: var(--color-success);
}

.monitor-badge.inactive {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.analysis-result {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-top: 8px;
}

.analysis-result.safe {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--color-success);
}

.analysis-result.danger {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--color-danger);
}

/* Safety Alert Item (extended) */
.safety-alert-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.safety-alert-item.dismissed {
  opacity: 0.5;
  border-color: var(--border-subtle);
}

.safety-alert-item .severity-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.severity-badge.critical { background: rgba(220, 38, 38, 0.2); color: #ef4444; }
.severity-badge.high { background: rgba(249, 115, 22, 0.2); color: #f97316; }
.severity-badge.medium { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.severity-badge.low { background: rgba(148, 163, 184, 0.2); color: var(--text-muted); }

/* Add Camera Form */
.add-camera-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.add-camera-form input,
.add-camera-form select {
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.add-camera-form input:focus,
.add-camera-form select:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* Camera list */
.camera-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.camera-list-item .cam-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.camera-list-item .cam-info {
  flex: 1;
  min-width: 0;
}

.camera-list-item .cam-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.camera-list-item .cam-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Safety alert toast (fullscreen overlay) */
.safety-alert-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: var(--bg-elevated);
  border: 2px solid rgba(248, 113, 113, 0.6);
  border-radius: 14px;
  padding: 16px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(248, 113, 113, 0.2), 0 4px 16px rgba(0,0,0,0.4);
  animation: slideInRight 0.3s ease;
}

.safety-alert-toast .toast-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.safety-alert-toast .toast-header i {
  color: var(--color-danger);
  font-size: 1.3rem;
  animation: pulse-alert 1s infinite;
}

@keyframes pulse-alert {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.safety-alert-toast .toast-header span {
  font-weight: 600;
  color: var(--color-danger);
  font-size: 0.95rem;
  flex: 1;
}

.safety-alert-toast img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 10px;
  max-height: 200px;
  object-fit: cover;
}

.safety-alert-toast .toast-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.safety-alert-toast .toast-actions {
  display: flex;
  gap: 8px;
}
