/* ===== Custom Dropdown ===== */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-selected {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.dropdown-selected:hover { 
  border-color: var(--accent); 
}

.dropdown-selected.active { 
  border-color: var(--accent); 
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
  background: var(--bg-card);
}

.dropdown-arrow {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  margin-left: 4px;
  transition: transform 0.2s;
}

.dropdown-selected.active .dropdown-arrow { 
  transform: rotate(180deg); 
  border-top-color: var(--accent);
}

.dropdown-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
  z-index: 100;
  display: none;
  overflow: hidden;
  padding: 4px;
}

.dropdown-options.show { 
  display: block; 
}

.dropdown-option {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.dropdown-option:hover { 
  background: var(--bg-subtle); 
}

.dropdown-option.selected { 
  font-weight: 600; 
  background: var(--bg); 
}

/* ===== Table ===== */
table { 
  width: 100%; 
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  text-align: left; 
  padding: 10px 16px; 
  font-size: 10px; 
  font-weight: 600;
  color: var(--text-muted); 
  text-transform: uppercase; 
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border); 
  background: var(--bg-subtle);
}

thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }

tbody td {
  padding: 12px 16px; 
  font-size: 13px; 
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { 
  border-bottom: none; 
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover { 
  background: var(--bg-subtle); 
}

tbody td a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.15s;
}

tbody td a:hover {
  opacity: 0.7;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-content::-webkit-scrollbar { display: none; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Toast Notification ===== */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 240px;
  max-width: 380px;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.toast-item.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-item.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-success .toast-icon {
  stroke: var(--success);
}

.toast-error .toast-icon {
  stroke: var(--danger);
}

.toast-msg {
  flex: 1;
  line-height: 1.4;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
}

.toast-progress-bar {
  height: 100%;
  border-radius: 0 0 12px 12px;
  animation: toast-countdown 3s linear forwards;
}

.toast-success .toast-progress-bar {
  background: var(--success);
}

.toast-error .toast-progress-bar {
  background: var(--danger);
}

@keyframes toast-countdown {
  from { width: 100%; }
  to { width: 0%; }
}

/* ===== Dark Theme Component Overrides ===== */
[data-theme="dark"] .btn-primary {
  background: #e5e5e5;
  color: #111;
}

[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: #fff;
}

[data-theme="dark"] .btn-danger {
  color: #fff;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

[data-theme="dark"] .dropdown-selected.active {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

[data-theme="dark"] .modal-content {
  background: var(--bg-card);
}

[data-theme="dark"] .log-box {
  background: #080a0f;
  border-color: rgba(255,255,255,0.05);
  color: rgba(226, 232, 240, 0.85);
}

/* Proxy 相关样式已移除（代理管理功能下线） */

[data-theme="dark"] .addr-tooltip {
  background: #374151;
}

/* ===== MoeMail 配置卡片样式 ===== */
.moemail-add-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.moemail-add-section:hover {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.05);
}

.moemail-add-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.moemail-add-header svg {
  color: #10b981;
}

.moemail-add-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.moemail-input-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.moemail-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.moemail-input-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.moemail-input-group .form-input {
  height: 36px;
  font-size: 13px;
}

.moemail-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.moemail-action-row .btn {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.moemail-status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
  line-height: 1.4;
  flex: 1;
}

/* 配置列表 */
.moemail-config-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.moemail-config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
}

.moemail-config-item:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.moemail-config-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.moemail-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.moemail-status-dot.success {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.moemail-status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.moemail-status-dot.untested {
  background: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.moemail-config-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.moemail-config-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.moemail-config-details {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.moemail-config-url {
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.moemail-config-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-weight: 600;
}

.moemail-config-status.success {
  color: #10b981;
}

.moemail-config-status.error {
  color: #ef4444;
}

.moemail-config-status.untested {
  color: var(--text-muted);
}

.moemail-config-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.moemail-config-actions .btn {
  font-size: 11px;
  padding: 6px 12px;
  height: auto;
}

/* 空状态 */
.moemail-empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 12px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 16px;
}

.moemail-empty-state svg {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  opacity: 0.3;
}

/* 域名 tag */
.moemail-domain-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.moemail-domain-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 5px;
  line-height: 1.6;
  white-space: nowrap;
}

[data-theme="dark"] .moemail-domain-tag {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
}

/* 域名选择容器 */
.moemail-domains-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* 全选按钮 */
.moemail-select-all-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 6px;
  transition: all 0.15s;
}

.moemail-select-all-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

/* 模式选择行 */
.domain-mode-row {
  display: flex;
  gap: 6px;
}

.domain-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 0;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.domain-mode-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-secondary);
}

.domain-mode-btn.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.07);
  color: #3b82f6;
}

.domain-mode-btn svg {
  opacity: 0.6;
}

.domain-mode-btn.selected svg {
  opacity: 1;
}

/* 域名 chip 流式布局 */
.domain-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.domain-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}

.domain-chip:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.domain-chip.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
  font-weight: 600;
}

/* 暗色适配 */
[data-theme="dark"] .domain-mode-btn.selected {
  background: rgba(59, 130, 246, 0.12);
}

[data-theme="dark"] .domain-chip.selected {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

/* 暗色主题适配 */
[data-theme="dark"] .moemail-add-section:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.08);
}

[data-theme="dark"] .moemail-config-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
