/* ==========================================================================
   Arlo - Minimalist Grey & White Theme
   ========================================================================== */

:root {
  --bg-page: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f0f0f2;
  --bg-hover: #eaeaecef;
  --bg-inverse: #18181b;

  --text-primary: #111113;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --text-inverse: #ffffff;

  --border-light: #e4e4e7;
  --border-medium: #d4d4d8;
  --border-strong: #18181b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
}

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

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   1. Gate View (Auth Key + Dropdown Identity Selector)
   ========================================================================== */

.gate-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-page);
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-sm);
}

.gate-header {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  background: var(--bg-inverse);
  border: 1px solid var(--border-light);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.brand-mark img,
.brand-mark-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.gate-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 8px;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.textarea-input {
  resize: vertical;
}

.error-text {
  font-size: 13px;
  color: #dc2626;
  margin-top: 2px;
}

.status-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

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

.btn-primary {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border-color: var(--bg-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: #27272a;
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
  background: #e4e4e7;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  align-self: center;
  margin-top: 4px;
}

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

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

/* ==========================================================================
   2. Topbar & Member Navigation
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-sm {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-inverse);
  border: 1px solid var(--border-light);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.topbar-brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.counter-pill {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 3px 12px 3px 4px;
}

.viewer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Avatars */
.avatar {
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
}

/* Horizontal Family Member Tabs */
.member-tabs-bar {
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.member-tabs-scroll {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.member-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.member-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.member-tab:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.member-tab.active {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border-color: var(--bg-inverse);
}

.member-tab.active .avatar {
  border-color: rgba(255, 255, 255, 0.25);
  background: #3f3f46;
  color: #ffffff;
}

.member-tab-count {
  font-size: 11px;
  opacity: 0.75;
  padding-left: 2px;
}

/* ==========================================================================
   3. Main Content & Gift Cards
   ========================================================================== */

.main-content {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.list-person-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.list-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.list-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.list-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  background: var(--bg-muted);
}

.filter-pill.active {
  background: var(--bg-inverse);
  color: var(--text-inverse);
  border-color: var(--bg-inverse);
}

.surprise-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Items Sections & Grid */
.items-sections {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.present-tier-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.present-tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.present-tier-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.present-tier-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.present-tier-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.item-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-medium);
}

.item-card.is-claimed-other {
  background: var(--bg-subtle);
}

.item-media {
  width: 100%;
  height: 170px;
  background: #fafafa;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.item-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.item-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.store-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 2px 7px;
  border-radius: 4px;
}

.priority-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-muted);
  border: 1px solid var(--border-medium);
  padding: 1px 7px;
  border-radius: 4px;
}

.item-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.item-title a {
  color: inherit;
  text-decoration: none;
}

.item-title a:hover {
  text-decoration: underline;
}

.item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.item-notes {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-line;
  word-break: break-word;
}

.item-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  margin-top: 2px;
}

.item-link-btn:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Item Footer (Owner Edit/Delete OR Family Claim/Bought/Contributors Controls) */
.item-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.claim-people-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.claim-role-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.claim-role-line strong {
  color: var(--text-primary);
  font-weight: 600;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-inverse);
  color: var(--text-inverse);
}

.role-pill.contributing {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}

.contributors-avatars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.claim-status-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.claim-status-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.claim-status-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.available {
  background: #a1a1aa;
}

.status-dot.claimed {
  background: #52525b;
}

.status-dot.purchased {
  background: #18181b;
}

.claim-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.purchased-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-inverse);
  color: var(--text-inverse);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 28px;
  margin-bottom: 10px;
  filter: grayscale(100%);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 16px;
}

/* ==========================================================================
   4. Modals & Admin Panel
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 17, 19, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-lg {
  max-width: 620px;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

/* Admin Members Grid */
.admin-members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.admin-member-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.admin-member-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.admin-member-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-member-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 4px 0;
}

.add-member-row {
  display: flex;
  gap: 8px;
}

/* Shopping List Modal Rows */
.shopping-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.shopping-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.shopping-recipient {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.shopping-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .topbar-inner {
    padding: 10px 14px;
  }
  .main-content {
    padding: 20px 14px 48px;
  }
}
