/* Clean Base Theme - UI/UX Pro Max Edition */
:root {
  --bg-page: #0c1017;
  --bg-surface: #121826;
  --bg-card: #172134;
  --bg-card-elevated: #1c2840;
  --bg-hover: #1e2c45;
  --bg-input: #0e1422;
  
  --border-subtle: #1e2b42;
  --border-card: #263654;
  --border-active: #3b82f6;
  --border-focus: rgba(59, 130, 246, 0.45);
  
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-muted: #64748b;
  --text-highlight: #ffffff;
  /* Compatibility aliases used by older component styles. */
  --text-primary: var(--text-main);
  --text-secondary: var(--text-sub);
  --border-color: var(--border-subtle);
  
  --accent-blue: #3b82f6;
  --accent-blue-hover: #60a5fa;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-glow: 0 0 20px rgba(59, 130, 246, 0.25);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.55);

  --badge-green-text: #34d399;
  --badge-green-bg: rgba(16, 185, 129, 0.12);
  --badge-green-border: rgba(16, 185, 129, 0.28);

  --badge-awaiting-text: #60a5fa;
  --badge-awaiting-bg: rgba(59, 130, 246, 0.12);
  --badge-awaiting-border: rgba(59, 130, 246, 0.28);

  --badge-orange-text: #fbbf24;
  --badge-orange-bg: rgba(245, 158, 11, 0.12);
  --badge-orange-border: rgba(245, 158, 11, 0.28);

  --badge-red-text: #f87171;
  --badge-red-bg: rgba(239, 68, 68, 0.14);
  --badge-red-border: rgba(239, 68, 68, 0.3);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-page);
  background-image: 
    radial-gradient(ellipse 90% 60% at 50% -15%, rgba(59, 130, 246, 0.08), transparent 75%),
    radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.03), transparent 45%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessible focus outlines */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 1px;
}

/* Modern Minimalist Toast */
#toast {
  visibility: hidden;
  background: rgba(18, 25, 39, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-main);
  border-radius: 8px;
  padding: 10px 18px;
  position: fixed;
  z-index: 99999;
  bottom: 24px;
  right: 24px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border-card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
  display: flex;
  align-items: center;
  gap: 8px;
}

#toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

#toast.success {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(10, 28, 20, 0.96);
  color: #a7f3d0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.15);
}

#toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(30, 10, 10, 0.96);
  color: #fca5a5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(239, 68, 68, 0.15);
}

.copied-active {
  color: #34d399 !important;
  transform: scale(1.1);
  transition: transform 0.15s, color 0.15s;
}

/* ==============================================================================
   Authentication Gate Screen
   ============================================================================== */
.auth-gate-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 100000;
  background: var(--bg-page);
  background-image: 
    radial-gradient(ellipse 70% 50% at 50% 20%, rgba(59, 130, 246, 0.12), transparent 70%),
    radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.05), transparent 50%),
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

#toast.warning {
  border-color: var(--badge-orange-border);
  background: rgba(36, 28, 12, 0.96);
  color: var(--badge-orange-text);
}

.inbox-results-dialog {
  width: min(640px, calc(100vw - 28px));
  max-height: min(76vh, 720px);
  margin: auto;
  padding: 20px;
  overflow: auto;
  color: var(--text-main);
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

.inbox-results-dialog::backdrop { background: rgba(2, 6, 15, 0.72); }
.inbox-results-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.inbox-results-header h2 { font-size: 18px; line-height: 1.3; }
.inbox-results-header p { margin-top: 6px; color: var(--text-sub); font-size: 13px; }
.inbox-results-header button {
  min-height: 44px;
  padding: 0 16px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  cursor: pointer;
}
.inbox-results-list { display: grid; gap: 8px; margin-top: 18px; list-style: none; }
.inbox-result-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-card);
  overflow-wrap: anywhere;
}
.inbox-result-item strong { color: var(--text-main); font-size: 13px; }
.inbox-result-item span { color: var(--text-sub); font-size: 13px; }
.inbox-result-item.review { border-color: var(--badge-orange-border); }
.inbox-result-item.saved { border-color: var(--badge-green-border); }
.inbox-result-item.error { border-color: var(--badge-red-border); }

.auth-gate-card {
  width: 100%;
  max-width: 440px;
  background: rgba(23, 33, 52, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(59, 130, 246, 0.08);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: gateCardEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.auth-gate-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-gate-logo-wrapper {
  margin-bottom: 6px;
}

.auth-gate-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-highlight);
}

.auth-gate-subtitle {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
}

.auth-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  margin-top: 4px;
}

.auth-gate-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.gate-input {
  width: 100%;
  padding-left: 38px !important;
  padding-right: 38px !important;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-main);
  height: 42px;
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gate-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

.btn-toggle-password {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  z-index: 2;
  min-width: 32px;
  min-height: 32px;
}

.btn-toggle-password:hover {
  color: var(--text-main);
}

.btn-gate-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  margin-top: 4px;
}

.btn-gate-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.btn-gate-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-gate-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.gate-footnote {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 480px), (max-height: 680px) {
  .auth-gate-screen {
    align-items: flex-start;
    padding: 16px;
  }

  .auth-gate-card {
    padding: 24px 20px;
    gap: 18px;
    margin: auto 0;
  }

  .auth-gate-form {
    gap: 14px;
  }

  .gate-input {
    min-height: 44px;
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
