/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
}

h1 {
  font-size: 20px;
  font-weight: 300;
  color: #b0b0b0;
  letter-spacing: 0.5px;
}

/* Common Components */
.container {
  width: 100%;
}

.section {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  font-weight: 500;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

label {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="email"]:focus {
  border-color: #4a4a4a;
}

input[type="email"]::placeholder {
  color: #666;
}

textarea {
  width: 100%;
  padding: 14px 16px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: #4a4a4a;
}

textarea::placeholder {
  color: #666;
}

/* Buttons */
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

button {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

button:hover:not(:disabled) {
  background: #3a3a3a;
  border-color: #4a4a4a;
}

button:active:not(:disabled) {
  background: #2a2a2a;
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: #e0e0e0;
  color: #0a0a0a;
  border-color: #e0e0e0;
}

button.primary:hover:not(:disabled) {
  background: #f0f0f0;
  border-color: #f0f0f0;
}

/* Record Control */
.record-control {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 3px solid #3a3a3a;
  cursor: pointer;
  transition: all 0.2s;
  flex: 0 0 auto;
  min-width: auto;
}

.record-control:hover:not(:disabled) {
  border-color: #4a4a4a;
  transform: scale(1.05);
}

.record-control:active:not(:disabled) {
  transform: scale(0.95);
}

.record-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.record-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ff4444;
  display: block;
  transition: all 0.3s ease;
}

.record-circle[class-active="true"] {
  background: #ff0000;
  border-radius: 4px;
  box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.3);
  animation: pulse 1.5s ease-in-out infinite;
}

.record-control:disabled .record-circle {
  background: #666;
}

.record-control[class-recording="true"] {
  border-color: #ff0000;
}

/* Restart Control */
.restart-control {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 3px solid #3a3a3a;
  cursor: pointer;
  transition: all 0.2s;
  flex: 0 0 auto;
  min-width: auto;
}

.restart-control:hover {
  border-color: #4a4a4a;
  transform: scale(1.05) rotate(180deg);
}

.restart-control:active {
  transform: scale(0.95) rotate(180deg);
}

.restart-icon {
  font-size: 32px;
  color: #e0e0e0;
  display: block;
  transition: transform 0.3s ease;
}

.restart-control:hover .restart-icon {
  transform: rotate(180deg);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 0, 0, 0.1);
  }
}

/* Recording indicator on video */
.video-container.recording::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 16px;
  width: 16px;
  height: 16px;
  background: #ff0000;
  border-radius: 50%;
  z-index: 10;
  animation: blink 1s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(255, 0, 0, 0.3);
}

.video-container.recording::after {
  content: 'REC';
  position: absolute;
  top: 16px;
  left: 40px;
  background: rgba(0, 0, 0, 0.7);
  color: #ff0000;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  z-index: 10;
  letter-spacing: 1px;
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Video */
video {
  width: 100%;
  background: #000;
  border-radius: 8px;
}

/* Status Messages */
.error {
  color: #ff6b6b;
  font-size: 13px;
  padding: 8px 0;
  text-align: center;
}

.error.full {
  padding: 16px;
  background: #2a1a1a;
  border: 1px solid #4a2a2a;
  border-radius: 4px;
}

.success {
  color: #51cf66;
  font-size: 13px;
  padding: 8px 0;
  text-align: center;
}

/* Utility Classes */
.hidden {
  display: none;
}

.empty-state {
  color: #888;
}

/* Spinner */
.spinner {
  border: 2px solid #2a2a2a;
  border-top: 2px solid #e0e0e0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

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

/* Status Badges */
.status {
  font-size: 16px;
  margin: 20px 0;
  padding: 20px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.status-uploaded {
  color: #888;
}

.status-processing {
  color: #e0e0e0;
}

.status-completed {
  color: #51cf66;
}

.status-failed {
  color: #ff6b6b;
}

/* Page-specific: Index/Upload Page */
body.upload-page {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  min-height: 100vh;
  height: auto;
  overflow: auto;
}

body.upload-page .container {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-height: 100vh;
}

/* Video upload component container */
video-upload {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

body.upload-page h1 {
  display: none; /* Hide h1 on mobile - no title needed */
}

.video-container {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  min-height: 50vh;
  width: 100%;
  overflow: hidden;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-width: 100%;
  max-height: 100%;
}

.controls {
  background: #1a1a1a;
  border-top: 1px solid #2a2a2a;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
}

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

/* Page-specific: Processing Page */
body.processing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.processing-page .container {
  text-align: center;
  max-width: 400px;
}

body.processing-page h1 {
  margin-bottom: 40px;
}

.processing-page #message {
  margin-top: 16px;
  color: #888;
  font-size: 14px;
}

/* Page-specific: Result Page */
body.result-page {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

body.result-page h1 {
  font-size: 24px;
  margin-bottom: 30px;
  text-align: center;
}

body.result-page video {
  max-width: 800px;
  display: block;
  margin: 0 auto;
}

.transcript {
  background: #2a2a2a;
  padding: 16px;
  border-radius: 4px;
  line-height: 1.6;
  color: #d0d0d0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.keyframes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.keyframe-item {
  position: relative;
  background: #2a2a2a;
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 16/9;
}

.keyframe-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.keyframe-timestamp {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #e0e0e0;
  font-size: 11px;
  padding: 4px 6px;
  text-align: center;
}

.email-content {
  background: #2a2a2a;
  padding: 20px;
  border-radius: 4px;
}

.email-subject {
  font-size: 18px;
  font-weight: 500;
  color: #e0e0e0;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #3a3a3a;
}

.email-body {
  line-height: 1.8;
  color: #d0d0d0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

/* Responsive - Desktop adjustments */
@media (min-width: 768px) {
  body.upload-page {
    padding: 20px;
    overflow: auto;
  }

  body.upload-page .container {
    max-width: 600px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    height: auto;
    min-height: 600px;
    max-height: 90vh;
  }

  body.upload-page h1 {
    font-size: 24px;
    padding: 16px;
  }

  .controls {
    padding: 24px;
  }

  .keyframes-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

