/* LinkHub - landing + dashboard styles */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";
  color: #1a1a2e;
  background: #f4f5f7;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: #4338ca;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout container */
.container {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 640px) {
  .container {
    padding: 24px;
  }
}

/* Headings */
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 12px;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 12px;
}

/* Auth page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 32px;
  background: linear-gradient(160deg, #eef0ff 0%, #f4f5f7 45%, #f4f5f7 100%);
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.site-header {
  text-align: center;
  padding: 0 0 20px;
}

.site-header h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.site-header .tagline {
  color: #555;
  margin-bottom: 0;
  font-size: 0.95rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-logo {
  display: block;
  height: auto;
  max-width: 180px;
  margin: 0 auto 8px;
}

.dashboard-logo {
  display: block;
  height: auto;
  max-width: 130px;
}

.recovery-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.recovery-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
  padding: 14px 16px;
  background: #f6f8fb;
  border: 1px dashed #b7bdd0;
  border-radius: 12px;
}

.recovery-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #4f46e5;
  user-select: all;
}

/* Card */
.card {
  background: #fff;
  border: 1px solid #e2e4ea;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.05);
}

/* Auth tabs */
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: #f0f1f5;
  border-radius: 8px;
}

.auth-tab {
  flex: 1 1 0;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #1a1a2e;
}

.auth-tab.active {
  background: #fff;
  color: #4338ca;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
}

.auth-switch {
  margin: 4px 0 0;
  font-size: 0.875rem;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-weight: 600;
  font-size: 0.85rem;
}

.hint {
  margin: 0;
  font-size: 0.78rem;
  color: #6b7280;
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #c9ccd6;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: #a3a8b8;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid #4338ca;
  outline-offset: 2px;
}

/* Buttons */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: #4f46e5;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

button:hover,
.btn:hover {
  background: #4338ca;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary,
.btn.secondary {
  background: #fff;
  color: #4338ca;
  border-color: #c9ccd6;
}

button.secondary:hover,
.btn.secondary:hover {
  background: #f0f0f8;
}

button.danger,
.btn.danger {
  background: #dc2626;
}

button.danger:hover,
.btn.danger:hover {
  background: #b91c1c;
}

button.small,
.btn.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

/* Tab buttons must not inherit primary button styles */
.auth-tabs button {
  min-height: 36px;
}

.auth-tab:not(.active) {
  background: transparent;
  color: #555;
}

.auth-tab.active:hover {
  background: #fff;
}

/* Avatar / thumbnail upload rows */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-row input[type="url"],
.avatar-row input[type="text"] {
  flex: 1 1 160px;
  min-width: 0;
}

.avatar-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #c9ccd6;
  flex: 0 0 auto;
}

.file-btn {
  cursor: pointer;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  font-size: 0.7em;
  vertical-align: middle;
}

.verified-line {
  font-weight: 600;
  color: #1d9bf0;
}

/* Premium upgrade banner + controls */
.premium-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 4px 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #ede9fe, #fef3c7);
  color: #4a3b06;
  font-size: 0.9rem;
}

.premium-banner button {
  margin-left: auto;
}

.premium-controls {
  border: 1px solid #e2e4ea;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 4px 0;
}

.premium-controls legend {
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0 6px;
  color: #7c3aed;
}

.link-premium-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-basis: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e2e4ea;
  font-size: 0.85rem;
}

.schedule-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: #555;
}

.schedule-field input {
  min-height: 30px;
  font-size: 0.8rem;
  padding: 3px 6px;
}

/* Theme preview swatch */
.theme-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px solid #c9ccd6;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.theme-preview #theme-preview-button {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Error messages */
.error {
  margin: 0;
  padding: 8px 12px;
  font-size: 0.875rem;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}

/* Dashboard header */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid #e2e4ea;
  margin-bottom: 20px;
}

.dashboard-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.dashboard-header .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Dashboard sections spacing */
.dashboard-section {
  margin-bottom: 24px;
}

/* Links list */
.links-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e4ea;
  border-radius: 8px;
  background: #fafafe;
}

.link-item .link-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 260px;
  min-width: 0;
}

.link-item .link-fields input {
  flex: 1 1 140px;
  min-width: 0;
}

.link-item .link-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.link-item .toggle-active {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 4px;
  font-weight: 500;
  font-size: 0.85rem;
}

.link-item .toggle-active input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.link-item-clicks {
  font-size: 0.85rem;
  color: #666;
}

.link-item-error {
  flex-basis: 100%;
}

.link-item-error:empty {
  display: none;
}

/* Analytics table */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 480px;
}

thead th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #555;
  background: #f4f5f7;
}

th,
td {
  padding: 10px 12px;
  border: 1px solid #e2e4ea;
}

tbody tr:hover {
  background: #fafafe;
}

/* Utility */
.muted {
  color: #666;
  font-size: 0.9rem;
}

.text-center {
  text-align: center;
}

/* ============ Responsive ============ */

/* Phones */
@media (max-width: 640px) {
  /* 16px inputs stop iOS Safari zooming the page on focus */
  input,
  textarea,
  select {
    font-size: 16px;
  }

  .auth-page {
    padding: 24px 12px 24px;
    align-items: flex-start;
  }

  .card {
    padding: 18px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-header .actions {
    justify-content: flex-start;
  }

  .dashboard-header #logout {
    align-self: flex-start;
  }

  .link-item .link-controls {
    flex-basis: 100%;
  }
}

/* Tablets and up: center the auth card vertically */
@media (min-width: 641px) {
  .auth-page {
    align-items: center;
    padding-top: 32px;
    padding-bottom: 32px;
  }
}

/* Desktops: widen the dashboard and lay sections out on a grid */
@media (min-width: 900px) {
  #dashboard.container {
    max-width: 960px;
  }

  #dashboard {
    display: block;
  }

  #dashboard:not([hidden]) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    align-content: start;
  }

  #dashboard .dashboard-header {
    grid-column: 1 / -1;
  }

  #profile-section {
    grid-column: 1;
  }

  #links-section {
    grid-column: 2;
  }

  #analytics-section {
    grid-column: 1 / -1;
  }
}
