@import '../../shared-tokens.css';

/* ── Page layout ── */
body {
  background: #f5f5f7;
  min-height: 100vh;
}

.dm-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  gap: 12px;
}

.dm-nav-back {
  font-size: 17px;
  font-weight: 600;
  color: #1d1d1f;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.3px;
  transition: opacity 0.2s;
}

.dm-nav-back:hover { opacity: 0.7; }

.dm-stepper {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

.dm-nav-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #6e6e73;
  text-decoration: none;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.2s;
}

.dm-nav-close:hover { background: #e5e5e7; }

/* ── Main layout ── */
.dm-main {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 68px 20px 40px;
}

/* ── Form title block ── */
.dm-form-title {
  text-align: center;
  margin-bottom: 28px;
}

.dm-form-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--oe-primary);
  margin-bottom: 10px;
}

.dm-form-heading {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #1d1d1f;
  line-height: 1.1;
  margin-bottom: 10px;
}

.dm-form-sub {
  font-size: 14px;
  color: #6e6e73;
  line-height: 1.55;
  max-width: 440px;
  margin: 0 auto;
}

.dm-card {
  background: #fff;
  border-radius: var(--oe-radius-xl);
  border: 0.5px solid rgba(0,0,0,0.08);
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.dm-body {
  padding: 28px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: var(--oe-radius-lg);
  background: #f5f5f7;
  color: #1d1d1f;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--oe-primary);
  box-shadow: 0 0 0 3px rgba(200,169,106,0.15);
  background: #fff;
}

.form-input::placeholder { color: #6e6e73; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--oe-btn-padding);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--oe-radius-md);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, opacity 0.2s;
}

.btn-primary {
  background: var(--oe-primary);
  color: #fff;
}

.btn-primary:hover { background: var(--oe-primary-hover); }

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

.btn-secondary {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid rgba(0,0,0,0.15);
}

.btn-secondary:hover { background: #f5f5f7; }

.btn-full { width: 100%; }

/* ── Criteria tags (suggested) ── */
.criteria-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.criteria-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f5f5f7;
  border-radius: 980px;
  font-size: 13px;
  color: #6e6e73;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.criteria-tag:hover,
.criteria-tag.selected {
  background: var(--oe-primary-light);
  color: var(--oe-primary);
  border-color: var(--oe-primary);
}

/* ── Criteria items (selected pills) ── */
.criteria-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.criteria-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--oe-primary-light);
  border: 1px solid var(--oe-primary);
  border-radius: 980px;
  font-size: 13px;
  color: var(--oe-primary);
}

.criteria-item button {
  background: none;
  border: none;
  color: var(--oe-primary);
  cursor: pointer;
  font-size: 14px;
  opacity: 0.7;
  line-height: 1;
  padding: 0;
}

.criteria-item button:hover { opacity: 1; }

/* ── Custom criteria input ── */
.custom-criteria-input {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.custom-criteria-input input { flex: 1; }

/* ── Options ── */
.decision-options { margin-top: 12px; }

.decision-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f7;
  border-radius: var(--oe-radius-md);
  margin-bottom: 8px;
}

.decision-option-text {
  flex: 1;
  font-size: 14px;
}

.decision-option-remove {
  background: none;
  border: none;
  color: #6e6e73;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.decision-option-remove:hover { color: var(--oe-danger); }

.add-option-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: none;
  border: 1.5px dashed rgba(0,0,0,0.12);
  border-radius: var(--oe-radius-md);
  color: #6e6e73;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: all 0.15s;
}

.add-option-btn:hover {
  border-color: var(--oe-primary);
  color: var(--oe-primary);
}

/* ── Host controls ── */
.host-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.host-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #f5f5f7;
  border-radius: 980px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.host-toggle.active {
  background: var(--oe-primary-light);
  color: var(--oe-primary);
}

.host-toggle input { display: none; }

/* ── Criteria weights panel ── */
.weight-panel {
  margin-top: 12px;
  padding: var(--oe-card-padding);
  background: #f5f5f7;
  border-radius: var(--oe-radius-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.weight-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weight-criteria-name {
  font-size: 13px;
  flex: 1;
  min-width: 80px;
}

.weight-slider {
  flex: 2;
  accent-color: var(--oe-primary);
  cursor: pointer;
}

.weight-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--oe-primary);
  min-width: 32px;
  text-align: right;
}

/* ── QR step ── */
.qr-section {
  text-align: center;
  padding: 8px 0;
}

.qr-code {
  display: inline-block;
  padding: 16px;
  background: #fff;
  border-radius: var(--oe-radius-lg);
  border: 0.5px solid rgba(0,0,0,0.08);
  margin-bottom: 20px;
}

.qr-code canvas { display: block; }

.qr-instructions {
  font-size: 13px;
  color: #6e6e73;
  margin-bottom: 16px;
  line-height: 1.55;
}

.voter-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: #f5f5f7;
  border-radius: var(--oe-radius-md);
  margin-bottom: 20px;
}

.voter-count {
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}

.voter-status {
  font-size: 13px;
  color: #6e6e73;
}

.waiting-animation {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.waiting-animation span {
  width: 7px;
  height: 7px;
  background: var(--oe-primary);
  border-radius: 50%;
  animation: dm-bounce 1.4s infinite ease-in-out both;
}

.waiting-animation span:nth-child(1) { animation-delay: -0.32s; }
.waiting-animation span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dm-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40%           { transform: scale(1); }
}

/* ── Timer ── */
.timer-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--oe-primary);
  border-radius: var(--oe-radius-lg);
  color: #fff;
  margin-bottom: 20px;
}

.timer-icon { font-size: 20px; }

.timer-time {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-label { font-size: 11px; opacity: 0.85; }

.timer-expired { background: var(--oe-danger); }

.timer-controls {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.timer-btn {
  flex: 1;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--oe-radius-md);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

.timer-btn.extend {
  background: #f5f5f7;
  color: #1d1d1f;
}

.timer-btn.extend:hover { background: #e5e5e7; }

.timer-btn.close {
  background: var(--oe-primary);
  color: #fff;
}

.timer-btn.close:hover { background: var(--oe-primary-hover); }

/* ── QR actions ── */
.qr-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.qr-action-btn {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 0.5px solid rgba(0,0,0,0.12);
  border-radius: var(--oe-radius-md);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.qr-action-btn:hover {
  background: var(--oe-primary-light);
  border-color: var(--oe-primary);
  color: var(--oe-primary);
}

.all-voted-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--oe-success-light);
  border: 1px solid var(--oe-success);
  border-radius: 980px;
  color: var(--oe-success);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ── Voting interface ── */
.voting-section { padding: 8px 0; }

.voting-header {
  text-align: center;
  margin-bottom: 20px;
}

.voting-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.voting-subtitle {
  font-size: 14px;
  color: #6e6e73;
}

.voter-name-input { margin-bottom: 20px; }

.progress-bar {
  height: 4px;
  background: #e5e5e7;
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--oe-primary);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── Ranking blocks ── */
.ranking-criteria-block {
  margin-bottom: 16px;
  padding: var(--oe-card-padding);
  background: #f5f5f7;
  border-radius: var(--oe-radius-lg);
  border: 0.5px solid rgba(0,0,0,0.06);
}

.ranking-criteria-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ranking-criteria-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

.ranking-weight-badge {
  padding: 2px 8px;
  background: var(--oe-primary-light);
  color: var(--oe-primary);
  border-radius: 980px;
  font-size: 11px;
  font-weight: 600;
}

.ranking-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--oe-success-light);
  color: var(--oe-success);
  border-radius: 980px;
  font-size: 11px;
  font-weight: 500;
}

.ranking-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  padding: 8px 12px;
  border-radius: var(--oe-radius-md);
}

.ranking-option-name {
  font-size: 13px;
  flex: 1;
  min-width: 70px;
}

.rank-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.rank-btn {
  width: 34px;
  height: 34px;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: var(--oe-radius-md);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.rank-btn:hover:not(:disabled) {
  border-color: var(--oe-primary);
  color: var(--oe-primary);
}

.rank-btn.selected {
  background: var(--oe-primary);
  border-color: var(--oe-primary);
  color: #fff;
}

.rank-btn.taken {
  background: #f5f5f7;
  border-color: transparent;
  color: #c7c7cc;
  cursor: not-allowed;
}

/* ── Results ── */
.results-section { padding: 8px 0; }

.results-header {
  text-align: center;
  margin-bottom: 20px;
}

.results-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.winner-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--oe-success-light);
  border: 1px solid var(--oe-success);
  border-radius: 980px;
  color: var(--oe-success);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
}

.results-grid {
  display: grid;
  gap: 10px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #f5f5f7;
  border-radius: var(--oe-radius-lg);
}

.result-item.winner {
  background: var(--oe-primary-light);
  border: 1px solid var(--oe-primary);
}

.result-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #6e6e73;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.result-item.winner .result-rank {
  background: var(--oe-primary);
}

.result-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.result-bar {
  width: 80px;
  height: 5px;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  background: var(--oe-primary);
  border-radius: 3px;
}

.result-item.winner .result-bar-fill {
  background: var(--oe-primary);
}

.result-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--oe-primary);
}

/* ── Criteria weights display ── */
.criteria-weights {
  margin-top: 16px;
  padding: var(--oe-card-padding);
  background: #f5f5f7;
  border-radius: var(--oe-radius-lg);
}

.criteria-weights-title {
  font-size: 12px;
  font-weight: 600;
  color: #6e6e73;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.criteria-weight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  gap: 12px;
}

.criteria-weight-bar {
  flex: 1;
  height: 5px;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.criteria-weight-fill {
  height: 100%;
  background: var(--oe-primary);
  border-radius: 3px;
}

.criteria-weight-value {
  font-weight: 600;
  color: var(--oe-primary);
  min-width: 40px;
  text-align: right;
  font-size: 13px;
}

/* ── Voter breakdown ── */
.voter-breakdown {
  margin-top: 16px;
  padding: var(--oe-card-padding);
  background: #f5f5f7;
  border-radius: var(--oe-radius-lg);
}

.voter-breakdown-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.voter-score-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
}

.voter-score-item:last-child { border-bottom: none; }

.voter-name {
  font-size: 13px;
  font-weight: 500;
  min-width: 90px;
}

.voter-scores {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.voter-score-tag {
  padding: 3px 8px;
  background: #fff;
  border-radius: var(--oe-radius-md);
  font-size: 11px;
  color: #6e6e73;
}

.voter-score-tag .score {
  font-weight: 600;
  color: var(--oe-primary);
}

/* ── Tie alert ── */
.tie-alert {
  padding: 10px 14px;
  background: var(--oe-warning-light);
  border: 1px solid rgba(186,117,23,0.3);
  border-radius: var(--oe-radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--oe-warning);
  margin-bottom: 16px;
}

/* ── Rating buttons (legacy, kept for voter compat) ── */
.rating-btn {
  flex: 1;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: var(--oe-radius-md);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.rating-btn:hover {
  border-color: var(--oe-primary);
  color: var(--oe-primary);
}

.rating-btn.selected {
  background: var(--oe-primary);
  border-color: var(--oe-primary);
  color: #fff;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .dm-nav { padding: 0 16px; }
  .dm-nav-title { display: none; }
  .dm-main { padding-left: 12px; padding-right: 12px; }
  .dm-body { padding: 20px 16px; }
  .rank-buttons { gap: 3px; }
  .rank-btn { width: 30px; height: 30px; font-size: 12px; }
}

/* ── Download dropdown ── */
.dm-dl-wrap { position: relative; }
.dm-dl-trigger { display: flex; align-items: center; justify-content: center; gap: 6px; }
.dm-dl-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 100;
}
.dm-dl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #1d1d1f;
  background: none;
  border: none;
  border-top: 1px solid rgba(0,0,0,0.06);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.dm-dl-item:first-child { border-top: none; }
.dm-dl-item:hover { background: #f5f5f7; }
.dm-dl-icon { font-size: 16px; flex-shrink: 0; }
.dm-dl-label { flex: 1; }
.dm-dl-check { font-size: 12px; font-weight: 600; color: #16a34a; margin-left: auto; }

/* ── Auth modal ── */
.dm-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dm-auth-overlay.active { display: flex; }
.dm-auth-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}
.dm-auth-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.dm-auth-title  { font-size: 18px; font-weight: 600; color: #1d1d1f; margin: 0; }
.dm-auth-subtitle { font-size: 13px; color: #6e6e73; margin: 4px 0 0; }
.dm-auth-close  { background: none; border: none; font-size: 20px; color: #6e6e73; cursor: pointer; padding: 2px 4px; }
.dm-auth-tabs   { display: flex; gap: 4px; background: #f5f5f7; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.dm-auth-tab    { flex: 1; padding: 7px; font-size: 14px; font-weight: 500; border: none; border-radius: 8px; cursor: pointer; transition: all 0.15s; background: transparent; color: #6e6e73; }
.dm-auth-tab.active { background: #fff; color: #1d1d1f; box-shadow: 0 1px 6px rgba(0,0,0,0.1); }
.dm-auth-error  { font-size: 13px; color: #ff3b30; background: rgba(255,59,48,0.08); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.dm-auth-fields { margin-bottom: 16px; }
.dm-auth-field  { margin-bottom: 12px; }
.dm-auth-link   { background: none; border: none; color: var(--oe-primary); font-size: 13px; cursor: pointer; padding: 0; }
