@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #07071a;
  --bg-secondary: #0d0d2b;
  --bg-card: rgba(18, 18, 50, 0.65);
  --bg-card-hover: rgba(25, 25, 65, 0.75);
  --glass-border: rgba(120, 90, 255, 0.15);
  --glass-shadow: rgba(100, 70, 255, 0.08);
  --accent: #7c5cfc;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 92, 252, 0.35);
  --cyan: #22d3ee;
  --cyan-glow: rgba(34, 211, 238, 0.25);
  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;
  --text-primary: #f1f0ff;
  --text-secondary: #9e9bc7;
  --text-muted: #5a577a;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-effects {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-effects .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.3;
  animation: orbFloat 20s ease-in-out infinite alternate;
}

.bg-effects .orb-1 {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  right: -200px;
  animation-delay: 0s;
}

.bg-effects .orb-2 {
  width: 500px;
  height: 500px;
  background: var(--cyan);
  bottom: -150px;
  left: -150px;
  animation-delay: -7s;
}

.bg-effects .orb-3 {
  width: 350px;
  height: 350px;
  background: #e879f9;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
  opacity: 0.15;
}

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
  100% { transform: translate(10px, -10px) scale(1.02); }
}

/* ===== LAYOUT ===== */
.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 40px 0 32px;
}

.header .logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.header .logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
  margin-top: 4px;
}

.header .domain-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 6px 14px;
  background: rgba(124, 92, 252, 0.1);
  border: 1px solid rgba(124, 92, 252, 0.2);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--accent-light);
  font-weight: 500;
}

/* ===== GLASS CARD ===== */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 40px var(--glass-shadow), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: var(--transition);
}

/* ===== EMAIL DISPLAY CARD ===== */
.email-card {
  padding: 28px 24px;
  margin-bottom: 20px;
}

.email-card .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.email-card .label .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 12px var(--green); }
  50% { opacity: 0.5; box-shadow: 0 0 4px var(--green); }
}

.email-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(124, 92, 252, 0.12);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.email-display:hover {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.06);
}

.email-display .email-text {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
  font-family: 'Inter', monospace;
}

.email-display .copy-btn {
  background: linear-gradient(135deg, var(--accent), #6341e0);
  border: none;
  border-radius: var(--radius-xs);
  padding: 10px 18px;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.email-display .copy-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.email-display .copy-btn.copied {
  background: linear-gradient(135deg, var(--green), #059669);
}

/* ===== ACTION BUTTONS ===== */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6341e0);
  color: white;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== INBOX HEADER ===== */
.inbox-section {
  margin-top: 24px;
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.inbox-header .inbox-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.inbox-header .inbox-title .count {
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

.inbox-header .refresh-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.refresh-info .refresh-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(124, 92, 252, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== INBOX MESSAGES ===== */
.inbox-list {
  max-height: 450px;
  overflow-y: auto;
}

.inbox-list::-webkit-scrollbar {
  width: 4px;
}

.inbox-list::-webkit-scrollbar-track {
  background: transparent;
}

.inbox-list::-webkit-scrollbar-thumb {
  background: rgba(124, 92, 252, 0.3);
  border-radius: 999px;
}

.message-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: var(--transition);
  animation: slideIn 0.4s ease-out;
}

.message-item:hover {
  background: var(--bg-card-hover);
}

.message-item:last-child {
  border-bottom: none;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-item .msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.message-item .msg-content {
  flex: 1;
  min-width: 0;
}

.message-item .msg-from {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-item .msg-subject {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.message-item .msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.message-item.unread .msg-from {
  color: var(--accent-light);
}

.message-item.unread::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.message-item {
  position: relative;
}

/* ===== EMPTY INBOX ===== */
.inbox-empty {
  text-align: center;
  padding: 48px 24px;
}

.inbox-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.inbox-empty h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.inbox-empty p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== LOADING STATE ===== */
.loading-state {
  text-align: center;
  padding: 48px 24px;
}

.loading-state .loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(124, 92, 252, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loading-state p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== EMAIL MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header .modal-info h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.modal-header .modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-header .modal-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xs);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--red);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body .email-content {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  word-break: break-word;
}

.modal-body .email-content a {
  color: var(--accent-light);
  text-decoration: underline;
}

.modal-body .email-content img {
  max-width: 100%;
  border-radius: var(--radius-xs);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.4s ease-out;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-width: 340px;
}

.toast.toast-success {
  border-color: rgba(52, 211, 153, 0.3);
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.3);
}

.toast.toast-out {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 32px 0 16px;
  margin-top: 32px;
}

.footer p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-email {
  height: 56px;
  border-radius: var(--radius-sm);
}

.skeleton-msg {
  height: 72px;
  margin: 8px 24px;
  border-radius: var(--radius-sm);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .app {
    padding: 16px 12px 32px;
  }
  
  .header h1 {
    font-size: 1.6rem;
  }
  
  .email-display {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .email-display .copy-btn {
    justify-content: center;
  }
  
  .email-card {
    padding: 20px 16px;
  }
  
  .inbox-header {
    padding: 16px;
  }
  
  .message-item {
    padding: 14px 16px;
  }
  
  .modal {
    max-height: 92vh;
  }
  
  .modal-header {
    padding: 18px;
  }
  
  .modal-body {
    padding: 18px;
  }

  .actions {
    flex-direction: column;
  }
}
