/* ═══════════════════════════════════════════════
   om-e2ee.css — E2EE UI Components (Old Money)
   Phase 3: Badge · Safety Dialog · Settings · Onboarding · Status Bar
   ═══════════════════════════════════════════════ */

/* ── 🔒 Encryption Badge ── */
.om-e2ee-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: transparent;
  border: 1px solid transparent;
  position: relative;
  flex-shrink: 0;
}
.om-e2ee-badge:hover {
  transform: scale(1.15);
}
.om-e2ee-badge:active {
  transform: scale(0.92);
}

/* State: Active — ratchet running */
.om-e2ee-badge--active {
  color: var(--om-accent, #2ecc71);
  border-color: var(--om-accent, #2ecc71);
  background: rgba(46, 204, 113, 0.08);
  animation: om-e2ee-pulse-active 3s ease-in-out infinite;
}
.om-e2ee-badge--active::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--om-accent, #2ecc71);
  border-radius: 50%;
  bottom: 0;
  right: 0;
  border: 2px solid var(--om-bg-card, #1a1a2e);
}

/* State: Establishing — handshake in progress */
.om-e2ee-badge--establishing {
  color: var(--om-warning, #f39c12);
  border-color: var(--om-warning, #f39c12);
  background: rgba(243, 156, 18, 0.08);
  animation: om-e2ee-spin 1.2s linear infinite;
}

/* State: Inactive — prekeys exist, no session */
.om-e2ee-badge--inactive {
  color: var(--om-muted, #95a5a6);
  border-color: var(--om-muted, #95a5a6);
  background: rgba(149, 165, 166, 0.06);
}

/* State: Unsupported — contact without E2EE */
.om-e2ee-badge--unsupported {
  color: var(--om-danger, #e74c3c);
  border-color: transparent;
  background: transparent;
  opacity: 0.5;
  cursor: not-allowed;
}
.om-e2ee-badge--unsupported:hover {
  transform: none;
}

/* Verified checkmark overlay */
.om-e2ee-badge--verified {
  position: relative;
}
.om-e2ee-badge--verified::before {
  content: '✓';
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 10px;
  color: var(--om-accent, #2ecc71);
  background: var(--om-bg-card, #1a1a2e);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--om-accent, #2ecc71);
  font-weight: 700;
}

/* ── 🔐 Safety Number Dialog ── */
.om-e2ee-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: om-e2ee-fade-in 0.2s ease;
}
.om-e2ee-dialog-overlay.open {
  display: flex;
}

.om-e2ee-dialog {
  background: var(--om-bg-card, #1a1a2e);
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.3));
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 460px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: om-e2ee-slide-up 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.om-e2ee-dialog-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--om-gold, #C9A84C);
  margin: 0 0 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.om-e2ee-dialog-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--om-muted, #95a5a6);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: 0.2s;
  font-family: inherit;
}
.om-e2ee-dialog-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--om-text, #e8e6e3);
}

.om-e2ee-fp-section {
  margin-bottom: 20px;
}
.om-e2ee-fp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--om-text-dim, #888);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.om-e2ee-fp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 16px;
}
.om-e2ee-fp-pair {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--om-text, #e8e6e3);
  text-align: center;
}

/* ── QR Code ── */
.om-e2ee-qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
.om-e2ee-qr-container {
  background: #fff;
  border: 2px solid var(--om-gold, #C9A84C);
  border-radius: 12px;
  padding: 12px;
  display: inline-flex;
}
.om-e2ee-qr-container canvas {
  display: block;
  width: 160px;
  height: 160px;
}
.om-e2ee-qr-label {
  font-size: 11px;
  color: var(--om-text-dim, #888);
  text-align: center;
}

/* ── Dialog Actions ── */
.om-e2ee-dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.om-e2ee-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.3));
  background: transparent;
  color: var(--om-text, #e8e6e3);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  flex: 1;
  justify-content: center;
}
.om-e2ee-btn:hover {
  background: rgba(201, 168, 76, 0.1);
  border-color: var(--om-gold, #C9A84C);
}
.om-e2ee-btn:active {
  transform: scale(0.97);
}

.om-e2ee-btn--primary {
  background: var(--om-gold, #C9A84C);
  color: var(--om-bg, #0D1117);
  border-color: var(--om-gold, #C9A84C);
  font-weight: 600;
}
.om-e2ee-btn--primary:hover {
  background: #dbb95a;
  border-color: #dbb95a;
}

.om-e2ee-btn--danger {
  border-color: var(--om-danger, #e74c3c);
  color: var(--om-danger, #e74c3c);
}
.om-e2ee-btn--danger:hover {
  background: rgba(231, 76, 60, 0.1);
}

/* ── Dialog Session Info ── */
.om-e2ee-session-info {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(46, 204, 113, 0.06);
  border: 1px solid rgba(46, 204, 113, 0.15);
  border-radius: 10px;
  font-size: 12px;
  color: var(--om-text-dim, #888);
}
.om-e2ee-session-info strong {
  color: var(--om-accent, #2ecc71);
}

/* ── ⚙️ E2EE Settings Page ── */
.om-e2ee-settings {
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.om-e2ee-settings-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--om-gold, #C9A84C);
  margin: 0 0 24px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.om-e2ee-settings-section {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: var(--om-bg-card, #1a1a2e);
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.2));
  border-radius: 14px;
}

.om-e2ee-settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--om-text-dim, #888);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* ── Toggle Switch ── */
.om-e2ee-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.om-e2ee-toggle-label {
  font-size: 14px;
  color: var(--om-text, #e8e6e3);
  font-weight: 500;
}

.om-e2ee-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}
.om-e2ee-toggle input {
  display: none;
}
.om-e2ee-toggle-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--om-muted, #555);
  border-radius: 13px;
  transition: 0.3s;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.om-e2ee-toggle input:checked + .om-e2ee-toggle-track {
  background: var(--om-accent, #2ecc71);
  border-color: var(--om-accent, #2ecc71);
}
.om-e2ee-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.om-e2ee-toggle input:checked + .om-e2ee-toggle-track .om-e2ee-toggle-thumb {
  left: 24px;
}

/* ── Verified Contacts List ── */
.om-e2ee-contact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.om-e2ee-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: var(--om-text, #e8e6e3);
}
.om-e2ee-contact-verified {
  margin-left: auto;
  color: var(--om-accent, #2ecc71);
  font-size: 16px;
}
.om-e2ee-contact-not-verified {
  margin-left: auto;
  color: var(--om-muted, #555);
  font-size: 12px;
}

/* ── My Fingerprint ── */
.om-e2ee-my-fp {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--om-text-dim, #888);
  word-break: break-all;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  line-height: 1.6;
}

.om-e2ee-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.3));
  border-radius: 8px;
  background: transparent;
  color: var(--om-gold, #C9A84C);
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
}
.om-e2ee-copy-btn:hover {
  background: rgba(201, 168, 76, 0.1);
}
.om-e2ee-copy-btn:active {
  transform: scale(0.95);
}

/* ── Reset Sessions Button ── */
.om-e2ee-reset-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--om-danger, #e74c3c);
  background: transparent;
  color: var(--om-danger, #e74c3c);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
  margin-top: 8px;
}
.om-e2ee-reset-btn:hover {
  background: rgba(231, 76, 60, 0.08);
}
.om-e2ee-reset-btn:active {
  transform: scale(0.97);
}

/* ── Warning ── */
.om-e2ee-warning {
  font-size: 11px;
  color: var(--om-warning, #f39c12);
  padding: 8px 12px;
  background: rgba(243, 156, 18, 0.06);
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid rgba(243, 156, 18, 0.12);
}

/* ── 📱 Onboarding ── */
.om-e2ee-onboarding {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: om-e2ee-fade-in 0.3s ease;
}
.om-e2ee-onboarding.open {
  display: flex;
}

.om-e2ee-onboarding-card {
  background: var(--om-bg-card, #1a1a2e);
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.3));
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 380px;
  width: 88%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: om-e2ee-slide-up 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.om-e2ee-onboarding-icon {
  font-size: 52px;
  margin-bottom: 16px;
}

.om-e2ee-onboarding-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--om-gold, #C9A84C);
  margin: 0 0 8px 0;
}

.om-e2ee-onboarding-desc {
  font-size: 14px;
  color: var(--om-text-dim, #888);
  line-height: 1.6;
  margin: 0 0 6px 0;
}

.om-e2ee-onboarding-features {
  text-align: left;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}
.om-e2ee-onboarding-features li {
  font-size: 13px;
  color: var(--om-text, #e8e6e3);
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.om-e2ee-onboarding-features li::before {
  content: '🛡️';
  font-size: 14px;
}

.om-e2ee-onboarding-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.om-e2ee-onboarding-btn {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--om-gold-border, rgba(201, 168, 76, 0.3));
  background: transparent;
  color: var(--om-text, #e8e6e3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
}
.om-e2ee-onboarding-btn:hover {
  background: rgba(201, 168, 76, 0.1);
}

.om-e2ee-onboarding-btn--primary {
  background: var(--om-gold, #C9A84C);
  color: var(--om-bg, #0D1117);
  border-color: var(--om-gold, #C9A84C);
  font-weight: 600;
}
.om-e2ee-onboarding-btn--primary:hover {
  background: #dbb95a;
}

.om-e2ee-onboarding-skip {
  background: none;
  border: none;
  color: var(--om-muted, #555);
  font-size: 12px;
  cursor: pointer;
  padding: 8px;
  font-family: inherit;
}
.om-e2ee-onboarding-skip:hover {
  color: var(--om-text-dim, #888);
}

/* ── 📊 Status Bar ── */
.om-e2ee-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--om-text-dim, #888);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 0 12px 12px;
  margin: 0 16px 0 0;
}

.om-e2ee-status-icon {
  font-size: 12px;
}
.om-e2ee-status-icon--active {
  color: var(--om-accent, #2ecc71);
}
.om-e2ee-status-icon--inactive {
  color: var(--om-danger, #e74c3c);
}

.om-e2ee-status-label {
  flex: 1;
}
.om-e2ee-status-detail {
  color: var(--om-gold, #C9A84C);
  cursor: pointer;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(201, 168, 76, 0.3);
}
.om-e2ee-status-detail:hover {
  text-decoration-color: var(--om-gold, #C9A84C);
}

/* ── 🎨 Animations ── */
@keyframes om-e2ee-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes om-e2ee-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes om-e2ee-pulse-active {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(46, 204, 113, 0); }
}
@keyframes om-e2ee-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── 📱 Mobile ── */
@media (max-width: 768px) {
  .om-e2ee-dialog {
    padding: 20px 16px;
    max-width: 95%;
    border-radius: 16px;
  }
  .om-e2ee-fp-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px 6px;
    padding: 10px 12px;
  }
  .om-e2ee-fp-pair {
    font-size: 11px;
  }
  .om-e2ee-onboarding-card {
    padding: 28px 20px;
  }
  .om-e2ee-settings {
    padding: 16px 12px;
  }
  .om-e2ee-status-bar {
    margin: 0 12px;
  }
}

/* ── Scrollbar ── */
.om-e2ee-dialog::-webkit-scrollbar {
  width: 3px;
}
.om-e2ee-dialog::-webkit-scrollbar-thumb {
  background: var(--om-gold, rgba(201, 168, 76, 0.2));
  border-radius: 2px;
}
.om-e2ee-dialog::-webkit-scrollbar-track {
  background: transparent;
}

/* ── ⚠️ Crypto Warning (Step 9) ── */
.om-e2ee-crypto-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  background: rgba(231, 76, 60, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
  animation: om-e2ee-slide-down 0.3s ease;
  cursor: pointer;
}
.om-e2ee-crypto-warning-content {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}
.om-e2ee-crypto-warning-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.om-e2ee-crypto-warning-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}
.om-e2ee-crypto-warning-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
}

/* ── ⚠️ Olm Fallback (Step 9) ── */
.om-e2ee-olm-fallback {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 710;
  background: rgba(243, 156, 18, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
  animation: om-e2ee-slide-down 0.3s ease;
  cursor: pointer;
}
.om-e2ee-olm-fallback-content {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

@keyframes om-e2ee-slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Шаг 8: E2EE Chat Dropdown Menu ── */
.om-e2ee-dropdown {
  position: fixed;
  z-index: 100001;
  background: var(--om-bg-card, #151B24);
  border: 1px solid var(--om-gold-border, rgba(201,168,76,0.3));
  border-radius: 12px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.7);
}

.om-e2ee-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--om-text, #e8dcc8);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--om-font-body, 'Inter', sans-serif);
  text-align: left;
  transition: background 0.15s;
}

.om-e2ee-menu-item:hover {
  background: var(--om-gold-pale, rgba(201,168,76,0.08));
}

.om-e2ee-menu-item:active {
  background: rgba(201,168,76,0.15);
}

/* ── Шаг 9: Error/Warning статус-бар ── */
.om-e2ee-status-bar--error {
  color: #e74c3c;
  border-color: rgba(231,76,60,0.25);
  background: rgba(231,76,60,0.05);
}

.om-e2ee-status-bar--warning {
  color: #f39c12;
  border-color: rgba(243,156,18,0.25);
  background: rgba(243,156,18,0.05);
}

/* ── Кнопка хедера чата 🔐 ── */
#e2ee-chat-menu-btn {
  transition: all 0.2s !important;
}
#e2ee-chat-menu-btn:hover {
  background: var(--om-gold-pale, rgba(201,168,76,0.08)) !important;
  transform: scale(1.1) !important;
}
#e2ee-chat-menu-btn:active {
  transform: scale(0.95) !important;
}
