@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #36A635;
  --green-dark:  #2A7D29;
  --green-light: #EBF7EB;
  --green-mid:   #C8EBC8;
  --gold:        #F59E0B;
  --text:        #1A1A1A;
  --text-muted:  #6B7280;
  --border:      #E5E7EB;
  --bg:          #F7F8F9;
  --white:       #FFFFFF;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-hover:0 8px 24px rgba(0,0,0,.10);
  --font:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}

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

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  background: #F5F5F5;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 40px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.site-logo img.keap-logo {
  height: 28px;
  width: auto;
  display: block;
}

.logo-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.logo-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .01em;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 20px;
  border-bottom: 2px solid transparent;
  background: transparent;
  transition: color .2s, border-color .2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  height: 100%;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text);
  font-weight: 600;
  border-bottom: 2px solid var(--green);
  text-decoration: none;
}

/* ── Hero ────────────────────────────────────────────────────────────────────── */
.hero {
  background: #F5F5F5;
  padding: 52px 24px 44px;
  text-align: center;
  color: var(--text);
  border-bottom: 1px solid #E5E7EB;
}

.hero h1 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 28px;
  letter-spacing: -0.3px;
  color: #1A1A1A;
}

.hero-tabs {
  display: inline-flex;
  gap: 0;
}

.hero-tab {
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 20px;
  transition: color .2s, border-color .2s;
}

.hero-tab:hover {
  color: var(--text);
}

.hero-tab.active {
  color: var(--text);
  font-weight: 600;
  border-bottom: 2px solid var(--green);
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 76px;
}

.filter-block {
  margin-bottom: 16px;
}

.filter-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-input,
.filter-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--white);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(54,166,53,.12);
}

.filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.btn-clear {
  width: 100%;
  margin-top: 4px;
  padding: 4px 0;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.85rem;
  color: #2563EB;
  cursor: pointer;
  text-align: left;
  transition: color .15s;
}

.btn-clear:hover {
  color: #1D4ED8;
  text-decoration: underline;
}

/* ── Results bar ─────────────────────────────────────────────────────────────── */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.result-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-select {
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.sort-select:focus { outline: none; border-color: var(--green); }

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
}

.view-btn {
  border: none;
  background: none;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: background .15s, color .15s;
}

.view-btn.active,
.view-btn:hover {
  background: var(--white);
  color: var(--green);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── Provider Cards (Grid) ───────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: #CBD5E1;
}

/* Grid card layout */
.results-grid .card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.results-grid .card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* List card layout */
.results-list .card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.results-list .card-top {
  flex-shrink: 0;
}

.results-list .card-body {
  flex: 1;
  min-width: 0;
}

/* Avatar */
.card-avatar {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.card-avatar-initial {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4B5563 0%, #6B7280 100%);
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}

.card-location {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-rating {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stars {
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 1px;
  line-height: 1;
}

.rating-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.review-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  /* Show 3 lines then truncate */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.tag {
  background: #F3F4F6;
  color: #374151;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

/* ── App Cards ───────────────────────────────────────────────────────────────── */
.app-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--white);
  padding: 4px;
  flex-shrink: 0;
}

.app-logo-initial {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, #374151 0%, #6B7280 100%);
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-category-badge {
  display: inline-block;
  background: #EFF6FF;
  color: #2563EB;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #BFDBFE;
}

.app-edition-badge {
  display: inline-block;
  background: #F0FDF4;
  color: #16A34A;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #BBF7D0;
}

.app-price {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.app-developer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── States: loading, empty ──────────────────────────────────────────────────── */
.state-loading,
.state-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 36px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--white);
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.page-btn:hover {
  border-color: #9CA3AF;
  background: #F3F4F6;
  color: var(--text);
}

.page-btn.active {
  background: #E5E7EB;
  border-color: #D1D5DB;
  color: var(--text);
  font-weight: 600;
}

.page-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal-panel {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  position: relative;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  z-index: 1;
}

.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 32px; }

/* Detail header */
.detail-header {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.detail-avatar {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
}

.detail-avatar-initial {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4B5563 0%, #6B7280 100%);
  color: white;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-avatar-initial.app {
  background: linear-gradient(135deg, #374151 0%, #6B7280 100%);
}

.detail-name {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}

.detail-tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.detail-location {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.btn-visit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green);
  color: white;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-visit:hover { background: var(--green-dark); text-decoration: none; color: white; }

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-section { margin-bottom: 24px; }

.detail-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-description {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-line;
}

/* Reviews */
.reviews-list { display: flex; flex-direction: column; gap: 16px; }

.review {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px 16px;
}

.review-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.review-author { font-weight: 600; font-size: 0.88rem; }

.review-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

.review-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Login button in header ──────────────────────────────────────────────────── */
.btn-header-login {
  padding: 5px 16px;
  background: var(--white);
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  color: #2563EB;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: border-color .15s, background .15s;
}

.btn-header-login:hover {
  border-color: #2563EB;
  background: #EFF6FF;
  text-decoration: none;
  color: #1D4ED8;
}

/* ── Auth nav ────────────────────────────────────────────────────────────────── */
.auth-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.auth-user-name {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Login modal ──────────────────────────────────────────────────────────────── */
.login-overlay { align-items: center; }

.login-panel {
  max-width: 400px;
  width: 100%;
  border-radius: 18px;
  animation: slideUp .2s ease;
}

.login-body {
  padding: 36px 32px 32px;
  text-align: center;
}

.login-icon { font-size: 2.2rem; margin-bottom: 12px; }

.login-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-field {
  text-align: left;
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(54,166,53,.12);
}

.login-error {
  background: #FEE2E2;
  color: #991B1B;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 7px;
  padding: 9px 12px;
  margin-bottom: 14px;
  text-align: left;
}

.btn-login-submit {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  margin-top: 4px;
}

.btn-login-submit:hover { background: var(--green-dark); }
.btn-login-submit:disabled { opacity: .55; cursor: not-allowed; }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--white);
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links { display: flex; gap: 20px; }

.footer-links a {
  color: #2563EB;
  text-decoration: none;
  transition: color .15s;
}

.footer-links a:hover { color: #1D6FD8; }

/* ── Edit listing button (modal) ──────────────────────────────────────────── */
.btn-edit-listing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  white-space: nowrap;
  background: #FEF9C3;
  color: #92400E;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn-edit-listing:hover { background: #FDE68A; }

.btn-remove-card {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  white-space: nowrap;
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.btn-remove-card:hover { background: #FECACA; }

.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  margin: 16px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.btn-leave-review {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  white-space: nowrap;
  background: #F0FDF4;
  color: #15803D;
  border: 1px solid #BBF7D0;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.btn-leave-review:hover { background: #DCFCE7; }
