/* Global Styles */
:root {
  --primary-color: #1a1a2e;
  --secondary-color: #16213e;
  --accent-color: #0f3460;
  --text-primary: #eee;
  --text-secondary: #bbb;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --error-color: #f44336;
  --border-radius: 8px;
  --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--primary-color);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background-color: var(--secondary-color);
  padding: 1rem;
  box-shadow: var(--box-shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.status-bar {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.status-bar span {
  padding: 0.25rem 0.5rem;
  background-color: var(--accent-color);
  border-radius: var(--border-radius);
}

#connection-status.online {
  background-color: var(--success-color);
  color: white;
}

#connection-status.offline {
  background-color: var(--warning-color);
  color: white;
}

/* Main Content */
main {
  flex: 1;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Video Container */
.video-container {
  position: relative;
  background-color: var(--secondary-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--box-shadow);
  aspect-ratio: 16/9;
  transition: all 0.3s ease;
}

.video-container.maximized {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  z-index: 1000;
  aspect-ratio: auto;
}

#video-input,
#output-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#video-input {
  z-index: 1;
}

#output-canvas {
  z-index: 2;
  pointer-events: none;
}

.overlay-info {
  position: absolute;
  /* Position at bottom by default to avoid fullscreen button */
  bottom: 1rem;
  left: 1rem;
  z-index: 3;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  backdrop-filter: blur(4px);
  max-width: fit-content;
}

.video-container.maximized .overlay-info {
  bottom: 1rem;
  font-size: 1rem;
}

/* Ensure detection info is compact and doesn't interfere */
#detection-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* On larger screens, we can optionally position it at top left with offset */
@media (min-width: 1024px) {
  .overlay-info {
    /* Still keep at bottom to avoid any conflict with fullscreen button */
    bottom: 1rem;
    left: 1rem;
  }
}

@media (max-width: 768px) {
  .overlay-info {
    left: 1rem;
    right: 1rem;
    max-width: none;
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .overlay-info {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }
}

/* Fullscreen Button */
.fullscreen-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100; /* Very high z-index to ensure it's always on top */
  background-color: rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.75rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  /* Ensure button is always clickable */
  pointer-events: all;
}

.fullscreen-btn:hover {
  background-color: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

.fullscreen-btn svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  .fullscreen-btn {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.75rem; /* Ensure 44px minimum touch target */
    min-width: 44px;
    min-height: 44px;
    background-color: rgba(0, 0, 0, 0.9); /* More opaque on mobile */
  }
  
  /* Disable hover effects on touch devices */
  @media (hover: none) {
    .fullscreen-btn:hover {
      transform: none;
      background-color: rgba(0, 0, 0, 0.9);
    }
  }
  
  .fullscreen-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Controls */
.controls {
  background-color: var(--secondary-color);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  box-shadow: var(--box-shadow);
}

.controls > * {
  margin-bottom: 1rem;
}

.controls > *:last-child {
  margin-bottom: 0;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 0.5rem;
  font-weight: 500;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: #0d2d4f;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--text-primary);
  border: 1px solid var(--accent-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--accent-color);
}

/* Model Selector */
.model-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.model-selector label {
  font-weight: 500;
}

.model-selector select {
  padding: 0.5rem;
  background-color: var(--accent-color);
  color: var(--text-primary);
  border: 1px solid var(--accent-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  cursor: pointer;
}

/* Settings */
.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.settings input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
}

/* Results Panel */
.results-panel {
  background-color: var(--secondary-color);
  padding: 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  margin-bottom: 1rem;
}

.results-panel h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

#results-container {
  max-height: 300px;
  overflow-y: auto;
}

/* Console Panel */
.console-panel {
  background-color: var(--secondary-color);
  padding: 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.console-panel h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

#console-output {
  background-color: #000;
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  padding: 1rem;
  border-radius: var(--border-radius);
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.console-log {
  margin-bottom: 0.25rem;
}

.console-log.error {
  color: #ff5555;
}

.console-log.warn {
  color: #ffff55;
}

.console-log.info {
  color: #5555ff;
}

.console-log.success {
  color: #55ff55;
}

.detection-item {
  background-color: var(--accent-color);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: var(--border-radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detection-item:last-child {
  margin-bottom: 0;
}

.detection-label {
  font-weight: 500;
}

.detection-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Hide other elements when video is maximized */
body:has(.video-container.maximized) header,
.video-container.maximized ~ .controls,
.video-container.maximized ~ .results-panel,
.video-container.maximized ~ .console-panel {
  display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.25rem;
  }
  
  .status-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .status-bar span {
    font-size: 0.75rem;
  }
  
  .controls {
    padding: 0.75rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .model-selector {
    flex-direction: column;
    align-items: stretch;
  }
  
  .settings {
    flex-direction: column;
  }
  
  /* Adjust fullscreen button for mobile */
  .fullscreen-btn {
    padding: 0.5rem;
  }
  
  .fullscreen-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Loading Animation */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Attention pulse for fullscreen button */
@keyframes attention-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(77, 184, 255, 0.6);
  }
}

.fullscreen-btn.attention {
  animation: attention-pulse 2s ease-in-out 3; /* Pulse 3 times */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--secondary-color);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #0d2d4f;
}

/* Face Recognition Styles */
.face-recognition-controls {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.face-recognition-controls input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
}

.face-recognition-controls input[type="text"]:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.face-recognition-controls input[type="range"] {
    accent-color: #4CAF50;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: white;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
}

/* People List Styles */
.person-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.person-photos {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.person-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.person-info {
    flex: 1;
}

.person-name {
    font-size: 18px;
    font-weight: bold;
    color: white;
    margin-bottom: 5px;
}

.person-details {
    color: #ccc;
    font-size: 14px;
}

.person-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
}

.btn-danger {
    background: #f44336;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Recognition Status Styles */
.recognition-status {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10;
}

.recognition-status.known {
    background: rgba(76, 175, 80, 0.8);
}

.recognition-status.unknown {
    background: rgba(255, 152, 0, 0.8);
} 