/* Innercast App — Design tokens from landing page */
:root {
  --ink: #0a0a0f;
  --paper: #fafaf8;
  --accent: #4f46e5;
  --accent-light: #818cf8;
  --accent-dark: #3730a3;
  --accent-bg: rgba(79, 70, 229, 0.06);
  --muted: #64748b;
  --muted-light: #94a3b8;
  --surface: #f1f0ec;
  --glow: rgba(79, 70, 229, 0.08);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --sidebar-w: 248px;
  --radius: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

/* ======================= LOADING ======================= */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ======================= APP LAYOUT ======================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ======================= SIDEBAR ======================= */
.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: var(--paper);
  padding: 28px 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 21px;
  font-weight: 700;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.sidebar-logo .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--accent-light);
  border-radius: 50%;
  margin-left: 1px;
  vertical-align: super;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.06);
}

.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 13px;
}

.sidebar-user .user-name {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  margin-bottom: 2px;
}

.sidebar-user .user-email {
  color: rgba(255,255,255,0.45);
  font-size: 12px;
}

.sidebar-user .logout-btn {
  color: rgba(255,255,255,0.35);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  display: inline-block;
  transition: color 0.15s;
}

.sidebar-user .logout-btn:hover {
  color: #f87171;
}

/* ======================= MAIN ======================= */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 36px 44px;
  max-width: calc(var(--sidebar-w) + 1060px);
  min-height: 100vh;
}

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

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header p {
  font-size: 15px;
  color: var(--muted);
  margin-top: 2px;
}

/* ======================= CARDS ======================= */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ======================= STATS ======================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--ink);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}

/* ======================= BUTTONS ======================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e8e7e3;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--surface);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.12);
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 15px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-secondary.btn-loading::after {
  border-color: rgba(0,0,0,0.1);
  border-top-color: var(--ink);
}

/* ======================= FORMS ======================= */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.form-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  background: #fff;
  color: var(--ink);
  transition: all 0.15s ease;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

select {
  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='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ======================= TABLE ======================= */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

table tbody tr {
  transition: background 0.1s;
}

table tbody tr:hover td {
  background: var(--accent-bg);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* ======================= BADGES ======================= */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-draft {
  background: var(--surface);
  color: var(--muted);
}

.badge-published {
  background: var(--success-bg);
  color: var(--success);
}

.badge-archived {
  background: #f5f5f5;
  color: #999;
}

.badge-open {
  background: #eff6ff;
  color: #2563eb;
}

/* ======================= AUTH ======================= */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 20px;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.03);
}

.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-logo .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 1px;
  vertical-align: super;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 32px;
}

.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.auth-error, .error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.success-msg {
  background: var(--success-bg);
  color: var(--success);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ======================= ONBOARDING ======================= */
.onboard-card {
  max-width: 540px;
}

.step-indicator {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ======================= NEWSLETTER PREVIEW ======================= */
.newsletter-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-top: 16px;
  overflow: hidden;
}

.newsletter-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.newsletter-preview-header h3 {
  font-size: 18px;
}

.newsletter-content-wrapper {
  max-width: 100%;
  overflow: auto;
}

.newsletter-content-wrapper img {
  max-width: 100%;
  height: auto;
}

/* ======================= SHARE LINK ======================= */
.share-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 10px;
}

.share-link input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--ink);
  padding: 4px 0;
}

.share-link input:focus {
  outline: none;
  box-shadow: none;
}

/* ======================= EMPTY STATE ======================= */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--surface);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 28px;
  height: 28px;
  color: var(--muted-light);
}

.empty-state h3 {
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ======================= OPEN RATE BAR ======================= */
.open-rate-bar {
  width: 100%;
  height: 5px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.open-rate-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ======================= UTILITIES ======================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pointer { cursor: pointer; }

/* ======================= RESPONSIVE ======================= */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 24px 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-card .stat-value {
    font-size: 24px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .newsletter-preview {
    padding: 20px;
  }

  .auth-card {
    padding: 28px 24px;
  }

  /* Mobile nav bar */
  .mobile-nav {
    display: flex !important;
  }
}

/* Mobile nav (hidden by default) */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  z-index: 100;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 12px;
}

.mobile-nav a.active {
  color: var(--accent-light);
}

.mobile-nav a svg {
  width: 20px;
  height: 20px;
}
