/* =============================================
   TECHMEET — MediaPicker (WhatsApp style)
   ============================================= */

/* ── Overlay fullscreen ── */
.mp-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: var(--bg, #0d0d0d);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}

.mp-overlay.mp-visible {
  transform: translateY(0);
}

/* ── Header ── */
.mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mp-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-1, #fff);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.mp-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.mp-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1, #fff);
  font-family: var(--font-display, system-ui, sans-serif);
}

.mp-next-btn {
  background: var(--blue, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.mp-next-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.mp-next-btn:not(:disabled):active {
  background: var(--blue-light, #2563eb);
}

/* ── Grid ── */
.mp-grid-wrapper {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Camera cell (first) ── */
.mp-cell-camera {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s;
}

.mp-cell-camera:active {
  background: rgba(255, 255, 255, 0.15);
}

.mp-cell-camera-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-cell-camera-label {
  font-size: 12px;
  color: var(--text-2, rgba(255, 255, 255, 0.7));
  font-weight: 500;
}

/* ── Media cell ── */
.mp-cell {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card2, #1a1a2a);
  user-select: none;
  -webkit-user-select: none;
}

.mp-cell img,
.mp-cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* ── Video play icon ── */
.mp-cell-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 6px;
  pointer-events: none;
}

.mp-cell-play svg {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}

/* ── Selection overlay ── */
.mp-cell-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(59, 130, 246, 0.35);
  pointer-events: none;
}

.mp-cell-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue, #3b82f6);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

/* ── Unselected circle (single-select mode) ── */
.mp-cell-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 2;
}

/* ── Fallback button ── */
.mp-fallback-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 24px;
}

.mp-fallback-text {
  font-size: 14px;
  color: var(--text-2, rgba(255, 255, 255, 0.6));
  text-align: center;
  line-height: 1.5;
}

.mp-fallback-btn {
  background: var(--blue, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.mp-fallback-btn:active {
  opacity: 0.8;
}

/* ── Loading indicator ── */
.mp-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2, rgba(255, 255, 255, 0.5));
  font-size: 14px;
}

/* ── Caméra in-app (style WhatsApp) ── */
.mp-incam {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mp-incam-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-incam-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, transparent 100%);
}

.mp-incam-topbtn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mp-incam-topbtn:active { opacity: 0.65; }

.mp-incam-timer {
  display: none;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.45);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.mp-incam-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.mp-incam-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 36px 16px;
}

.mp-incam-gallerybtn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255,255,255,0.15);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mp-incam-gallerybtn:active { opacity: 0.65; }

.mp-incam-spacer { width: 52px; height: 52px; }

/* Bouton capture */
.mp-incam-capture {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.mp-incam-capture:active { transform: scale(0.91); }

/* Mode vidéo : anneau blanc + cercle rouge */
.mp-incam-capture.mp-incam-capture-video {
  background: transparent;
}
.mp-incam-capture.mp-incam-capture-video::after {
  content: '';
  position: absolute;
  inset: 8px;
  background: #ef4444;
  border-radius: 50%;
  transition: border-radius 0.2s, inset 0.2s;
}

/* Enregistrement en cours : carré rouge (stop) */
.mp-incam-capture.mp-incam-recording::after {
  border-radius: 6px;
  inset: 16px;
}

/* Onglets PHOTO / VIDÉO */
.mp-incam-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding-bottom: 4px;
}

.mp-incam-tab {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mp-incam-tab.mp-incam-tab-active {
  color: #fff;
  border-bottom-color: #fff;
}

/* ── Caméra : loading overlay (fond noir → disparaît quand le flux démarre) ── */
.mp-incam-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.mp-incam-loading span {
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  letter-spacing: 0.01em;
}
.mp-incam-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mp-spin 0.75s linear infinite;
}
@keyframes mp-spin {
  to { transform: rotate(360deg); }
}

/* ── Caméra : confirmation photo (style WhatsApp) ── */
.mp-incam-confirm {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: #000;
}
.mp-incam-confirm-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.mp-incam-confirm-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
}
.mp-incam-confirm-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  padding: 20px 24px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
}
.mp-incam-confirm-btn {
  background: #fff;
  color: #111;
  border: none;
  border-radius: 24px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.mp-incam-confirm-btn:active { opacity: 0.8; }
