/* Modals & Overlays */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--modal-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: auto;
  position: relative;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  z-index: 10;
}

.modal-close:hover { background: var(--bg-hover); }
.modal-close svg { width: 20px; height: 20px; }

/* Auth Modal */
.auth-modal {
  width: 100%;
  max-width: 400px;
  padding: 32px;
}

.auth-modal h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 32px;
}

.auth-modal .auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  background: var(--bg-primary);
  transition: background var(--transition);
}

.auth-btn:hover { background: var(--bg-hover); }

.auth-btn svg, .auth-btn img { width: 20px; height: 20px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--input-bg);
  color: var(--text-primary);
  margin-bottom: 12px;
  outline: none;
  transition: border-color var(--transition);
}

.auth-input:focus { border-color: var(--text-muted); }

.auth-submit {
  width: 100%;
  padding: 12px 16px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}

.auth-submit:hover { opacity: 0.9; }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  padding: 4px 0;
}

.auth-back:hover { color: var(--text-primary); }

.auth-form-group {
  margin-bottom: 16px;
}

.auth-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.phone-input-group {
  display: flex;
  gap: 8px;
}

.phone-prefix {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--input-bg);
  color: var(--text-secondary);
  min-width: 70px;
  text-align: center;
}

.otp-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 24px 0;
}

.otp-input {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
}

.otp-input:focus { border-color: var(--accent); }

/* Search Modal */
.search-modal {
  width: 100%;
  max-width: 560px;
  padding: 0;
}

.search-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-modal-header svg { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }

.search-modal-header input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-primary);
}

.search-modal-header kbd {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.search-results {
  padding: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  width: 100%;
  text-align: left;
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg-hover); }
.search-result-item svg { width: 18px; height: 18px; color: var(--text-muted); }

.search-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Account Menu */
.account-menu {
  position: fixed;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  padding: 6px;
  z-index: 2000;
  animation: menuIn 0.15s ease;
}

@keyframes menuIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.account-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  text-align: left;
  transition: background var(--transition);
}

.account-item:hover { background: var(--bg-hover); }
.account-item svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }

.account-item .help-chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
}

.account-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.account-item-wrapper {
  position: relative;
}

/* Help Submenu */
.help-submenu {
  position: absolute;
  right: calc(100% + 4px);
  top: 0;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  z-index: 2001;
  animation: menuIn 0.15s ease;
}

.help-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  text-align: left;
  transition: background var(--transition);
}

.help-item:hover { background: var(--bg-hover); }
.help-item svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }

/* Settings Modal */
.settings-modal {
  width: 100%;
  max-width: 900px;
  height: 80vh;
  max-height: 680px;
  padding: 0;
  overflow: hidden;
}

.settings-layout {
  display: flex;
  height: 100%;
}

.settings-sidebar {
  width: 240px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.settings-sidebar-header {
  padding: 0 8px 12px;
}

.settings-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  margin-bottom: 8px;
}

.settings-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
}

.settings-search svg { width: 16px; height: 16px; color: var(--text-muted); }

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  text-align: left;
  transition: background var(--transition);
}

.settings-nav-item:hover { background: var(--bg-hover); }
.settings-nav-item.active { background: var(--bg-active); font-weight: 500; }
.settings-nav-item svg { width: 18px; height: 18px; color: var(--text-secondary); }

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.settings-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
}

.settings-upgrade-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(2, 133, 255, 0.08);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.settings-upgrade-banner p { font-size: 14px; font-weight: 500; }

.settings-upgrade-banner button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-info h4 { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.settings-row-info p { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

.settings-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 160px;
  cursor: pointer;
}

.settings-color-preview {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--toggle-off);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle.on { background: var(--toggle-on); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on::after { transform: translateX(20px); }

/* Upgrade Modal */
.upgrade-modal {
  width: 100%;
  max-width: 720px;
  padding: 32px;
}

.upgrade-modal h2 {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
}

.upgrade-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 4px;
  width: fit-content;
  margin: 0 auto 32px;
}

.upgrade-toggle button {
  padding: 8px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.upgrade-toggle button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.upgrade-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upgrade-plan {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.upgrade-plan.recommended {
  border-color: var(--accent);
  position: relative;
}

.upgrade-plan-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(2, 133, 255, 0.1);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.upgrade-plan h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.upgrade-plan .plan-title { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.upgrade-plan .plan-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 16px; flex: 1; }
.upgrade-plan .plan-price { font-size: 24px; font-weight: 600; margin-bottom: 16px; }
.upgrade-plan .plan-price span { font-size: 14px; font-weight: 400; color: var(--text-secondary); }

.plan-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

.plan-btn.current {
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: default;
}

.plan-btn.upgrade {
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.plan-features { list-style: none; }

.plan-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.plan-features li svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

/* Profile Modal */
.profile-modal {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.profile-modal h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
}

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
}

.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.profile-avatar-edit svg { width: 14px; height: 14px; }

.profile-form-group {
  margin-bottom: 16px;
}

.profile-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.profile-form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
}

.profile-form-group input:focus { border-color: var(--text-muted); }

.profile-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.4;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.profile-actions button {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
}

.btn-cancel { border: 1px solid var(--border); }
.btn-cancel:hover { background: var(--bg-hover); }
.btn-save { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-save:hover { opacity: 0.9; }

/* Confirm Modal */
.confirm-modal {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.confirm-modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.confirm-modal p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions button {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
}

.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { opacity: 0.9; }

/* Generic Modal */
.generic-modal {
  width: 100%;
  max-width: 560px;
  padding: 32px;
}

.generic-modal h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-right: 32px;
}

.generic-modal textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .upgrade-plans { grid-template-columns: 1fr; }
  .settings-layout { flex-direction: column; }
  .settings-sidebar { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  .help-submenu { right: auto; left: 0; top: calc(100% + 4px); }
}
