/* === Rewards Hub Styles === */

:root {
  --bg: #0a0a0f;
  --bg-elev: #14141c;
  --bg-elev-2: #1c1c26;
  --border: #2a2a35;
  --text: #e4e4eb;
  --text-muted: #888893;
  --text-dim: #5a5a65;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --purple: #a855f7;
  --orange: #f97316;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 150ms ease;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
  color: inherit;
}

input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* === Lock screen === */

.lock-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.lock-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.lock-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.lock-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.lock-sub {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

#lock-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.5rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: 1rem;
}

#lock-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.lock-error {
  color: var(--danger);
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background var(--transition), transform var(--transition);
  width: 100%;
  margin-bottom: 0.5rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* === App layout === */

.app {
  min-height: 100vh;
  padding-bottom: 4rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-size: 1.75rem;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--transition);
}

.profile-btn:hover {
  background: var(--border);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.chevron {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* === Profile menu === */

.profile-menu {
  position: fixed;
  top: 4.5rem;
  right: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  min-width: 240px;
  overflow: hidden;
}

.profile-menu-section {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.profile-menu-section:last-child {
  border-bottom: none;
}

.menu-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem 0.25rem;
}

.menu-btn,
.profile-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.9rem;
  transition: background var(--transition);
}

.menu-btn:hover,
.profile-list-item:hover {
  background: var(--bg-elev-2);
}

.profile-list-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

/* === Layout (main + sidebar) === */

.layout-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2rem;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

.layout-main {
  min-width: 0;
}

/* === Controls (search/filter) === */

.controls {
  padding: 1.5rem 0 0;
}

.search-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.6;
}

#search {
  width: 100%;
  padding: 0.875rem 2.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

#search:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--text-muted);
  background: var(--bg-elev-2);
}

.search-clear:hover {
  background: var(--border);
  color: var(--text);
}

.filter-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.category-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.pill {
  padding: 0.4rem 0.875rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.pill:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.sort-select {
  padding: 0.4rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-row.secondary {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--primary);
}

.result-count {
  margin-left: auto;
}

/* === Brand grid === */

.brand-grid-wrap {
  padding: 1rem 0;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.brand-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.brand-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-color, var(--primary));
}

.brand-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-color, var(--primary));
}

.brand-card.signed-up {
  opacity: 0.5;
}

.brand-card.signed-up::after {
  content: "✓ Signed up";
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.7rem;
  background: var(--success);
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.brand-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brand-color, var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand-info {
  flex: 1;
  min-width: 0;
}

.brand-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

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

.brand-welcome {
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg-elev-2);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-color, var(--primary));
}

.brand-welcome-value {
  font-weight: 700;
  color: var(--success);
}

.brand-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-elev-2);
  color: var(--text-muted);
}

.badge.method-google {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge.method-form {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}

.badge.method-app {
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange);
}

.badge.method-fee {
  background: rgba(168, 85, 247, 0.15);
  color: var(--purple);
}

.badge.method-impossible {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.brand-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.brand-actions .btn {
  margin-bottom: 0;
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
}

.brand-actions .btn-primary {
  flex: 1;
}

.brand-actions .btn-secondary {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: auto;
  padding: 0.5rem 0.75rem;
}

.brand-actions .btn-secondary:hover {
  background: var(--border);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

/* === Legend sidebar === */

.legend {
  position: sticky;
  top: 5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.legend-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.legend-section {
  margin-bottom: 1.25rem;
}

.legend-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.legend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.legend-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.legend-list .badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  white-space: nowrap;
}

.legend-checkbadge {
  flex-shrink: 0;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  background: var(--success);
  color: white;
  white-space: nowrap;
}

.legend-tip {
  background: var(--bg-elev-2);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
  border-left: 3px solid var(--primary);
}

.legend-tip strong {
  color: var(--text);
  font-weight: 600;
}

/* === Footer === */

.footer {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* === Modal === */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: var(--bg-elev-2);
  z-index: 1;
}

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

.modal-card h2 {
  margin-bottom: 1rem;
  font-size: 1.35rem;
}

/* Brand modal */

.modal-brand-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-right: 2rem;
}

.modal-brand-header .brand-logo {
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
}

.modal-brand-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.modal-brand-header .brand-category {
  font-size: 0.85rem;
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.modal-section p {
  font-size: 0.95rem;
}

.modal-section .value {
  color: var(--success);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn {
  margin-bottom: 0;
}

/* === Profile form === */

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.profile-form input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-top: 0.25rem;
}

.profile-form input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.profile-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.profile-form legend {
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.form-actions .btn {
  margin-bottom: 0;
  flex: 1;
}

/* === Log === */

.log-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.log-item:hover {
  background: var(--border);
}

.log-item input {
  accent-color: var(--success);
  width: 18px;
  height: 18px;
}

.log-item.done {
  opacity: 0.55;
  text-decoration: line-through;
}

.log-item-name {
  flex: 1;
  font-size: 0.9rem;
}

.log-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === Toast === */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
}

/* === Mobile responsive === */

@media (max-width: 1024px) {
  .layout-wrap {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .legend {
    position: static;
    margin-top: 1.5rem;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .layout-wrap {
    padding: 0 1rem;
  }

  .controls {
    padding: 1rem 0 0;
  }

  .brand-grid-wrap {
    padding: 0.75rem 0;
  }

  .brand-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .filter-row {
    gap: 0.5rem;
  }

  .pill {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
  }

  .profile-menu {
    right: 1rem;
    left: 1rem;
    min-width: auto;
  }

  .modal-card {
    padding: 1.5rem 1.25rem;
  }

  .footer {
    padding: 1rem;
  }
}
