:root {
  --primary: #6b21a8;
  --primary-dark: #4c1d95;
  --primary-light: #a855f7;
  --bg: #0f0f13;
  --card-bg: #1a1a24;
  --text: #f5f5f7;
  --text-muted: #a1a1aa;
  --border: #2a2a3a;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,0.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Landing */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0f13 0%, #1e1b4b 50%, #0f0f13 100%);
}

.landing-container {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}

.landing-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.landing-card h1 {
  font-size: 1.75rem;
  margin-bottom: 12px;
}

.landing-card p {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint {
  margin-top: 24px !important;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(107, 33, 168, 0.4);
}

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.875rem;
}

.btn-icon {
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

/* Admin Layout */
.admin-body {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .logo {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 32px;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  font-size: 0.95rem;
  text-align: left;
}

.nav-item:hover, .nav-item.active {
  background: rgba(168, 85, 247, 0.15);
  color: var(--primary-light);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  max-width: 1100px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h1 {
  font-size: 1.75rem;
}

/* Cards & Forms */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group input[type="color"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Color picker special */
.color-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-preview input[type="color"] {
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: none;
}

/* Profile pic upload */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  border: 3px solid var(--primary);
}

.avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  border: 3px solid var(--border);
}

/* Links list in admin */
.links-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.link-item .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.link-item .link-info {
  flex: 1;
  min-width: 0;
}

.link-item .link-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.link-item .link-actions {
  display: flex;
  gap: 8px;
}

/* Pages grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.page-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
}

.page-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.page-card .page-name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.page-card .page-username {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.page-card .page-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Login modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.modal h2 {
  margin-bottom: 20px;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 2000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

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

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

/* ========== VIEW PAGE (polished Linktree style) ========== */
.view-body {
  min-height: 100vh;
  background: #111113;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* full width */
}

#page-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.view-header {
  width: 100%;
  background: linear-gradient(165deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 48px 20px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.view-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.18) 0%, transparent 60%);
  pointer-events: none;
}

.view-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.35);
  margin: 0 auto 14px;
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,0.25);
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.view-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
}
.view-avatar-placeholder.hidden {
  display: none !important;
}

.view-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 2px;
  position: relative;
  z-index: 1;
  letter-spacing: -0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #1d9bf0;
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}

.view-username {
  color: rgba(255,255,255,0.75);
  font-size: 0.95rem;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
  font-weight: 500;
}

.view-bio {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  max-width: 320px;
  margin: 0 auto 18px;
  position: relative;
  z-index: 1;
  line-height: 1.45;
}

.social-icons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.social-icons a {
  color: #fff;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

.social-icons a:hover {
  transform: scale(1.12);
  background: rgba(255,255,255,0.28);
}

.social-icons svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.view-links {
  width: 100%;
  max-width: 580px;
  padding: 28px 16px 48px;
  position: relative;
  z-index: 2;
}

.link-card {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
  text-decoration: none;
  color: #111;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-height: 64px;
}

.link-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 22px rgba(0,0,0,0.28);
}

.link-card.has-image {
  display: grid;
  grid-template-columns: 1fr 90px;
}

.link-card-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
}

.link-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}

.link-card-subtitle {
  font-size: 0.78rem;
  color: #666;
  margin-top: 3px;
}

.link-card-image {
  width: 90px;
  height: 100%;
  min-height: 64px;
  object-fit: cover;
  background: #f0f0f0;
}

.link-card.no-image .link-card-content {
  text-align: center;
  width: 100%;
}

/* Special style for CPA / offer style links */
.link-card.is-offer {
  background: linear-gradient(135deg, #fff 0%, #f8f5ff 100%);
  border: 1px solid rgba(107, 33, 168, 0.15);
}

.link-card.is-offer .link-card-title {
  color: #4c1d95;
}

.offers-header {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 8px 0 14px;
}

.view-footer {
  margin-top: auto;
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 0.78rem;
  width: 100%;
}

.view-footer a {
  color: #a855f7;
  text-decoration: none;
  font-weight: 500;
}

.view-footer a:hover {
  text-decoration: underline;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* Responsive admin */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-body {
    flex-direction: column;
  }
  .main-content {
    margin-left: 0;
    padding: 20px;
  }
}

/* Social icons selector in admin */
.social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.social-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.social-field label {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.social-field input {
  padding: 8px 12px;
  font-size: 0.9rem;
}

/* Password gate */
.password-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0f13 0%, #1e1b4b 100%);
}

/* Preview pane */
.preview-frame {
  background: #111;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 380px;
  margin: 0 auto;
}

.preview-frame iframe {
  width: 100%;
  height: 600px;
  border: none;
}

/* Utility */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
