/* LinkForge — Facebook Social Link Generator */

:root {
  --bg: #eef1f6;
  --bg-accent: #e4e9f2;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #12151c;
  --ink-soft: #4a5160;
  --muted: #7a8294;
  --line: #d8dee8;
  --brand: #0d6e6e;
  --brand-hover: #0a5858;
  --brand-soft: #d8efef;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #067647;
  --success-soft: #e7f6ee;
  --warn-soft: #fff6e5;
  --warn-ink: #8a5a00;
  --shadow: 0 10px 30px rgba(18, 21, 28, 0.06);
  --shadow-sm: 0 2px 8px rgba(18, 21, 28, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Sans", "DM Sans", system-ui, sans-serif;
  --fb-bg: #f0f2f5;
  --fb-btn: #e4e6eb;
  --fb-domain: #606770;
  --max: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7ecec 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #dde4f4 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

code {
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(216, 222, 232, 0.8);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #1a9a8f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px 6px 8px 10px;
  border: 2px solid #fff;
  border-radius: 3px;
  border-left: none;
  transform: skewX(-12deg);
}

.topnav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.page {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 3rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 2.5vw, 2rem);
  letter-spacing: -0.03em;
  font-weight: 700;
}

.lede {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  max-width: 42rem;
}

.layout-create {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem;
}

.panel-head {
  margin-bottom: 1.1rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.panel-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  font-weight: 600;
  font-size: 0.92rem;
}

.req {
  color: var(--danger);
}

.optional {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}

.textarea {
  resize: vertical;
  min-height: 88px;
}

.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.input-prefix:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
}

.prefix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  border-right: 1px solid var(--line);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-slug {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.dropzone {
  position: relative;
  border: 1.5px dashed #b8c0d0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfcfe, #f3f6fb);
  min-height: 180px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  overflow: hidden;
}

.dropzone:hover,
.dropzone:focus {
  border-color: var(--brand);
  outline: none;
}

.dropzone.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.01);
}

.dropzone.has-file {
  cursor: default;
  border-style: solid;
  border-color: var(--line);
  background: #fff;
}

.dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.75rem 1rem;
  gap: 0.2rem;
  min-height: 180px;
}

.dropzone-icon {
  color: var(--brand);
  margin-bottom: 0.4rem;
}

.dropzone-title {
  margin: 0;
  font-weight: 700;
  font-family: var(--display);
}

.dropzone-sub,
.dropzone-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.dropzone-hint {
  margin-top: 0.45rem;
  font-size: 0.78rem;
}

.dropzone-preview {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  padding: 1rem;
  align-items: center;
}

.dropzone-preview img {
  width: 100%;
  height: 100px;
  object-fit: contain;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.upload-status {
  margin: 0;
  font-weight: 600;
  color: var(--success);
}

.dim-line {
  margin: 0.15rem 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.upload-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(13, 110, 110, 0.12);
}

.upload-progress-bar {
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width 0.2s ease;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.btn-secondary:hover {
  background: #eceff5;
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: #f9d5d1;
  color: var(--danger);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Facebook preview simulator */
.fb-card {
  border: 1px solid #ccd0d5;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  max-width: 500px;
  font-family: Helvetica, Arial, sans-serif;
  box-shadow: var(--shadow-sm);
}

.fb-card-image {
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 180px;
}

.fb-card-image img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  background: #f0f2f5;
}

.fb-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2a2f3a, #12151c);
  color: #9aa3b5;
  font-size: 0.9rem;
  min-height: 180px;
}

.fb-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--fb-bg);
  padding: 0.75rem 0.85rem;
  border-top: 1px solid #e4e6eb;
}

.fb-card-text {
  min-width: 0;
  flex: 1;
}

.fb-domain {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--fb-domain);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fb-title {
  margin-top: 0.15rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: #050505;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fb-desc {
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: #606770;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fb-cta {
  flex-shrink: 0;
  border: none;
  background: var(--fb-btn);
  color: #050505;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  cursor: default;
  pointer-events: none;
  white-space: nowrap;
}

.preview-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 5rem;
}

.result-box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-url {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  word-break: break-all;
  padding: 0.85rem 1rem;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  color: var(--brand);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-meta {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.result-meta dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-meta dd {
  margin: 0.15rem 0 0;
  word-break: break-word;
}

.info-box {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border: 1px solid #f0d9a8;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.stat-value {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-value-sm {
  font-size: 1.15rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.toolbar .input {
  flex: 1;
  min-width: 180px;
}

.toolbar .select {
  width: auto;
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
}

.thumb {
  width: 72px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.cell-strong {
  font-weight: 600;
  max-width: 180px;
}

.cell-truncate {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem !important;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.inline-form {
  display: inline;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active {
  background: var(--success-soft);
  color: var(--success);
}

.badge-inactive {
  background: #eef0f4;
  color: var(--ink-soft);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.detail-media img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #111;
  object-fit: contain;
  max-height: 220px;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 0.9rem;
}

.detail-list dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detail-list dd {
  margin: 0.2rem 0 0;
  word-break: break-word;
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert ul {
  margin: 0;
  padding-left: 1.1rem;
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(360px, calc(100% - 2rem));
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-weight: 500;
  animation: toast-in 0.25s ease;
}

.toast-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #b7e4c7;
}

.toast-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5c2c0;
}

.toast[data-toast] {
  position: fixed;
  right: 1rem;
  top: 4.5rem;
  z-index: 90;
  max-width: 360px;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-weight: 500;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.is-hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.text-cap {
  text-transform: capitalize;
}

.site-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 920px) {
  .layout-create {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .dropzone-preview {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(var(--max), calc(100% - 1.25rem));
  }

  .fb-card-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .fb-cta {
    align-self: stretch;
    text-align: center;
  }
}
