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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #c4bbf0;
  min-height: 100vh;
  color: white;
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  position: relative;
}

/* Loading Screen */
.loading-screen,
.error-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content,
.error-content {
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 64px;
  height: 64px;
  border: 4px solid rgba(139, 92, 246, 0.3);
  border-top: 4px solid #8b5cf6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-content h2,
.error-content h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #52357B;
}

.loading-content p,
.error-content p {
  color: #ffff;
  font-size: 0.9rem;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.refresh-btn {
  background: #8b5cf6;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 1rem;
  transition: background-color 0.2s;
}

.refresh-btn:hover {
  background: #7c3aed;
}

.hidden {
  display: none !important;
}

/* Main Application */
.main-app {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 3rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  background-color: rgba(61, 9, 113, 0.992);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}


.container {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 2rem;
  }
}

/* Cards */
.card {
  background-color: #4f3b78;
  backdrop-filter: blur(10px);
  border: 1px solid rgb(248, 237, 245);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: white;
}

/* Camera Section */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.face-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #10b981;
  font-size: 0.875rem;
}

.face-status .status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.camera-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #5b3990;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.camera-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.camera-btn.stop {
  background: #ef4444;
  color: #ffff;
}

.camera-btn.stop:hover {
  background: #dc2626;
}

.video-container {
  position: relative;
  width: 100%;
  height: 380px;
  background: #d7d7d8;
  border-radius: 0.5rem;
  overflow: hidden;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#video.active {
  display: block;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-placeholder,
.camera-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eeeeee;
}

.camera-error {
  background: rgba(239, 68, 68, 0.1);
}

.placeholder-content,
.camera-error .error-content {
  text-align: center;
}

.placeholder-icon,
.camera-error .error-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.placeholder-content p,
.camera-error p {
  color: #9ca3af;
  font-size: 0.875rem;
}

.camera-error p {
  color: #fca5a5;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.loading {
  background: #f59e0b;
  animation: pulse 2s infinite;
}

.status-dot.ready {
  background: #10b981;
}

.status-dot.active {
  background: #3b82f6;
  animation: pulse 2s infinite;
}

.status-dot.inactive {
  background: #6b7280;
}

/* Current Emotion */
.current-emotion {
  text-align: center;
}

.emotion-display {
  padding: 1rem;
}

.emotion-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(139, 92, 246, 0.2);
  border: 2px solid #8b5cf6;
  transition: all 0.3s ease;
}

.emotion-name {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
  text-transform: capitalize;
}

.confidence-bar {
  width: 100%;
  height: 12px;
  background: #FCECDD;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.confidence-fill {
  height: 100%;
  background: #471396;
  width: 0%;
  transition: all 0.5s ease;
  border-radius: 6px;
}

.confidence-text {
  color: #ffff;
  font-size: 0.875rem;
}

/* Emotion History */
.emotion-history {
  max-height: 200px;
  overflow-y: auto;
}

.emotion-history .no-data {
  text-align: center;
  color: #9ca3af;
  font-style: italic;
}

.emotion-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.emotion-item:last-child {
  border-bottom: none;
}

.emotion-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.emotion-emoji {
  font-size: 1.25rem;
}

.emotion-label {
  text-transform: capitalize;
  font-weight: 500;
}

.emotion-confidence {
  color: #d1d5db;
  font-size: 0.875rem;
}

/* Statistics */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: white;
}

.stat-label {
  color: #d1d5db;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.most-frequent {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.frequent-emotion {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.frequent-label {
  color: #d1d5db;
}

.frequent-name {
  font-weight: 600;
  text-transform: capitalize;
}

.frequent-subtitle {
  color: #9ca3af;
  font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .main-app {
    padding: 0.5rem;
  }

  .card {
    padding: 1rem;
  }

  .card-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .controls {
    justify-content: center;
  }

  .video-container {
    height: 240px;
  }

  .status-bar {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.5s ease-out;
}

.emotion-item {
  animation: fadeIn 0.3s ease-out;
}

/* Scrollbar Styling */
.emotion-history::-webkit-scrollbar {
  width: 6px;
}

.emotion-history::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.emotion-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.emotion-history::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}