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

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

:root {
  --bg:          #07070f;
  --bg-1:        #0d0d1a;
  --bg-2:        #12121f;
  --bg-3:        #1a1a2e;
  --border:      rgba(255,255,255,0.07);
  --border-hover:rgba(255,255,255,0.14);
  --text:        #e8e8f0;
  --text-muted:  #6b6b8a;
  --text-dim:    #9898b8;
  --accent:      #e63946;
  --accent-dark: #c1121f;
  --accent-glow: rgba(230,57,70,0.15);
  --blue:        #3b82f6;
  --blue-dark:   #2563eb;
  --green:       #22c55e;
  --orange:      #f59e0b;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 15px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--text-dim); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 99px; }

/* ── Layout: Topbar + Page ────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 58px;
  background: rgba(7,7,15,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 24px;
  z-index: 100;
}

.topbar-logo {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.topbar-logo .logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.topbar-spacer { flex: 1; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.topbar-nav a:hover { color: var(--text); background: var(--bg-2); }

.page-wrap {
  padding-top: 58px;
  min-height: 100vh;
}

/* ── Hero / Login Page ────────────────────────────────────── */
.hero {
  min-height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(230,57,70,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(59,130,246,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(230,57,70,0.1);
  border: 1px solid rgba(230,57,70,0.2);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 99px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
}

.hero-title span {
  color: var(--accent);
}

.hero-sub {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
  max-width: 440px;
  margin-bottom: 48px;
}

/* ── Login Card ───────────────────────────────────────────── */
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.login-card-header {
  margin-bottom: 28px;
}

.login-card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-card-header p {
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* ── Form Elements ────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input::placeholder { color: var(--text-muted); font-family: 'Inter', sans-serif; }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input.pin-input {
  letter-spacing: 0.3em;
  text-align: center;
  font-size: 1.1rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(230,57,70,0.3);
}

.btn-secondary {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-2); }

.btn-danger {
  background: rgba(230,57,70,0.1);
  color: var(--accent);
  border: 1px solid rgba(230,57,70,0.2);
}
.btn-danger:hover { background: rgba(230,57,70,0.2); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-error {
  background: rgba(230,57,70,0.1);
  border: 1px solid rgba(230,57,70,0.2);
  color: #ff6b7a;
}
.alert-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  color: #4ade80;
}

/* ── Inbox Layout ─────────────────────────────────────────── */
.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 58px);
}

.inbox-sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.inbox-email-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.inbox-email-badge:hover { border-color: var(--border-hover); }
.inbox-email-badge .copy-icon { margin-left: auto; color: var(--text-muted); }

.inbox-toolbar {
  display: flex;
  gap: 8px;
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.message-item {
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  margin-bottom: 2px;
}

.message-item:hover {
  background: var(--bg-2);
  border-color: var(--border);
}

.message-item.active {
  background: var(--bg-3);
  border-color: var(--border-hover);
}

.message-item.unread .message-sender {
  color: var(--text);
  font-weight: 600;
}

.message-item.unread::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  flex-shrink: 0;
}

.message-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.message-sender {
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.message-subject {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  gap: 8px;
}

/* ── Message Viewer ───────────────────────────────────────── */
.message-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.message-viewer-header {
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--border);
}

.message-viewer-subject {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.message-meta span { display: flex; align-items: center; gap: 4px; }

.message-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.message-body-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  color: var(--text-dim);
  line-height: 1.7;
}

.message-body-html {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.message-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
}

.message-placeholder-icon {
  width: 56px; height: 56px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
}

/* ── Admin Layout ─────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 58px);
}

.admin-sidebar {
  width: 220px;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  flex-shrink: 0;
}

.admin-nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
  margin-top: 16px;
}

.admin-nav-label:first-child { margin-top: 0; }

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  margin-bottom: 2px;
}

.admin-nav-item:hover { background: var(--bg-2); color: var(--text); }
.admin-nav-item.active { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.admin-nav-item .nav-icon { width: 16px; text-align: center; color: var(--text-muted); }
.admin-nav-item.active .nav-icon { color: var(--accent); }

.admin-main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
}

.admin-page-header {
  margin-bottom: 28px;
}

.admin-page-header h1 { margin-bottom: 4px; }
.admin-page-header p { font-size: 0.875rem; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--border-hover); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.stat-value.red    { color: var(--accent); }
.stat-value.blue   { color: var(--blue); }
.stat-value.green  { color: var(--green); }
.stat-value.orange { color: var(--orange); }

/* ── Cards & Tables ───────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 0.95rem; }
.card-body { padding: 24px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr { border-bottom: 1px solid var(--border); }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); color: var(--text); }

.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.825rem; }

/* ── Badges / Pills ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 500;
}
.badge-green  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.badge-red    { background: rgba(230,57,70,0.12);  color: #ff6b7a; }
.badge-blue   { background: rgba(59,130,246,0.12); color: #60a5fa; }
.badge-muted  { background: var(--bg-3); color: var(--text-muted); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  transform: translateY(12px);
  transition: transform 0.2s;
  box-shadow: var(--shadow);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1.2rem;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Refresh indicator ────────────────────────────────────── */
.refresh-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Utility ──────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.8rem; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ── Fade in ──────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Copy Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  opacity: 0;
  transition: all 0.2s;
  z-index: 999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .inbox-layout {
    grid-template-columns: 1fr;
  }
  .admin-layout {
    flex-direction: column;
  }
  .admin-sidebar {
    width: 100%;
    padding: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-main {
    padding: 20px 16px;
  }
  .topbar { padding: 0 16px; }
}
