/* ==========================================================================
   Minimalist Link-in-Bio Design System
   Color Palette: Pure Monochrome, Neutral Grays, Clean Hairlines
   ========================================================================== */

:root {
  /* Light Theme Variables */
  --bg-color: #fbfbfb;
  --surface-color: #ffffff;
  --surface-hover: #f4f4f5;
  --border-color: #e4e4e7;
  --border-hover: #18181b;
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  
  --accent-color: #18181b;
  --accent-contrast: #ffffff;
  --badge-bg: #f4f4f5;
  --badge-text: #27272a;
  
  --danger-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;

  --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg-color: #0c0c0e;
  --surface-color: #17171a;
  --surface-hover: #222226;
  --border-color: #27272a;
  --border-hover: #52525b;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent-color: #f4f4f5;
  --accent-contrast: #09090b;
  --badge-bg: #27272a;
  --badge-text: #e4e4e7;

  --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 20px 30px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  padding: 24px 16px 64px 16px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */

.page-container {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding: 6px 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  display: inline-block;
  transition: background-color var(--transition-fast);
}

.status-indicator.connected {
  background-color: var(--success-color);
  box-shadow: 0 0 6px var(--success-color);
}

.status-indicator.local {
  background-color: var(--warning-color);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="dark"] .icon-moon {
  display: block;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-pill:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: var(--accent-color);
  color: var(--accent-contrast);
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  background: var(--surface-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.text-danger {
  color: var(--danger-color) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

.text-danger:hover {
  background: rgba(239, 68, 68, 0.08) !important;
}

/* ==========================================================================
   Public View: Profile Section
   ========================================================================== */

.profile-header {
  text-align: center;
  margin-bottom: 36px;
}

.avatar-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow: var(--shadow-subtle);
  background-color: var(--surface-hover);
}

.avatar-ring {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  pointer-events: none;
}

.profile-name {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.verified-badge {
  color: #0ea5e9;
  display: inline-flex;
  align-items: center;
}

.profile-bio {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 440px;
  margin: 0 auto 20px auto;
  line-height: 1.6;
}

/* Social Icons Row */
.social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.social-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--surface-color);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.social-icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.social-icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   Public View: Links List
   ========================================================================== */

.links-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.link-card {
  position: relative;
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.link-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.link-card:active {
  transform: translateY(0);
}

.link-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
  margin-right: 16px;
  border: 1px solid var(--border-color);
}

.link-icon-box svg {
  width: 20px;
  height: 20px;
}

.link-content {
  flex-grow: 1;
  min-width: 0;
}

.link-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.link-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--border-color);
  letter-spacing: 0.02em;
}

.link-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.link-card:hover .link-arrow {
  color: var(--text-primary);
  transform: translateX(3px);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

/* Footer */
.profile-footer {
  margin-top: 48px;
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.footer-credit {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-subactions {
  margin-top: 12px;
}

.btn-text-link {
  background: none;
  border: 1px dashed var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-text-link:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--surface-hover);
}

/* ==========================================================================
   Dashboard / Editor Mode
   ========================================================================== */

.editor-drawer {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-modal);
  margin-top: 10px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.editor-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.editor-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--text-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.counter-badge {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--surface-hover);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

/* Editor Items List */
.editor-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-item-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 12px;
}

.editor-item-drag {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-item-drag button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px;
}
.editor-item-drag button:hover {
  color: var(--text-primary);
}

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

.editor-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-item-url {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-tiny {
  padding: 5px 9px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-tiny:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

/* Form Styles */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-hover);
}

.code-font {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}

.form-divider {
  display: flex;
  align-items: center;
  margin: 10px 0 2px 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
}

.form-divider::after {
  content: '';
  flex-grow: 1;
  height: 1px;
  background: var(--border-color);
  margin-left: 12px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  user-select: none;
}

.avatar-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.preset-btn {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
}
.preset-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.helper-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.firebase-info-card {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.steps-list {
  padding-left: 18px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}
.steps-list code {
  background: var(--surface-color);
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}
.steps-list a {
  color: var(--text-primary);
  text-decoration: underline;
}

.firebase-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-upload-label {
  cursor: pointer;
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-dialog {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-color);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
}

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

/* ==========================================================================
   Responsive adjustments
   ========================================================================== */

@media (max-width: 480px) {
  body {
    padding: 16px 12px 48px 12px;
  }
  .profile-avatar {
    width: 84px;
    height: 84px;
  }
  .profile-name {
    font-size: 1.25rem;
  }
  .link-card {
    padding: 14px 16px;
  }
  .editor-drawer {
    padding: 18px 14px;
  }
}
