/**
 * CertiSigma Bundle - Integration Container Styles
 * 
 * FIXED: Prevent horizontal overflow
 * 
 * @version 2.0.9
 */

/* ============================================================================
   PREVENT HORIZONTAL OVERFLOW - CRITICAL FIX
   ============================================================================ */

body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

/* ROUND 11 FIX: Reset all containers to prevent offset */
#bundleStagingSection,
#bundleActions,
.bundle-staging-container,
.actions-grid-container,
#bundleStagingMount,
#actionsGridMount {
  max-width: 100% !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ============================================================================
   BUNDLE STAGING SECTION - PERFECTLY CENTERED
   ============================================================================ */

#bundleStagingSection {
  width: 100%;
  max-width: 100%;
  margin: 0 auto var(--space-6) auto;
  padding: 0;
}

.bundle-staging-container {
  width: 100%;
  padding: 0;
  margin: 0 auto;
}

@media (max-width: 639px) {
  #bundleStagingSection {
    max-width: 100%;
    padding: 0;
    margin-bottom: var(--space-4);
  }
}

/* ============================================================================
   ACTIONS GRID - PERFECTLY CENTERED
   ============================================================================ */

#bundleActions {
  width: 100%;
  max-width: 100%;
  margin: 0 auto var(--space-6) auto;
  padding: 0;
}

@media (max-width: 639px) {
  #bundleActions {
    max-width: 100%;
    padding: 0;
    margin-bottom: var(--space-4);
  }
}

/* ============================================================================
   SECTION TITLES
   ============================================================================ */

.bundle-section-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  text-align: center;
}

@media (min-width: 640px) {
  .bundle-section-title {
    font-size: var(--text-2xl);
  }
}

/* ============================================================================
   INTEGRATION WITH EXISTING UI
   ============================================================================ */

/* Keep original hero buttons visible (for testing during development) */
/* Will be hidden later when new bundle system is fully tested */

/* ============================================================================
   VERIFICATION SECTION (separate)
   ============================================================================ */

.hero-verify-section {
  max-width: min(600px, calc(100vw - 2rem)) !important;
  margin: var(--space-8) auto;
  padding: var(--space-6);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 639px) {
  .hero-verify-section {
    margin: var(--space-6) var(--space-3);
    padding: var(--space-4);
  }
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .hero-verify-section {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
  }
}

/* ============================================================================
   MODAL OVERLAY
   ============================================================================ */

.modal-overlay {
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================================
   BUNDLE HEADER - CONDITIONAL (ROUND 10)
   ============================================================================ */

/* ROUND 10: Slide-down animation premium (cubic-bezier) */
@keyframes bundleHeaderSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bundle-header {
  animation: bundleHeaderSlideDown 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
  /* 0.34, 1.56, 0.64, 1 = elastic easing (wow effect!) */
}

.bundle-header--hidden {
  display: none !important;
  opacity: 0;
}

.bundle-header--visible {
  display: block !important;
  opacity: 1;
}

/* ============================================================================
   PHOTO PREVIEW MODAL (P1: Forensic UX)
   ============================================================================ */

.photo-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999999; /* ✅ CRITICAL FIX: Above header (999999) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 80px; /* ✅ SPACING: Compensate fixed header */
  padding-bottom: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.photo-preview-modal.active {
  opacity: 1;
  visibility: visible;
}

.photo-preview-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.photo-preview-modal-content {
  position: relative;
  width: 90%;
  max-width: 900px;
  max-height: calc(100vh - 100px); /* ✅ Leave space for site header */
  background: var(--bg-secondary, #ffffff);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* ✅ No scroll here - scroll in body only */
  transform: scale(0.9);
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.photo-preview-modal.active .photo-preview-modal-content {
  transform: scale(1);
}

.photo-preview-modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary, #ffffff);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}

.photo-preview-modal-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 46px);
}

.photo-preview-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #6b7280);
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
}

.photo-preview-modal-close:hover {
  background: var(--hover-bg, #f3f4f6);
  color: var(--text-primary, #111827);
}

.photo-preview-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

.photo-preview-modal-body::-webkit-scrollbar {
  width: 8px;
}

.photo-preview-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.photo-preview-modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.photo-preview-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

.photo-preview-modal-image {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: var(--bg-tertiary, #f9fafb);
}

.photo-preview-modal-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.photo-preview-modal-meta {
  padding: 12px 16px;
  padding-bottom: 48px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #ffffff);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  text-align: left !important; /* FORENSIC: Force left-align for all children */
}

.photo-preview-modal-meta .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
}

.photo-preview-modal-meta .meta-row svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.photo-preview-modal-meta .meta-row code {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  background: var(--bg-tertiary, #f3f4f6);
  padding: 4px 8px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .photo-preview-modal-content {
    width: 95%;
    max-height: calc(100vh - 80px);
  }
  
  .photo-preview-modal-header {
    padding: 6px 10px;
  }
  
  .photo-preview-modal-header h3 {
    font-size: 12px;
  }
  
  .photo-preview-modal-close {
    width: 26px;
    height: 26px;
  }
  
  .photo-preview-modal-close svg {
    width: 18px;
    height: 18px;
  }
  
  .photo-preview-modal-image {
    padding: 0px 4px;
  }
  
  .photo-preview-modal-meta {
    padding: 10px 12px;
    padding-bottom: 60px;
    font-size: 13px;
    gap: 8px;
  }
}

/* ============================================================================
   BUNDLE FORENSIC METADATA DISPLAY (v10.65.0 - Namespace Fix)
   CRITICAL: Prefixed with "bundle-" to avoid conflict with GPS modal classes
   ============================================================================ */

.bundle-forensic-section {
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: all 200ms ease;
  text-align: left !important; /* FORENSIC: Kill any inherited center alignment */
}

.bundle-forensic-section:hover {
  border-color: var(--primary-400, #60a5fa);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bundle-forensic-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.bundle-forensic-section-title svg {
  flex-shrink: 0;
  color: var(--primary-500, #3b82f6);
}

.bundle-forensic-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

.bundle-forensic-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 12px !important;
  min-height: 24px !important;
  text-align: left !important; /* FORENSIC: Force left-align (kill inherited center) */
  flex-direction: row !important; /* CRITICAL: Override GPS modal column layout */
}

.bundle-forensic-label {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-secondary, #6b7280) !important;
  flex-shrink: 0 !important;
  text-align: left !important; /* FORENSIC: Force left-align */
}

.bundle-forensic-value {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-primary, #111827) !important;
  text-align: right !important; /* FORENSIC: Force right-align */
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

.bundle-forensic-hash {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 11px;
  background: var(--bg-tertiary, #f3f4f6);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-secondary, #6b7280);
  border: 1px solid var(--border-color, #e5e7eb);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.bundle-forensic-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.bundle-forensic-badge--alto {
  /* Green - HIGH liveness */
  /* background set dynamically via inline style */
}

.bundle-forensic-badge--medio {
  /* Orange - MED liveness */
  /* background set dynamically via inline style */
}

.bundle-forensic-badge--basso {
  /* Red - LOW liveness */
  /* background set dynamically via inline style */
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .bundle-forensic-section {
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 10px;
  }
  
  .bundle-forensic-section-title {
    font-size: 13px;
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 6px;
  }
  
  .bundle-forensic-section-title svg {
    width: 14px;
    height: 14px;
  }
  
  .bundle-forensic-grid {
    gap: 8px;
  }
  
  .bundle-forensic-row {
    min-height: 22px;
    gap: 10px;
    flex-direction: row !important; /* CRITICAL: Stay horizontal on mobile */
  }
  
  .bundle-forensic-label {
    font-size: 12px;
  }
  
  .bundle-forensic-value {
    font-size: 12px;
  }
  
  .bundle-forensic-hash {
    font-size: 10px;
    padding: 3px 6px;
    max-width: 140px;
  }
  
  .bundle-forensic-badge {
    padding: 3px 8px;
    font-size: 11px;
  }
}

/* ============================================================================
   GPS ACTIONS BUTTONS (v10.67.0 - Forensic UX)
   ============================================================================ */

.gps-actions-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.gps-actions-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #111827);
  margin-bottom: 12px;
}

.gps-actions-title svg {
  flex-shrink: 0;
  color: var(--primary-500, #3b82f6);
}

.gps-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gps-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
  border: none;
  user-select: none;
}

.gps-action-btn:active {
  transform: scale(0.97);
}

/* Primary actions (white bg + border) */
.gps-action-btn--primary {
  background: white;
  color: var(--text-primary, #111827);
  border: 1.5px solid var(--border-color, #e5e7eb);
}

.gps-action-btn--primary:hover {
  border-color: var(--primary-500, #3b82f6);
  color: var(--primary-500, #3b82f6);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

/* Download action (blue) */
.gps-action-btn--download {
  background: var(--primary-500, #3b82f6);
  color: white;
  border: 1.5px solid var(--primary-500, #3b82f6);
}

.gps-action-btn--download:hover {
  background: var(--primary-600, #2563eb);
  border-color: var(--primary-600, #2563eb);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Delete action (red) */
.gps-action-btn--delete {
  background: #dc2626;
  color: white;
  border: 1.5px solid #dc2626;
}

.gps-action-btn--delete:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.3);
}

/* Mobile: Stack vertical */
@media (max-width: 640px) {
  .gps-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .gps-action-btn {
    padding: 14px 16px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .bundle-forensic-section {
    background: var(--bg-secondary-dark, #1f2937);
    border-color: var(--border-dark, #374151);
  }
  
  .bundle-forensic-section:hover {
    border-color: var(--primary-500, #3b82f6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .bundle-forensic-section-title {
    color: var(--text-primary-dark, #f9fafb);
    border-color: var(--border-dark, #374151);
  }
  
  .bundle-forensic-label {
    color: var(--text-secondary-dark, #9ca3af);
  }
  
  .bundle-forensic-value {
    color: var(--text-primary-dark, #f9fafb);
  }
  
  .bundle-forensic-hash {
    background: var(--bg-tertiary-dark, #111827);
    color: var(--text-secondary-dark, #9ca3af);
    border-color: var(--border-dark, #374151);
  }
  
  .gps-actions-section {
    border-top-color: var(--border-dark, #374151);
  }
  
  .gps-actions-title {
    color: var(--text-primary-dark, #f9fafb);
  }
  
  .gps-action-btn--primary {
    background: var(--bg-secondary-dark, #1f2937);
    color: var(--text-primary-dark, #f9fafb);
    border-color: var(--border-dark, #374151);
  }
  
  .gps-action-btn--primary:hover {
    background: var(--bg-tertiary-dark, #374151);
    border-color: var(--primary-500, #3b82f6);
  }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-content,
  .bundle-header {
    animation: none;
  }
  
  .bundle-forensic-section {
    transition: none;
  }
}
