/**
 * UpTe Share — Premium UI styles
 * Full-screen overlay, scanner animation, responsive
 */

/* ─── Overlay ─── */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.share-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Modal ─── */
.share-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow);
}

.share-overlay.open .share-modal {
  transform: translateY(0) scale(1);
}

/* Scrollbar inside modal */
.share-modal::-webkit-scrollbar {
  width: 4px;
}

.share-modal::-webkit-scrollbar-track {
  background: transparent;
}

.share-modal::-webkit-scrollbar-thumb {
  background: var(--muted2);
  border-radius: 4px;
}

/* ─── Header ─── */
.share-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.share-title {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.share-close,
.share-back {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.share-close:hover,
.share-back:hover {
  color: var(--text);
  background: var(--green-dim);
}

.share-back {
  transform: rotate(180deg);
}

/* ─── Body ─── */
.share-body {
  padding: 20px;
}

.share-subtitle {
  margin: 0 0 20px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.share-hint {
  margin: 0 0 12px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

/* ─── Action cards (entry point) ─── */
.share-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  width: 100%;
}

.share-action-card:hover {
  border-color: var(--green);
  background: var(--green-dim);
}

.share-action-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-dim);
  border-radius: 10px;
  color: var(--green);
  flex-shrink: 0;
}

.share-action-text {
  flex: 1;
  min-width: 0;
}

.share-action-text strong {
  display: block;
  font-family: 'Syne', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.share-action-text span {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.share-action-card>svg:last-child {
  color: var(--muted2);
  flex-shrink: 0;
}

/* ─── Sections ─── */
.share-section {
  margin-bottom: 20px;
}

.share-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.share-section-title svg {
  color: var(--green);
  flex-shrink: 0;
}

/* ─── Toggle switches ─── */
.share-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text);
  padding: 6px 0;
}

.share-toggle input {
  display: none;
}

.share-toggle-track {
  width: 36px;
  height: 20px;
  background: var(--muted2);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.share-toggle input:checked+.share-toggle-track {
  background: var(--green);
}

.share-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px var(--green-glow);
}

.share-toggle input:checked+.share-toggle-track .share-toggle-thumb {
  transform: translateX(16px);
}

/* ─── Checkbox list ─── */
.share-check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.share-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.8125rem;
  color: var(--text);
}

.share-check-item:hover {
  background: var(--green-dim);
}

.share-check-item input {
  display: none;
}

.share-check-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--muted2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  color: transparent;
}

.share-check-item input:checked~.share-check-mark {
  background: var(--green);
  border-color: var(--green);
  color: var(--bg);
}

.share-check-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.share-check-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  padding: 16px 0;
}

/* ─── Tags ─── */
.share-tag {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.share-tag-exists {
  background: var(--green-dim);
  color: var(--green);
}

.share-tag-new {
  background: var(--green-dim);
  color: var(--green);
}

.share-tag-warn {
  background: var(--orange-dim);
  color: var(--orange);
}

/* ─── PIN input ─── */
.share-pin-row {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
}

.share-pin-input {
  width: 120px;
  text-align: center;
  font-family: 'DM Sans', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s;
}

.share-pin-input:focus {
  outline: none;
  border-color: var(--green);
}

.share-pin-input::placeholder {
  color: var(--muted2);
  letter-spacing: 0.3em;
}

/* ─── Code input (saisie token receiver) ─── */
.share-code-input {
  width: 240px;
  max-width: 100%;
  text-align: center;
  font-family: 'DM Sans', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  padding: 12px 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-transform: uppercase;
  transition: border-color 0.15s;
}
.share-code-input:focus {
  outline: none;
  border-color: var(--green);
}
.share-code-input::placeholder {
  color: var(--muted2);
}

/* ─── Code result card (sender) ─── */
.share-code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: center;
  margin-bottom: 14px;
}
.share-code-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
  margin-bottom: 8px;
}
.share-code-value {
  display: inline-block;
  font-family: 'DM Sans', monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--green);
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  user-select: all;
}
.share-code-value:hover {
  opacity: 0.85;
}
.share-code-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}

/* ─── QR card expiry line ─── */
.share-qr-expiry {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}
.share-qr-expiry svg {
  flex-shrink: 0;
}

/* ─── Primary button ─── */
.share-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--green);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.share-primary-btn:hover {
  opacity: 0.9;
}

.share-primary-btn:active {
  transform: scale(0.98);
}

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

.share-primary-btn svg {
  flex-shrink: 0;
}

/* ─── Spinner (replaced by .upte-loader--inline) ─── */

/* ─── QR Result ─── */
.share-qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.share-qr-card {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.share-qr-card-top {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 16px;
}

.share-qr-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: 0 2px 12px var(--green-glow);
}

.share-qr-canvas {
  display: block;
  width: 220px;
  height: 220px;
  image-rendering: pixelated;
}

.share-qr-card-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.share-qr-pin {
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-qr-pin-label {
  font-size: 0.6875rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-qr-pin-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', monospace;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.2em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.share-qr-pin-value:hover {
  background: var(--green-dim);
}

.share-qr-pin-value svg {
  color: var(--muted);
}

.share-qr-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.share-qr-stat {
  font-size: 0.6875rem;
  padding: 3px 8px;
  background: var(--green-dim);
  color: var(--green);
  border-radius: 20px;
  font-weight: 500;
}

/* ─── Action bar ─── */
.share-qr-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.share-qr-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.6875rem;
  font-weight: 500;
}

.share-qr-action svg {
  color: var(--green);
}

.share-qr-action:hover {
  border-color: var(--green);
  background: var(--green-dim);
}

.share-qr-action:active {
  transform: scale(0.97);
}

/* ─── Camera scanner ─── */
.share-camera-body {
  padding: 0;
}

.share-scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
  border-radius: 0 0 var(--radius) var(--radius);
}

.share-scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.share-scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
}

.share-scanner-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--green);
  border-style: solid;
  border-width: 0;
}

.share-scanner-corner.tl {
  top: 0;
  left: 0;
  border-top-width: 3px;
  border-left-width: 3px;
  border-radius: 4px 0 0 0;
}

.share-scanner-corner.tr {
  top: 0;
  right: 0;
  border-top-width: 3px;
  border-right-width: 3px;
  border-radius: 0 4px 0 0;
}

.share-scanner-corner.bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-radius: 0 0 0 4px;
}

.share-scanner-corner.br {
  bottom: 0;
  right: 0;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-radius: 0 0 4px 0;
}

.share-scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  animation: share-scan-line 2s ease-in-out infinite;
}

@keyframes share-scan-line {

  0%,
  100% {
    top: 0;
    opacity: 0.8;
  }

  50% {
    top: calc(100% - 2px);
    opacity: 1;
  }
}

.share-scanner-hint {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ─── PIN entry (receiver) ─── */
.share-pin-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.share-pin-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-dim);
  border-radius: 50%;
  color: var(--green);
  margin-bottom: 4px;
}

.share-pin-icon svg {
  width: 24px;
  height: 24px;
}

.share-pin-title {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── Warnings ─── */
.share-warnings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.share-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--orange-dim);
  border: 1px solid var(--orange3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--orange);
  line-height: 1.4;
}

.share-warning svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Import result ─── */
.share-result-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.share-result-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  animation: share-result-pop 0.4s ease-out;
}

.share-result-icon.success {
  background: var(--green-dim);
  color: var(--green);
}

.share-result-icon.success svg {
  width: 28px;
  height: 28px;
}

.share-result-icon.empty {
  background: var(--orange-dim);
  color: var(--orange);
}

@keyframes share-result-pop {
  0% {
    transform: scale(0);
  }

  70% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

.share-result-title {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.share-result-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 280px;
}

.share-result-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text);
}

.share-result-line svg {
  color: var(--green);
  flex-shrink: 0;
}

.share-result-skipped {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── Accessibility ─── */
@media (prefers-reduced-motion: reduce) {
  .share-overlay {
    transition: none;
  }

  .share-modal {
    transition: none;
  }

  .share-scanner-line {
    animation: none;
  }

  .share-result-icon {
    animation: none;
  }
}

@media (prefers-contrast: high) {
  .share-modal {
    border-width: 2px;
  }

  .share-action-card {
    border-width: 2px;
  }
}

/* ─── Touch targets ─── */
@media (pointer: coarse) {
  .share-action-card {
    padding: 16px;
    min-height: 60px;
  }

  .share-primary-btn {
    min-height: 48px;
  }

  .share-check-item {
    min-height: 44px;
  }

  .share-toggle {
    min-height: 44px;
  }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .share-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .share-modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .share-qr-canvas {
    width: 180px;
    height: 180px;
  }

  .share-scanner-frame {
    width: 160px;
    height: 160px;
  }

  .share-qr-card-info {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

@media (max-width: 360px) {
  .share-header {
    padding: 12px 14px;
  }

  .share-body {
    padding: 14px;
  }

  .share-qr-canvas {
    width: 150px;
    height: 150px;
  }

  .share-qr-actions {
    gap: 4px;
  }

  .share-qr-action {
    padding: 10px 4px;
    font-size: 0.625rem;
  }
}

/* ─── Print ─── */
@media print {
  .share-overlay {
    display: none;
  }
}