@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ===== CSS Variables ===== */
:root {
  --bg-primary: #080c16;
  --bg-secondary: #0f1629;
  --bg-tertiary: #151d33;
  --bg-card: rgba(22, 33, 62, 0.55);
  --bg-card-hover: rgba(30, 45, 80, 0.65);
  --bg-input: rgba(40, 55, 90, 0.45);
  --bg-input-focus: rgba(50, 65, 100, 0.6);
  --bg-modal: rgba(10, 15, 28, 0.95);
  --text-primary: #e8ecf4;
  --text-secondary: #8892a8;
  --text-muted: #5a6478;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --danger: #ff6b6b;
  --danger-hover: #ff5252;
  --success: #51cf66;
  --warning: #ffd43b;
  --border: rgba(138, 148, 180, 0.08);
  --border-light: rgba(138, 148, 180, 0.15);
  --glass-blur: 24px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 64px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  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;
}

/* ===== Background Gradient ===== */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(108, 92, 231, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(15, 22, 41, 1) 0%, rgba(8, 12, 22, 1) 100%);
}

/* Animated orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  z-index: -1;
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(108, 92, 231, 0.1);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(162, 155, 254, 0.07);
  bottom: -80px;
  right: -80px;
  animation-delay: -10s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ===== Container ===== */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header / Brand ===== */
.brand-section {
  text-align: center;
  padding-top: clamp(60px, 15vh, 140px);
  padding-bottom: 12px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.brand-icon {
  display: flex;
  gap: 3px;
  align-items: flex-end;
}

.brand-icon span {
  display: block;
  width: 4px;
  background: var(--text-primary);
  border-radius: 2px;
}

.brand-icon span:nth-child(1) { height: 14px; }
.brand-icon span:nth-child(2) { height: 22px; }
.brand-icon span:nth-child(3) { height: 18px; }
.brand-icon span:nth-child(4) { height: 28px; }
.brand-icon span:nth-child(5) { height: 14px; }

.brand-name {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.5px;
}

/* ===== Email Input Section ===== */
.email-input-section {
  margin-top: 32px;
  margin-bottom: 20px;
}

.email-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 6px 4px 18px;
  transition: var(--transition);
  backdrop-filter: blur(var(--glass-blur));
}

.email-input-wrapper:focus-within {
  background: var(--bg-input-focus);
  border-color: rgba(108, 92, 231, 0.4);
  box-shadow: var(--shadow-glow);
}

.email-icon {
  color: var(--text-muted);
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}

.email-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  padding: 14px 0;
  min-width: 0;
}

.email-input::placeholder {
  color: var(--text-muted);
}

.email-at {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 2px;
  flex-shrink: 0;
}

.domain-select {
  background: rgba(108, 92, 231, 0.15);
  border: 1px solid rgba(108, 92, 231, 0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 28px 10px 12px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a29bfe' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.domain-select:hover {
  background: rgba(108, 92, 231, 0.25);
}

.domain-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2);
}

/* ===== Controls Section ===== */
.controls-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(108, 92, 231, 0.3);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 16px;
}

.btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: var(--shadow-glow);
}

.btn-danger {
  border-color: rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border-color: var(--danger);
}

/* Auto refresh indicator */
.refresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  backdrop-filter: blur(12px);
}

.refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

.refresh-dot.paused {
  background: var(--text-muted);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===== Email List ===== */
.email-list-section {
  margin-bottom: 60px;
}

.email-list-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.email-list-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.email-list-empty h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.email-list-empty p {
  font-size: 13px;
  line-height: 1.6;
}

/* Email Card */
.email-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(var(--glass-blur));
  position: relative;
  overflow: hidden;
}

.email-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--accent-gradient);
  opacity: 0;
  transition: var(--transition);
}

.email-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(108, 92, 231, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.email-card:hover::before {
  opacity: 1;
}

.email-card.unread {
  border-left: 3px solid var(--accent);
}

.email-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.email-card-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-card-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0;
}

.email-card:hover .email-card-delete {
  opacity: 1;
}

.email-card-delete:hover {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.1);
}

.email-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.email-card-from {
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 400;
}

.email-card-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: auto;
}

/* ===== Email Detail Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 700px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-subject {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-meta-row {
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-meta-row strong {
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 4px;
}

.modal-body {
  padding: 0;
  min-height: 200px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-body-text {
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-body iframe {
  width: 100%;
  min-height: 400px;
  border: none;
  background: #fff;
}

/* Custom scrollbar */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Loading States ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 72px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
}

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

/* ===== Copy Button ===== */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.copy-btn:hover {
  color: var(--accent-light);
  background: rgba(108, 92, 231, 0.1);
}

.copy-btn.copied {
  color: var(--success);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Settings Dropdown ===== */
.settings-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(30px);
  z-index: 100;
  display: none;
}

.settings-dropdown.active {
  display: block;
  animation: dropdownIn 0.2s ease;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.settings-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.settings-label {
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  .brand-section {
    padding-top: 60px;
  }

  .email-input-wrapper {
    padding: 4px 6px 4px 14px;
  }

  .email-input {
    font-size: 14px;
    padding: 12px 0;
  }

  .domain-select {
    font-size: 12px;
    padding: 8px 24px 8px 10px;
  }

  .controls-section {
    flex-wrap: wrap;
  }

  .modal-content {
    border-radius: var(--radius-lg);
  }

  .modal-overlay {
    padding: 20px 12px;
  }
  
  .email-card {
    padding: 14px 16px;
  }
}

/* ===== Page transition ===== */
.page-content {
  animation: pageIn 0.4s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Settings wrapper for positioning */
.settings-wrapper {
  position: relative;
}

/* ===== Domain Select Row (below input) ===== */
.domain-select-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.domain-select-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}

.domain-select-bottom {
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 8px;
  color: var(--accent-light);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 32px 8px 12px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a29bfe' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.domain-select-bottom:hover {
  background-color: rgba(108, 92, 231, 0.2);
  border-color: rgba(108, 92, 231, 0.35);
}

.domain-select-bottom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.15);
}
