/* Link Portal — Custom Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --border:    #475569;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --public-bg: rgba(34,197,94,0.12);
  --pub-text:  #4ade80;
  --rest-bg:   rgba(245,158,11,0.12);
  --rest-text: #fbbf24;
  --radius:    10px;
}

body { background: var(--bg); color: var(--text); font-family: system-ui,-apple-system,sans-serif; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
code { font-family: monospace; font-size: 0.85em; background: var(--surface2); padding: 0.1em 0.4em; border-radius: 4px; }

/* ── Layout ────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.navbar-brand svg { flex-shrink: 0; }
.navbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.nav-user { font-size: 0.875rem; color: var(--muted); }

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all 0.15s; text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: var(--error); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.3); color: var(--success); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.875rem; font-weight: 500; color: var(--muted); margin-bottom: 0.35rem; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
input[type=text], input[type=url], input[type=password], input[type=number],
select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 0.55rem 0.9rem;
  font-size: 0.9rem; outline: none; transition: border-color 0.2s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--surface2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:520px){ .row2 { grid-template-columns: 1fr; } }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card-sm { padding: 1rem; }

/* Link cards grid */
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.link-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem;
  transition: border-color 0.2s, transform 0.15s;
}
.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.link-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.link-card-title { font-weight: 600; font-size: 1rem; color: var(--text); }
.link-card-url { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-card-desc { font-size: 0.875rem; color: var(--muted); flex: 1; }
.link-card-footer { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; }
.link-card-open { margin-left: auto; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.5rem; border-radius: 99px; font-size: 0.72rem; font-weight: 600;
}
.badge-public { background: var(--public-bg); color: var(--pub-text); }
.badge-restricted { background: var(--rest-bg); color: var(--rest-text); }
.badge-tag { background: var(--surface2); color: var(--muted); font-size: 0.7rem; border-radius: 4px; }

/* ── Search bar ─────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.search-bar input { flex: 1; min-width: 180px; }
.search-bar select { width: auto; }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.page-header p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.6rem 0.9rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.03); }
.td-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Stats cards ────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.stat-card .stat-val { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.1rem; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.875rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: var(--error); }
.alert-info    { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: var(--accent-h); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty svg { margin-bottom: 1rem; opacity: 0.4; }
.empty h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.25rem; line-height: 1; padding: 0.25rem; border-radius: 4px; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* ── Tag input ──────────────────────────────────────────────────────────── */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.tag-item { background: var(--surface2); color: var(--text); border-radius: 4px; padding: 0.15rem 0.5rem; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.3rem; }
.tag-remove { cursor: pointer; color: var(--muted); font-size: 0.9rem; line-height: 1; }
.tag-remove:hover { color: var(--error); }

/* ── Users modal ────────────────────────────────────────────────────────── */
.user-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.user-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.user-item:last-child { border-bottom: none; }
.user-item:hover { background: var(--surface2); }
.user-item input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.user-info .user-name { font-size: 0.875rem; font-weight: 500; }
.user-info .user-email { font-size: 0.75rem; color: var(--muted); }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-bg { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-wrap { width: 100%; max-width: 380px; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem 2rem; text-align: center; }
.login-logo { display: flex; justify-content: center; margin-bottom: 1.25rem; }
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }
.login-hint { font-size: 0.75rem; color: var(--muted); margin-top: 1.25rem; }

/* ── Setup wizard ────────────────────────────────────────────────────────── */
.setup-wrap { max-width: 660px; margin: 2rem auto; padding: 0 1rem; }
.step-nav { display: flex; gap: 0.25rem; margin-bottom: 2rem; }
.step-pip { flex: 1; height: 4px; background: var(--surface2); border-radius: 2px; transition: background 0.3s; }
.step-pip.active { background: var(--accent); }
.step-pip.done   { background: var(--success); }
.setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.setup-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
.setup-card p.desc { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
.output-block { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; font-family: monospace; font-size: 0.78rem; white-space: pre; overflow-x: auto; color: var(--success); margin-top: 1rem; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 0.5rem; }
.ml-auto { margin-left: auto; } .mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.875rem; }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
