/* ============================================================
   LinQovery — Design System
   ============================================================ */

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef2ff;
  --color-secondary: #64748b;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-sidebar: #1e293b;
  --color-sidebar-hover: #334155;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

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

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ============================================================
   Typography
   ============================================================ */
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 600; }

.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.text-center { text-align: center; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.fw-600 { font-weight: 600; }

/* ============================================================
   Layout utilities
   ============================================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 600px; margin: 0 auto; padding: 0 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500; font-family: var(--font);
  text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--color-card); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-icon { padding: .4rem; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; }
.form-control {
  width: 100%; padding: .6rem .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: .9375rem;
  font-family: var(--font); background: var(--color-card);
  color: var(--color-text); transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: .8125rem; color: var(--color-text-muted); margin-top: .25rem; }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input { width: 1rem; height: 1rem; cursor: pointer; accent-color: var(--color-primary); }
.form-check label { font-size: .9rem; cursor: pointer; margin-bottom: 0; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-header { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--color-border); }
.card-sm { padding: 1rem; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-list { list-style: none; }
.flash {
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: .75rem; font-size: .9rem; border-left: 4px solid;
}
.flash-success { background: #ecfdf5; border-color: var(--color-success); color: #065f46; }
.flash-error, .flash-danger { background: #fef2f2; border-color: var(--color-danger); color: #991b1b; }
.flash-info { background: #eff6ff; border-color: var(--color-info); color: #1e40af; }
.flash-warning { background: #fffbeb; border-color: var(--color-warning); color: #92400e; }

/* ============================================================
   Badges / Tags
   ============================================================ */
.badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 999px; font-size: .75rem; font-weight: 500;
}
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-danger { background: #fef2f2; color: var(--color-danger); }
.badge-success { background: #ecfdf5; color: var(--color-success); }
.badge-warning { background: #fffbeb; color: #b45309; }

.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag {
  background: var(--color-primary-light); color: var(--color-primary);
  padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500;
  text-decoration: none;
}
.tag:hover { background: var(--color-primary); color: #fff; text-decoration: none; }

/* ============================================================
   Stars (rating)
   ============================================================ */
.stars { display: inline-flex; gap: .1rem; }
.star { font-size: 1.1rem; }
.star-filled { color: #f59e0b; }
.star-empty { color: #d1d5db; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { display: flex; gap: .4rem; align-items: center; margin-top: 2rem; flex-wrap: wrap; }
.page-link {
  padding: .4rem .75rem; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font-size: .875rem;
  color: var(--color-text); text-decoration: none; transition: all .15s;
}
.page-link:hover { background: var(--color-bg); text-decoration: none; }
.page-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-link.disabled { color: var(--color-text-muted); pointer-events: none; }

/* ============================================================
   Public navbar
   ============================================================ */
.navbar {
  background: var(--color-card); border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 1.5rem; max-width: 1200px; margin: 0 auto;
}
.navbar-brand { font-size: 1.25rem; font-weight: 700; color: var(--color-primary); text-decoration: none; }
.navbar-brand:hover { text-decoration: none; }
.navbar-links { display: flex; align-items: center; gap: 1.5rem; }
.navbar-links a { font-size: .9rem; color: var(--color-text-muted); font-weight: 500; }
.navbar-links a:hover { color: var(--color-text); text-decoration: none; }

/* ============================================================
   App layout (sidebar + content)
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; background: var(--color-sidebar);
  flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  font-size: 1.1rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid #334155; text-decoration: none;
  display: block;
}
.sidebar-brand:hover { text-decoration: none; color: #a5b4fc; }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-section { padding: .25rem 1rem .5rem; font-size: .7rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-top: .5rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1rem; color: #94a3b8;
  font-size: .9rem; font-weight: 500; text-decoration: none;
  transition: all .15s; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--color-sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--color-sidebar-hover); color: #fff; border-left-color: var(--color-primary); }
.sidebar-link .icon { width: 1rem; text-align: center; opacity: .85; }
.sidebar-footer {
  padding: 1rem; border-top: 1px solid #334155;
  font-size: .8125rem; color: #64748b;
}
.sidebar-user { font-size: .85rem; color: #94a3b8; padding: .25rem 0; }
.sidebar-plan { display: inline-block; background: #334155; color: #a5b4fc; padding: .1rem .5rem; border-radius: 999px; font-size: .7rem; font-weight: 600; text-transform: uppercase; }

.app-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar {
  background: var(--color-card); border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem; height: 56px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 40;
}
.app-main { padding: 1.5rem; flex: 1; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .app-content { margin-left: 0; }
}

/* ============================================================
   Page header
   ============================================================ */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--color-text-muted); margin-top: .25rem; }

/* ============================================================
   Bookmark card
   ============================================================ */
.bookmark-list { display: flex; flex-direction: column; gap: .75rem; }
.bookmark-card {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s;
  display: flex; gap: 1rem; align-items: flex-start;
}
.bookmark-card:hover { box-shadow: var(--shadow-md); border-color: #c7d2fe; }
.bookmark-card.dead { border-left: 3px solid var(--color-danger); }
.bookmark-card.flagged { border-left: 3px solid var(--color-warning); }
.bookmark-favicon { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--color-bg); border: 1px solid var(--color-border); }
.bookmark-favicon-placeholder { width: 32px; height: 32px; border-radius: 6px; background: var(--color-primary-light); color: var(--color-primary); display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex-shrink: 0; }
.bookmark-body { flex: 1; min-width: 0; }
.bookmark-title { font-weight: 600; font-size: .9375rem; color: var(--color-text); }
.bookmark-title:hover { color: var(--color-primary); }
.bookmark-url { font-size: .8125rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.bookmark-desc { font-size: .875rem; color: var(--color-text-muted); margin-top: .35rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bookmark-meta { display: flex; align-items: center; gap: .75rem; margin-top: .5rem; flex-wrap: wrap; }
.bookmark-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ============================================================
   Search / Filters bar
   ============================================================ */
.search-bar {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  margin-bottom: 1rem; box-shadow: var(--shadow);
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end;
}
.search-input-wrap { flex: 1; min-width: 200px; position: relative; }
.search-input-wrap input { padding-left: 2.25rem; }
.search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }

/* ============================================================
   Stats cards
   ============================================================ */
.stat-card {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: .85rem; color: var(--color-text-muted); margin-top: .2rem; }

/* ============================================================
   Landing page hero
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff; padding: 5rem 1.5rem;
  text-align: center;
}
.hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.15; }
.hero p { font-size: 1.25rem; opacity: .9; margin-top: 1rem; max-width: 560px; margin-left: auto; margin-right: auto; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.btn-white { background: #fff; color: var(--color-primary); font-weight: 600; }
.btn-white:hover { background: #f0f0f0; text-decoration: none; color: var(--color-primary); }
.btn-outline-white { border: 2px solid rgba(255,255,255,.6); color: #fff; background: transparent; font-weight: 600; }
.btn-outline-white:hover { border-color: #fff; background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }

@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
}

/* ============================================================
   Feature grid
   ============================================================ */
.feature-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--color-primary-light); color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; margin-bottom: .75rem;
}

/* ============================================================
   Pricing cards
   ============================================================ */
.pricing-card { position: relative; }
.pricing-card.featured { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary); }
.pricing-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--color-primary); color: #fff; padding: .2rem .9rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pricing-price { font-size: 2.5rem; font-weight: 800; color: var(--color-text); }
.pricing-price sup { font-size: 1.25rem; font-weight: 600; }
.pricing-price .period { font-size: .9rem; font-weight: 400; color: var(--color-text-muted); }
.pricing-features { list-style: none; margin: 1.25rem 0; }
.pricing-features li { padding: .4rem 0; font-size: .9rem; display: flex; gap: .5rem; align-items: flex-start; }
.pricing-features li::before { content: "✓"; color: var(--color-success); font-weight: 700; flex-shrink: 0; }

/* ============================================================
   Table
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .75rem 1rem; border-bottom: 2px solid var(--color-border); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-bg); }

/* ============================================================
   Footer (public)
   ============================================================ */
.footer {
  background: var(--color-sidebar); color: #94a3b8;
  padding: 2rem 1.5rem; margin-top: auto; font-size: .875rem;
}
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.footer a { color: #94a3b8; }
.footer a:hover { color: #fff; }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--color-bg); }
.auth-card { width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo a { font-size: 1.5rem; font-weight: 800; color: var(--color-primary); text-decoration: none; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--color-text-muted); }

/* ============================================================
   Detail view
   ============================================================ */
.detail-url {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: .6rem 1rem;
  font-size: .9rem; word-break: break-all; margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.status-indicator { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-ok { background: var(--color-success); }
.status-dead { background: var(--color-danger); }
.status-unknown { background: #d1d5db; }

/* ============================================================
   Alerts / info boxes
   ============================================================ */
.alert {
  padding: .9rem 1.1rem; border-radius: var(--radius-sm);
  border-left: 4px solid; margin-bottom: 1rem; font-size: .9rem;
}
.alert-info { background: #eff6ff; border-color: var(--color-info); color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: var(--color-warning); color: #92400e; }
.alert-danger { background: #fef2f2; border-color: var(--color-danger); color: #991b1b; }
.alert-success { background: #ecfdf5; border-color: var(--color-success); color: #065f46; }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--color-text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { color: var(--color-text); margin-bottom: .5rem; }

/* ============================================================
   Misc
   ============================================================ */
.divider { height: 1px; background: var(--color-border); margin: 1.5rem 0; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 500; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.hidden { display: none; }
