/* ===========================
   CSS Variables & Theme
   =========================== */
:root {
  --bg: #0d0d1a;
  --surface: #161627;
  --surface2: #1e1e35;
  --border: rgba(168,85,247,0.18);
  --text: #f0f0ff;
  --muted: #9090b0;
  --purple: #a855f7;
  --pink: #ec4899;
  --orange: #f97316;
  --green: #22c55e;
}
.light {
  --bg: #f4f0ff;
  --surface: #ffffff;
  --surface2: #ede8ff;
  --border: rgba(168,85,247,0.25);
  --text: #1a1a2e;
  --muted: #6b6b8a;
}

/* ===========================
   Reset & Base
   =========================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
}
#pageContent {
  flex-direction: column;
  flex: 1;
}
#pageContent > main,
#pageContent > .admin-container {
  flex: 1;
}
.mono { font-family: 'Space Mono', monospace; }

/* ===========================
   Shared Components
   =========================== */
.grad-text {
  background: linear-gradient(90deg, var(--purple), var(--pink), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.grad-btn {
  background: linear-gradient(90deg, #d946ef, #ec4899, #f97316);
  border: none;
  cursor: pointer;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  transition: opacity 0.2s, transform 0.15s;
}
.grad-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.grad-btn:active { transform: translateY(0); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.badge {
  background: rgba(168,85,247,0.2);
  color: var(--purple);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}
.badge-green {
  background: rgba(34,197,94,0.15);
  color: var(--green);
}

/* ===========================
   Navbar
   =========================== */
.nav-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d946ef, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hamburger */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px 16px;
  flex-direction: column;
  gap: 8px;
  z-index: 99;
  animation: slideDown 0.2s ease;
}
.mobile-menu.open { display: flex; }
.mobile-menu .nav-pill,
.mobile-menu .nav-icon-btn { width: 100%; justify-content: center; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-mobile-right {
  display: none;
  align-items: center;
  gap: 10px;
}
@media (max-width: 640px) {
  .nav-mobile-right { display: flex; }
  .hamburger { display: flex; }
  .nav-actions { display: none; }
  .nav-bar { position: relative; }
}
.nav-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  text-decoration: none;
}
.nav-pill:hover { border-color: var(--purple); color: var(--purple); }
.nav-icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.nav-icon-btn:hover { border-color: var(--purple); }

/* ===========================
   Inputs
   =========================== */
.input-field {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  width: 100%;
  padding: 14px 16px 14px 44px;
  outline: none;
  transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--purple); }
.input-field::placeholder { color: var(--muted); }

/* ===========================
   Alias Rows
   =========================== */
.alias-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s, opacity 0.2s;
  cursor: pointer;
  animation: slideUp 0.3s ease both;
}
.alias-row:hover { border-color: var(--purple); }
.alias-row.used { opacity: 0.45; cursor: default; }
.alias-row.used:hover { border-color: var(--border); }
.alias-row.current-highlight {
  border-color: var(--purple);
  background: rgba(168,85,247,0.10);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===========================
   Copy Button
   =========================== */
.copy-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--purple); color: var(--purple); }
.copy-btn.used-btn { opacity: 0.4; cursor: not-allowed; color: var(--green); border-color: var(--green); }

/* ===========================
   Scrollable, Progress, Misc
   =========================== */
.scrollable { max-height: 380px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--purple) transparent; }
.scrollable::-webkit-scrollbar { width: 4px; }
.scrollable::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 4px; }
.progress-bar-bg { background: var(--surface2); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d946ef, #f97316);
  transition: width 0.4s ease;
}
.current-alias-box {
  background: var(--surface2);
  border: 2px solid var(--purple);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.2s;
}
.current-alias-box:hover { border-color: var(--pink); }
.action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  padding: 18px 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
.action-btn:hover { border-color: var(--purple); background: rgba(168,85,247,0.08); }
.error-msg { color: #f87171; font-size: 12px; margin-top: 6px; display: none; }
.cap-warning {
  background: rgba(249,115,22,0.12);
  border: 1px solid rgba(249,115,22,0.35);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--orange);
  display: none;
  align-items: center;
  gap: 8px;
}

/* ===========================
   Toast
   =========================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: linear-gradient(90deg, #d946ef, #f97316);
  color: #fff;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  z-index: 9999;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===========================
   Modal
   =========================== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.25s;
}
.modal-bg.open .modal { transform: translateY(0); }

/* ===========================
   Page Loader
   =========================== */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 28px;
  background: rgba(13,13,26,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.loader-ring {
  position: relative;
  width: 64px;
  height: 64px;
  animation: loaderSpin 2.4s linear infinite;
}
.loader-ring .dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.loader-ring .dot:nth-child(1) {
  top: 0; left: 50%; transform: translateX(-50%);
  background: #d946ef;
  animation: loaderPulse 1.2s ease-in-out infinite;
}
.loader-ring .dot:nth-child(2) {
  top: 50%; right: 0; transform: translateY(-50%);
  background: #ec4899;
  animation: loaderPulse 1.2s ease-in-out 0.3s infinite;
}
.loader-ring .dot:nth-child(3) {
  bottom: 0; left: 50%; transform: translateX(-50%);
  background: #f97316;
  animation: loaderPulse 1.2s ease-in-out 0.6s infinite;
}
.loader-ring .dot:nth-child(4) {
  top: 50%; left: 0; transform: translateY(-50%);
  background: #a855f7;
  animation: loaderPulse 1.2s ease-in-out 0.9s infinite;
}
@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}
@keyframes loaderPulse {
  0%, 100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
  50% { transform: translate(-50%, 0) scale(0.5); opacity: 0.4; }
}

/* ===========================
   Auth Pages
   =========================== */
.auth-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d946ef, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 20px;
}
.auth-title {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}
.auth-input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  width: 100%;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}
.auth-input:focus { border-color: var(--purple); }
.auth-input::placeholder { color: var(--muted); }
.auth-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #f87171;
  margin-bottom: 14px;
  display: none;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}
.auth-tabs {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
  background: transparent;
  border: none;
  font-family: 'DM Sans', sans-serif;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.auth-link {
  color: var(--purple);
  text-decoration: none;
  font-weight: 600;
}
.auth-link:hover { text-decoration: underline; }

/* ===========================
   Admin Panel
   =========================== */
.admin-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 16px 60px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.stat-value {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.users-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.user-email {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  color: var(--purple);
}
.user-meta {
  font-size: 11px;
  color: var(--muted);
}
.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.admin-btn:hover { border-color: var(--purple); color: var(--purple); }
.admin-btn.danger { color: #f87171; border-color: rgba(248,113,113,0.3); }
.admin-btn.danger:hover { background: rgba(248,113,113,0.1); }
.admin-btn.success { color: var(--green); border-color: rgba(34,197,94,0.3); }
.admin-btn.success:hover { background: rgba(34,197,94,0.1); }
.search-input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  width: 100%;
  padding: 12px 16px 12px 42px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--purple); }
.search-input::placeholder { color: var(--muted); }

/* ===========================
   Lists Grid (Remaining / Copied)
   =========================== */
.lists-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .lists-grid { grid-template-columns: 1fr; }
}

/* ===========================
   Email Cards
   =========================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.email-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  animation: slideUp 0.3s ease both;
}
.email-card:hover {
  border-color: var(--purple);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.12);
}
.card-delete-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.card-delete-btn:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.1);
}

/* ===========================
   Admin Tab Bar
   =========================== */
.admin-tab-bar {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}
.admin-tab {
  flex: 1;
  padding: 10px 16px;
  text-align: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
  background: transparent;
  border: none;
  font-family: 'DM Sans', sans-serif;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  background: var(--surface2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ===========================
   Settings Form
   =========================== */
.settings-card {
  padding: 24px;
  margin-bottom: 16px;
}
.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 500px) {
  .settings-grid { grid-template-columns: 1fr; }
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.settings-input {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  resize: vertical;
}
.settings-input:focus { border-color: var(--purple); }
.settings-input::placeholder { color: var(--muted); opacity: 0.6; }

/* ===========================
   Footer
   =========================== */
.site-footer {
  background: linear-gradient(180deg, var(--bg) 0%, rgba(0,0,0,0.4) 100%);
  border-top: 1px solid var(--border);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-copy {
  font-size: 13px;
  color: var(--muted);
}
.footer-copy strong {
  color: var(--text);
  font-weight: 700;
}
.footer-tg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,136,204,0.12);
  border: 1px solid rgba(0,136,204,0.3);
  border-radius: 999px;
  padding: 8px 18px 8px 14px;
  color: #29b6f6;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}
.footer-tg:hover {
  background: rgba(0,136,204,0.22);
  border-color: rgba(0,136,204,0.5);
}
.footer-tg svg {
  width: 18px;
  height: 18px;
  fill: #29b6f6;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .site-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
  }
}
