/* main-right.css - Mobile-Optimized Version */

/* New container for QR and Camera to group them */
.qr-camera-group-container {
  flex: 1 1 100%; /* Full width on mobile */
  max-width: 100%; /* Ensure it doesn't exceed */
  display: flex;
  flex-direction: column; /* Stacks QR/Camera row and Carousel vertically */
  gap: 0.5rem; /* Reduced gap for mobile */
  align-items: stretch;
  height: auto; /* Auto height on mobile */
  min-height: 0;
  position: relative;

  background-color: var(--sidebar-bg);
  border-radius: 0; /* No border-radius on mobile for full-width layout */
  box-shadow: none; /* No shadow on mobile */
  padding: 0.5rem; /* Reduced padding for mobile */
  box-sizing: border-box;
  overflow: hidden;
}

/* Desktop/Tablet styles for qr-camera-group-container */
@media (min-width: 768px) { /* md breakpoint */
    .qr-camera-group-container {
        flex: 1 1 0%; /* Allows it to grow and shrink, taking available horizontal space */
        gap: 0.75rem;
        height: 100%;
        border-radius: var(--radius-md);
        box-shadow: var(--card-shadow-medium);
        padding: 0.75rem;
    }
}

/* This container holds the QR and Camera side-by-side */
.qr-camera-top-row {
  display: flex;
  flex-direction: column; /* Stack QR and Camera vertically on mobile */
  gap: 0.5rem; /* Reduced gap for mobile */
  align-items: stretch; /* Stretch items to fill width */
  flex: 1;
  flex-shrink: 0;
  overflow: hidden;
}
@media (min-width: 768px) { /* md breakpoint */
    .qr-camera-top-row {
        flex-direction: row; /* QR and Camera side-by-side on desktop */
        gap: 0.75rem;
        align-items: flex-start;
        /* Ensure its children (QR and camera) fill its height if needed */
        height: 100%; 
    }
}

/* Video Frame and Placeholder (now contains webcam video & output canvas) */
#cameraPreview {
  flex: 1; /* This is shorthand for flex-grow: 1, flex-shrink: 1, flex-basis: 0% */
  min-width: unset; /* Remove min-width on mobile */
  background-color: black;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px;
  box-shadow: var(--card-shadow-medium);
  position: relative;
  height: auto;

  /* CRITICAL FIX: Fixed aspect ratio for video container */
  aspect-ratio: 16 / 9; /* Ensure video always maintains 16:9 ratio */
}
@media (min-width: 768px) { /* md breakpoint */
    #cameraPreview {
        min-width: 280px;
        flex: 1; /* SURGICAL FIX: Ensure flex-grow is explicitly applied on desktop */
    }
}

.camera-preview-heading {
  font-size: 1rem; /* Reduced font size for mobile */
  margin-bottom: 6px; /* Reduced margin for mobile */
  color: white;
  font-weight: 700;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
}
@media (min-width: 768px) { /* md breakpoint */
    .camera-preview-heading {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
}

/* Style for the actual output canvas that displays the video */
#outputCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Hidden video element for MediaPipe input */
#webcam {
    display: none;
}


.video-placeholder {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1rem; /* Reduced font size for mobile */
  z-index: 2;
  transition: opacity 0.3s ease;
  gap: 6px; /* Reduced gap for mobile */
  cursor: pointer;
}
@media (min-width: 768px) { /* md breakpoint */
    .video-placeholder {
        font-size: 1.1rem;
        gap: 8px;
    }
}

.video-placeholder i {
  font-size: 2rem; /* Reduced icon size for mobile */
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.9);
}
@media (min-width: 768px) { /* md breakpoint */
    .video-placeholder i {
        font-size: 2.5rem;
    }
}

.video-placeholder p {
  font-size: 0.8rem; /* Reduced font size for mobile */
  font-weight: 600;
  color: rgba(255, 255, 255, 1);
}
@media (min-width: 768px) { /* md breakpoint */
    .video-placeholder p {
        font-size: 0.85rem;
    }
}

.video-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.btn-start-media-inline {
  padding: 5px 10px; /* Reduced padding for mobile */
  font-size: 0.8rem; /* Reduced font size for mobile */
  font-weight: 600;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px; /* Reduced gap for mobile */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
@media (min-width: 768px) { /* md breakpoint */
    .btn-start-media-inline {
        padding: 6px 12px;
        font-size: 0.9rem;
        gap: 5px;
    }
}

.btn-start-media-inline:hover {
  background: #0c8ec4;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* New button to toggle camera controls overlay */
#toggleCameraControlsBtn {
  position: absolute;
  top: 8px;
  right: 8px;
  transform: translateX(0%);
  z-index: 9;
  padding: 4px 8px; /* Reduced padding for mobile */
  font-size: 0.7rem; /* Reduced font size for mobile */
  background-color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(5px);
  transition: all 0.2s ease;
  color: var(--text-dark);
}
@media (min-width: 768px) { /* md breakpoint */
    #toggleCameraControlsBtn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

#toggleCameraControlsBtn:hover {
  background-color: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}


/* Avatar preview (top-left of video) */
.avatar-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--sidebar-bg);
  color: var(--text-dark);
  font-weight: 700;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
  text-transform: uppercase;
  border: 1px solid var(--sidebar-border);
  width: 30px; /* Reduced size for mobile */
  height: 30px; /* Reduced size for mobile */
  font-size: 1rem; /* Reduced font size for mobile */
  border-radius: 50%;
  transition: opacity 0.3s ease, border-radius 0.3s ease;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 7;
  flex-shrink: 0;
  visibility: hidden;
}
@media (min-width: 768px) { /* md breakpoint */
    .avatar-preview {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
}

.avatar-preview.rounded-square {
  border-radius: var(--radius-sm);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* QR CODE SECTION (Consolidated and scaled) */
/* This section is now inside .qr-quick-join-wrapper in main-left.css */
.qr-code-section {
  /* Resetting styles that might conflict with new parent */
  flex: none;
  max-width: none;
  padding: 0;
  background-color: transparent;
  border-radius: 0;
  box-shadow: none;
  height: auto;
  min-height: unset;
  margin-top: 0;
  gap: 4px; /* Default gap, can be overridden by parent */
}
@media (min-width: 768px) { /* md breakpoint */
    .qr-code-section {
        flex: none; /* No flex basis here */
        max-width: none;
        min-height: unset;
    }
}

.qr-code-section h4 {
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 2px;
  text-align: center;
  color: var(--text-dark);
}

/* Phone status indicator (compact) */
.phone-status-box {
  margin-top: 5px;
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-light);
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 2px;
}

.phone-status-box i {
  font-size: 0.7rem;
  transition: color 0.3s ease;
}

.phone-status-box.connected {
  color: var(--accent);
  border-color: var(--accent);
}

.phone-status-box.disconnected {
  color: var(--danger);
  border-color: var(--danger);
}

/* QR visual blocks (shared styles) */
/* These are now styled within .qr-quick-join-wrapper in index.html <style> */
.qr-svg-holder,
.qr-overlay {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--container-bg);
  padding: 2px;
  border-radius: var(--radius-sm);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.2), /* Adjusted shadow for mobile */
    0 1px 4px rgba(0, 0, 0, 0.08) inset; /* Adjusted shadow for mobile */
  transform: rotateX(8deg) rotateY(-8deg) translateZ(10px); /* Adjusted transform for mobile */
  transition: transform 0.4s ease, box-shadow 0.3s ease, opacity 0.3s ease;
  text-align: center;
  will-change: transform, box-shadow;
}

/* Hover animation for both QR elements */
.qr-code-section:hover .qr-svg-holder,
.qr-code-section:hover .qr-overlay {
  transform: rotateX(0deg) rotateY(0deg) scale(1.05); /* Adjusted scale on hover for mobile */
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4), /* Adjusted shadow on hover for mobile */
    0 3px 8px rgba(0, 0, 0, 0.2) inset; /* Adjusted shadow on hover for mobile */
}

/* QR Canvas */
#qrCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Small hint text under QR */
.qr-overlay .input-hint {
  font-size: 0.5rem;
  margin-top: 1px;
  opacity: 0.8;
}

/* Visibility toggles */
.qr-svg-holder.hidden,
.qr-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* ──────────────────────────────────────────────────────────────────────────
   CAMERA BACKGROUND CAROUSEL
────────────────────────────────────────────────────────────────────────── */
.background-carousel-container {
  width: 100%;
  padding: 0px;
  margin-top: 0.5rem; /* Reduced margin for mobile */
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 6px; /* Reduced gap for mobile */
  -webkit-overflow-scrolling: touch;
  height: 70px; /* Reduced fixed height for mobile */
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  border-top: 1px solid var(--sidebar-border);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  box-shadow: var(--inner-shadow);
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}
@media (min-width: 768px) { /* md breakpoint */
    .background-carousel-container {
        margin-top: 0.75rem;
        gap: 8px;
        height: 80px;
    }
}

/* Custom scrollbar for Webkit browsers */
.background-carousel-container::-webkit-scrollbar {
  height: 6px;
}

.background-carousel-container::-webkit-scrollbar-track {
  background: transparent;
}

.background-carousel-container::-webkit-scrollbar-thumb {
  background-color: var(--sidebar-border);
  border-radius: 3px;
}

.background-carousel-container::-webkit-scrollbar-thumb:hover {
  background: #d8b4fe;
}

.carousel {
  display: flex;
  flex-direction: row;
  gap: 6px; /* Reduced gap for mobile */
  align-items: center;
  height: 100%;
}
@media (min-width: 768px) { /* md breakpoint */
    .carousel {
        gap: 8px;
    }
}

.carousel-item {
  flex-shrink: 0;
  width: 80px; /* Reduced width for mobile */
  height: 40px; /* Reduced height for mobile */
  border-radius: var(--radius-sm);
  background-color: var(--container-bg);
  border: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column; /* Stack thumbnail and text vertically */
  justify-content: center;
  align-items: center;
  font-size: 0.65rem; /* Reduced font size for mobile */
  color: var(--text-light);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  text-align: center;
  gap: 4px; /* Gap between thumbnail and text */
}
@media (min-width: 768px) { /* md breakpoint */
    .carousel-item {
        width: 100px;
        height: 50px;
        font-size: 0.7rem;
        gap: 5px;
    }
}

.carousel-item:hover {
  transform: translateY(-2px) scale(1.02); /* Adjusted hover for mobile */
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1); /* Adjusted shadow for mobile */
  border-color: var(--sidebar-border);
}
@media (min-width: 768px) { /* md breakpoint */
    .carousel-item:hover {
        transform: translateY(-3px) scale(1.05);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}

.carousel-item.active {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: scale(1.01); /* Adjusted scale when active for mobile */
  font-weight: 600;
  color: var(--text-dark);
  background-color: var(--container-bg);
}
@media (min-width: 768px) { /* md breakpoint */
    .carousel-item.active {
        transform: scale(1.02);
    }
}

/* Specific background styles for carousel items (dummy examples) */
/* These are now handled by the img tags or specific CSS in index.html <style> */
.carousel-item[data-bg="gradient1"] { background: none; } /* Reset background if img is used */
.carousel-item[data-bg="pattern1"] { background: none; } /* Reset background if img is used */
.carousel-item[data-bg="cityscape"] { background: none; } /* Reset background if img is used */
.carousel-item[data-bg="forest"] { background: none; } /* Reset background if img is used */
.carousel-item[data-bg="virtual"] { background: none; } /* Reset background if img is used */


/* ──────────────────────────────────────────────────────────────────────────
   CAMERA CONTROLS PANEL
────────────────────────────────────────────────────────────────────────── */
#cameraControls.camera-controls-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%; /* Full width on mobile */
  height: 100%;
  background-color: rgba(255, 255, 255, 0.98);
  box-shadow: none; /* No shadow on mobile */
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  display: flex;
  flex-direction: column;
  padding: 0.8rem; /* Reduced padding for mobile */
  z-index: 10;
  border-radius: 0; /* No border-radius on mobile */
  border-left: none; /* No border on mobile */
}
@media (min-width: 768px) { /* md breakpoint */
    #cameraControls.camera-controls-panel {
        width: 280px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
        padding: 1rem;
        border-radius: var(--radius-md);
        border-left: 1px solid var(--sidebar-border);
    }
}

/* When active */
#cameraControls.camera-controls-panel.show-overlay {
  transform: translateX(0);
}

/* Close button for camera controls panel */
#cameraControls .close-panel-btn {
  position: absolute;
  top: 6px; /* Adjusted position for mobile */
  right: 6px; /* Adjusted position for mobile */
  background: none;
  border: none;
  font-size: 1.1rem; /* Reduced font size for mobile */
  color: var(--text-light);
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
  z-index: 11;
  padding: 3px; /* Reduced padding for mobile */
  border-radius: 50%;
}
@media (min-width: 768px) { /* md breakpoint */
    #cameraControls .close-panel-btn {
        top: 8px;
        right: 8px;
        font-size: 1.3rem;
        padding: 4px;
    }
}

#cameraControls .close-panel-btn:hover {
  color: var(--text-dark);
  transform: rotate(90deg);
}

.controls-heading {
  font-size: 1.2rem; /* Reduced font size for mobile */
  margin-bottom: 8px; /* Reduced margin for mobile */
  color: var(--text-dark);
  font-weight: 700;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
}
@media (min-width: 768px) { /* md breakpoint */
    .controls-heading {
        font-size: 1.4rem;
        margin-bottom: 10px;
    }
}

/* Specific button styles for camera controls */
#cameraControls .control-group {
  width: 100%;
  margin-bottom: 6px; /* Reduced margin-bottom for mobile */
}
@media (min-width: 768px) { /* md breakpoint */
    #cameraControls .control-group {
        margin-bottom: 8px;
    }
}

#cameraControls .control-group label {
  font-size: 0.75rem; /* Reduced font size for mobile */
  margin-bottom: 2px;
  color: var(--text-dark);
}
@media (min-width: 768px) { /* md breakpoint */
    .control-group label {
        font-size: 0.8rem;
    }
}

#cameraControls .control-group .input-field {
  padding: 4px 6px; /* Reduced padding for mobile */
  font-size: 0.75rem; /* Reduced font size for mobile */
  border: 1px solid var(--sidebar-border);
  background-color: var(--container-bg);
  border-radius: var(--radius-sm);
  color: var(--text-dark);
}
@media (min-width: 768px) { /* md breakpoint */
    .input-field {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
}

#cameraControls .input-field:focus {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: var(--focus-shadow), var(--inner-shadow);
  background-color: var(--container-bg);
}

#cameraControls .avatar-shape-selection {
  width: 100%;
  margin-top: 6px; /* Reduced margin for mobile */
  padding-top: 6px; /* Reduced padding for mobile */
  border-top: 1px solid var(--sidebar-border);
}
@media (min-width: 768px) { /* md breakpoint */
    .avatar-shape-selection {
        margin-top: 8px;
        padding-top: 8px;
    }
}

/* Styles for Avatar Image Upload */
.avatar-image-upload-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px; /* Reduced gap for mobile */
  margin-top: 6px; /* Reduced margin for mobile */
  padding-top: 6px; /* Reduced padding for mobile */
  border-top: 1px solid var(--sidebar-border);
}
@media (min-width: 768px) { /* md breakpoint */
    .avatar-image-upload-group {
        gap: 4px;
        margin-top: 8px;
        padding-top: 8px;
    }
}

.avatar-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px; /* Reduced gap for mobile */
  padding: 4px 8px; /* Reduced padding for mobile */
  font-size: 0.75rem; /* Reduced font size for mobile */
  font-weight: 600;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-light);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  width: 100%;
}
@media (min-width: 768px) { /* md breakpoint */
    .avatar-upload-label {
        gap: 6px;
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

.avatar-upload-label:hover {
  background-color: var(--sidebar-border);
  transform: translateY(-1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#avatarImageInput {
  display: none;
}

.uploaded-avatar-preview {
  width: 40px; /* Reduced size for mobile */
  height: 40px; /* Reduced size for mobile */
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--sidebar-border);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
  display: none;
}
@media (min-width: 768px) { /* md breakpoint */
    .uploaded-avatar-preview {
        width: 45px;
        height: 45px;
    }
}

.uploaded-avatar-preview.rounded-square {
  border-radius: var(--radius-sm);
}
