/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --brand: #75e6a6;
  --brand-dark: #3730a3;
  --surface: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #ef4444;
  --success: #22c55e;
  --admin-bg: #13241a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
}
a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: 0.2s;
  text-decoration: none;
}
.btn:hover {
  filter: brightness(0.92);
  text-decoration: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-google {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  justify-content: center;
  padding: 12px;
}
.btn-admin {
  background: var(--admin-bg);
  color: #cbd5e1;
  width: 100%;
  justify-content: center;
  padding: 12px;
}
.btn-logout {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 7px 14px;
  font-size: 0.85rem;
}
.btn-full {
  width: 100%;
  justify-content: center;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ─── Login Page ────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 100%);
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  margin-bottom: 20px;
}
.login-logo svg {
  border-radius: 16px;
}
.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-subtitle {
  color: var(--muted);
  margin-bottom: 32px;
}
.login-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-form {
  text-align: left;
  margin-top: 4px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--brand);
}
.back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.85rem;
}
.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  text-align: left;
}

/* ─── Header ────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.admin-header {
  background: var(--admin-bg);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}
.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

/* ─── Gallery ───────────────────────────────────────────────────────────── */
.gallery-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}
.gallery-header {
  margin-bottom: 28px;
}
.gallery-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}
.gallery-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 1100px) {
  .link-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 780px) {
  .link-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .link-grid {
    grid-template-columns: 1fr;
  }
}

.link-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.link-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.link-card.is-favorite {
  border-color: #fcd34d;
  box-shadow: 0 0 0 1px #fcd34d, var(--shadow);
}

.link-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.link-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}
.link-logo-placeholder {
  width: 48px;
  height: 48px;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.link-card-body {
  flex: 1;
}
.link-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-url {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.fav-btn {
  position: relative;
  z-index: 2;
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}
.fav-btn:hover,
.fav-btn.active {
  color: #f59e0b;
}
.fav-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #fcd34d;
  color: #78350f;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 0 var(--radius) 0 8px;
}

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  transition: 0.2s;
  text-decoration: none;
}
.page-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  text-decoration: none;
}
.page-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ─── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ─── Admin Layout ──────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}
.admin-nav {
  width: 220px;
  background: #1e293b;
  padding: 24px 0;
  flex-shrink: 0;
}
.admin-nav .nav-item {
  display: block;
  padding: 11px 24px;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 500;
  transition: 0.15s;
  text-decoration: none;
}
.admin-nav .nav-item:hover,
.admin-nav .nav-item.active {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}
.admin-main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}
.admin-main h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 28px;
}

/* ─── Stat Grid ─────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
}
.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td {
  background: #f8fafc;
}
.action-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.table-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
.table-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
}
.table-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
}
.table-logo-placeholder {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green {
  background: #dcfce7;
  color: #166534;
}
.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

/* ─── Add Form Panel ────────────────────────────────────────────────────── */
.add-form-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.add-form-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  user-select: none;
}
.inline-form {
  margin-top: 16px;
}
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 {
  font-size: 1.2rem;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
