:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f0;
  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --border-color: #e5e5e5;
  --accent: #0a0a0a;
  --accent-hover: #262626;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
  --bg-primary: #0a0a0a;
  --bg-secondary: #171717;
  --bg-tertiary: #262626;
  --text-primary: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;
  --border-color: #262626;
  --accent: #fafafa;
  --accent-hover: #e5e5e5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: var(--transition);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}

.toast.removing {
  animation: toastOut 0.2s ease-out forwards;
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  background: var(--success);
  color: white;
}
.toast.warning .toast-icon {
  background: var(--warning);
  color: white;
}
.toast.error .toast-icon {
  background: var(--error);
  color: white;
}

.toast-content {
  flex: 1;
}
.toast-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}
.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}

.toast-close:hover {
  color: var(--text-primary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(100px) scale(0.9);
  }
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--text-secondary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
  font-size: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  background: var(--border-color);
}

/* Main Layout */
.main-layout {
  display: flex;
  padding-top: 64px;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 380px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  height: calc(100vh - 64px);
  overflow-y: auto;
  position: fixed;
  left: 0;
  top: 64px;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.sidebar-section {
  border-bottom: 1px solid var(--border-color);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  transition: var(--transition);
}

.section-header:hover {
  background: var(--bg-tertiary);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.section-title i {
  width: 20px;
  color: var(--text-secondary);
}

.section-toggle {
  color: var(--text-muted);
  transition: var(--transition);
}

.section-header.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-content {
  padding: 0 20px 20px;
  display: grid;
  gap: 16px;
  animation: slideDown 0.2s ease-out;
}

.section-content.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form Elements */
.form-group {
  display: grid;
  gap: 8px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.1);
}

.dark .form-input:focus {
  box-shadow: 0 0 0 3px rgba(250, 250, 250, 0.1);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Links List */
.links-list {
  display: grid;
  gap: 10px;
}

.link-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: grab;
  transition: var(--transition);
  animation: fadeIn 0.2s ease-out;
}

.link-item:hover {
  border-color: var(--text-muted);
}

.link-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.link-item.drag-over {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.link-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
}

.link-icon-select {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.link-icon-select:hover {
  border-color: var(--accent);
}

.link-item-inputs {
  flex: 1;
  display: grid;
  gap: 8px;
}

.link-item-inputs input {
  padding: 8px 12px;
  font-size: 13px;
}

.link-item-actions {
  display: flex;
  gap: 8px;
}

.btn-delete {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.btn-add {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border-color);
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-tertiary);
}

/* Social Icons */
.social-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 10px;
}

.social-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: var(--transition);
}

.social-item:hover {
  border-color: var(--text-muted);
}

.social-item.dragging {
  opacity: 0.5;
}

.social-item.drag-over {
  border-color: var(--accent);
}

.social-item i {
  width: 24px;
  text-align: center;
  font-size: 16px;
}

.social-item input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-primary);
  min-width: 0;
}

.social-item input:focus {
  outline: none;
}

.social-toggle {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: var(--transition);
}

.social-toggle.active {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Preview Area */
.preview-area {
  flex: 1;
  margin-left: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg-primary);
  background-image: radial-gradient(
    circle at 1px 1px,
    var(--border-color) 1px,
    transparent 0
  );
  background-size: 24px 24px;
  min-height: calc(100vh - 64px);
}

.preview-frame {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: var(--transition);
}

.preview-phone {
  padding: 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.phone-notch {
  width: 80px;
  height: 24px;
  background: var(--accent);
  border-radius: 12px;
  opacity: 0.3;
}

.preview-content {
  padding: 32px 24px;
}

/* Preview Card Styles */
.preview-avatar-wrap {
  text-align: center;
  margin-bottom: 24px;
}

.preview-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--text-secondary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--bg-primary);
  position: relative;
  animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.preview-avatar-ring {
  position: absolute;
  inset: -6px;
  border: 2px dashed var(--text-muted);
  border-radius: 50%;
  animation: ringRotate 20s linear infinite;
}

@keyframes ringRotate {
  to {
    transform: rotate(360deg);
  }
}

.preview-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.preview-tagline {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  display: inline-block;
  border: 1px solid var(--border-color);
}

.preview-links {
  display: grid;
  gap: 12px;
  margin: 28px 0;
}

.preview-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
  cursor: pointer;
}

.preview-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.preview-link i {
  font-size: 16px;
}

.preview-socials {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.preview-social {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 18px;
  transition: var(--transition);
  cursor: pointer;
}

.preview-social:hover {
  transform: translateY(-4px) rotate(8deg);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.preview-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.preview-footer-icon {
  font-size: 24px;
  margin-bottom: 8px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* Icon Picker Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-weight: 600;
  font-size: 16px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--border-color);
}

.modal-body {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.icon-search {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.icon-search-wrap {
  position: relative;
}

.icon-search-wrap i {
  position: absolute;
  left: 14px;
  top: 38%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.icon-option {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
}

.icon-option:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.icon-option.selected {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

/* Confirm Modal */
.confirm-modal .modal {
  max-width: 360px;
}

.confirm-modal .modal-body {
  text-align: center;
  padding: 32px 24px;
}

.confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--error);
  font-size: 24px;
}

.confirm-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

.confirm-actions .btn {
  flex: 1;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Export Modal */
.export-modal .modal {
  max-width: 640px;
}

.export-code {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
}

.export-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    position: relative;
    height: auto;
    max-height: none;
  }

  .main-layout {
    flex-direction: column;
  }

  .preview-area {
    margin-left: 0;
    padding: 24px 16px;
  }

  .header {
    padding: 0 16px;
  }

  .logo span {
    display: none;
  }
}

@media (max-width: 480px) {
  .preview-content {
    padding: 24px 16px;
  }

  .btn span {
    display: none;
  }

  .btn i {
    margin: 0;
  }

  .icon-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .social-grid {
    grid-template-columns: 1fr;
  }
}

/* Color Picker */
.color-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-picker-wrap {
  flex: 1;
}

.color-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  cursor: pointer;
  overflow: hidden;
}

.color-swatch input {
  width: 40px;
  height: 40px;
  border: none;
  cursor: pointer;
  margin: -6px;
}

.color-hex {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.color-hex:focus {
  outline: none;
}

/* Emoji Picker */
.emoji-select {
  width: 48px;
  height: 48px;
  font-size: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-select:hover {
  border-color: var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-option {
  padding: 8px;
  font-size: 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.emoji-option:hover {
  background: var(--bg-tertiary);
}

.preview-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-position: center;
  background-size: cover;
}
