/* ===== WindSpace TempMail — Style ===== */

/* --- Variables --- */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-card: #1e1e36;
  --bg-hover: #252545;
  --accent: #00d4ff;
  --accent-glow: rgba(0, 212, 255, 0.15);
  --accent-hover: #00b8e6;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #5a5a7a;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --danger: #ff4d6a;
  --danger-hover: #e0435d;
  --success: #00e676;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* --- Icons --- */
.icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* --- Header --- */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-img { height: 36px; width: auto; }
.logo-icon { font-size: 26px; }
.logo-text { font-size: 20px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.logo-text .accent { color: var(--accent); }

.header-actions { display: flex; gap: 8px; align-items: center; }

.btn-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Login button */
.btn-login {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-login:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-login .icon { width: 16px; height: 16px; }
@media (max-width: 480px) { .login-text { display: none; } }

/* --- Main --- */
.main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* --- Email Section --- */
.email-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
}
.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 600;
}

/* Email display */
.email-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-primary);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 12px;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-wrap: wrap;
}
.email-text {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
  user-select: all;
}
.btn-copy {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent);
  color: var(--bg-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-copy:hover { background: var(--accent-hover); transform: scale(1.03); }
.btn-copy.copied { background: var(--success); }
.copy-label { pointer-events: none; }

/* Meta row */
.email-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.timer { font-family: var(--font-mono); font-size: 13px; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  transition: background var(--transition);
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* Action buttons */
.email-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--border-light); }

/* Refresh button */
.btn-refresh {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}
.btn-refresh:hover {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
  transform: translateY(-1px);
}
.btn-refresh:active {
  transform: translateY(0);
}
.btn-refresh .refresh-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}
.btn-refresh.spinning .refresh-icon {
  animation: spin 0.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.custom-input-group {
  display: flex; align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}
.custom-input-group:focus-within { border-color: var(--accent); }
.input-custom {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  width: 130px;
  outline: none;
}
.input-custom::placeholder { color: var(--text-muted); }
.domain-suffix {
  color: var(--text-muted);
  font-size: 13px;
  padding-right: 4px;
  white-space: nowrap;
}
.custom-input-group .btn-secondary {
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 16px;
}

/* QR Code */
.qr-wrapper { margin-top: 16px; }
.btn-link {
  color: var(--text-secondary);
  font-size: 13px;
  transition: color var(--transition);
}
.btn-link:hover { color: var(--accent); }
.qr-container {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}
.qr-container canvas,
.qr-container img {
  border-radius: var(--radius-sm);
}

/* --- Inbox Section --- */
.inbox-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.inbox-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 50px;
  min-width: 22px;
  text-align: center;
}
.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.inbox-empty {
  padding: 60px 24px;
  text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-muted); }

/* Email list */
.inbox-list { display: flex; flex-direction: column; }
.email-item {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  gap: 14px;
}
.email-item:last-child { border-bottom: none; }
.email-item:hover { background: var(--bg-hover); }
.email-item.unread .email-item-subject { font-weight: 700; color: var(--text-primary); }
.email-item.active { background: var(--bg-hover); border-left: 3px solid var(--accent); }

.email-item-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
}
.email-item-content { flex: 1; min-width: 0; }
.email-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.email-item-from {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-item-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.email-item-subject {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-item-actions { flex-shrink: 0; }
.btn-delete-item {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
  opacity: 0;
}
.email-item:hover .btn-delete-item { opacity: 1; }
.btn-delete-item:hover { background: rgba(255, 77, 106, 0.15); color: var(--danger); }

/* --- Viewer --- */
.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  overflow-y: auto;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.viewer-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.viewer-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.btn-back .icon { width: 20px; height: 20px; }
.viewer-meta { flex: 1; min-width: 0; }
.viewer-subject {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  word-break: break-word;
}
.viewer-from { font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.viewer-date { font-size: 12px; color: var(--text-muted); }
.btn-delete { color: var(--text-muted); }
.btn-delete:hover { color: var(--danger); background: rgba(255, 77, 106, 0.12); }

.viewer-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.viewer-iframe {
  flex: 1;
  width: 100%;
  min-height: 400px;
  border: none;
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.viewer-text {
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-y: auto;
  color: var(--text-primary);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* --- Responsive --- */
@media (max-width: 640px) {
  .main { padding: 16px 12px; gap: 16px; }
  .email-section { padding: 20px 16px; }
  .email-text { font-size: 16px; }
  .email-display { padding: 12px 14px; gap: 10px; }
  .email-actions { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; }
  .custom-input-group { width: 100%; }
  .input-custom { flex: 1; min-width: 0; }
  .email-item { padding: 12px 16px; }
  .inbox-header { padding: 14px 16px; }
  .viewer-overlay { padding: 16px 8px; }
  .viewer-header { padding: 16px; }
  .viewer-iframe { min-height: 300px; }
  .email-item-avatar { width: 34px; height: 34px; font-size: 14px; }
  .btn-delete-item { opacity: 1; }
}

@media (max-width: 400px) {
  .email-text { font-size: 14px; }
  .logo-text { font-size: 17px; }
  .email-display { flex-direction: column; gap: 8px; }
  .btn-copy { width: 100%; justify-content: center; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
