/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

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

:root {
  color-scheme: light;
}

body {
  font-family: -apple-system, sans-serif;
  background: #f5f5f5;
  color: #333;
}

nav {
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-left {
  min-width: 0;
  flex: 1;
}

.nav-right {
  flex-shrink: 0;
  position: relative;
}

.nav-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
  text-decoration: none;
  color: #4f46e5;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.nav-link { text-decoration: none; color: #555; font-size: 0.9rem; }
.nav-user-name { font-size: 0.92rem; color: #4b5563; font-weight: 600; }
.nav-right form { margin: 0; }
.btn-primary-sm { background: #4f46e5; color: #fff; padding: 6px 14px; border-radius: 8px; text-decoration: none; font-size: 0.9rem; }

.nav-menu {
  position: relative;
}

.nav-menu-button {
  cursor: pointer;
}

.nav-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.12);
}

.nav-menu-backdrop[hidden],
.nav-menu-panel[hidden] {
  display: none;
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 240;
  width: min(86vw, 300px);
  min-height: 240px;
  padding: 18px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.nav-menu-header strong {
  font-size: 1rem;
  color: #111827;
}

.nav-menu-header span {
  font-size: 0.86rem;
  color: #6b7280;
}

.nav-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
}

.nav-switch-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.nav-switch-copy strong {
  font-size: 0.96rem;
  color: #111827;
}

.nav-switch-copy span {
  font-size: 0.84rem;
  color: #6b7280;
  line-height: 1.45;
}

.nav-switch {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 32px;
}

.nav-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.nav-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d1d5db;
  transition: background 0.2s ease;
}

.nav-switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
  transition: transform 0.2s ease;
}

.nav-switch input:checked + .nav-switch-track {
  background: #4f46e5;
}

.nav-switch input:checked + .nav-switch-track::after {
  transform: translateX(20px);
}

.nav-switch input:disabled + .nav-switch-track {
  background: #e5e7eb;
}

.nav-menu-footer {
  margin-top: auto;
}

.nav-menu-logout {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: #111827;
  color: #ffffff;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

main { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.notice { background: #d1fae5; border: 1px solid #6ee7b7; padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; }
.alert { background: #fee2e2; border: 1px solid #fca5a5; padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; color: #dc2626; }

/* Auth pages */
.auth-container { max-width: 420px; margin: 60px auto; background: #fff; padding: 40px; border-radius: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.auth-container h1 { margin-bottom: 8px; }
.subtitle { color: #888; font-size: 0.9rem; margin-bottom: 24px; }
.auth-link { margin-top: 20px; text-align: center; font-size: 0.9rem; color: #666; }
.auth-link a { color: #4f46e5; text-decoration: none; font-weight: 500; }

/* Family header */
.family-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.family-actions { display: flex; gap: 10px; }
.member-count { font-size: 0.85rem; color: #888; margin-top: 2px; }
.btn-primary { background: #4f46e5; color: #fff; padding: 8px 18px; border-radius: 8px; text-decoration: none; font-size: 0.9rem; }
.btn-secondary { background: #f3f4f6; color: #333; padding: 8px 18px; border-radius: 8px; text-decoration: none; font-size: 0.9rem; border: 1px solid #e0e0e0; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: #888; }
.empty-state p { margin-bottom: 20px; }

.family-selector-header {
  margin-bottom: 28px;
}

.family-selector-header .subtitle {
  margin-bottom: 0;
}

.family-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.family-selector-card {
  display: block;
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.08);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.family-selector-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(79, 70, 229, 0.12);
}

.family-selector-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.family-selector-top h2 {
  font-size: 1.1rem;
  color: #111827;
}

.family-selector-top span {
  font-size: 0.82rem;
  color: #4f46e5;
  font-weight: 700;
}

.family-selector-card p {
  margin: 0;
  color: #6b7280;
  font-size: 0.92rem;
}

.family-selector-empty {
  background: #fff;
  border: 1px dashed #c7d2fe;
  border-radius: 18px;
}

/* Members page */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header a:not(.btn-primary):not(.btn-secondary) { text-decoration: none; color: #4f46e5; }
.section { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 20px; }
.section h2 { font-size: 1.1rem; margin-bottom: 16px; }
.section h3 { font-size: 0.95rem; margin: 20px 0 10px; color: #555; }
.member-list { display: flex; flex-direction: column; gap: 12px; }
.member-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; }
.member-item:last-child { border-bottom: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: #4f46e5; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.member-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-info strong { font-size: 0.95rem; }
.email { color: #888; font-size: 0.85rem; }
.role-badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.role-admin { background: #fef3c7; color: #d97706; }
.role-member { background: #f0fdf4; color: #16a34a; }

/* Invitations */
.invite-form { margin-bottom: 8px; }
.invite-row label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 6px; }
.invite-input-row { display: flex; gap: 8px; }
.invite-input-row input[type=email] { flex: 1; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 0.95rem; }
.invite-input-row input[type=submit] { background: #4f46e5; color: #fff; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.invitation-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.invitation-item { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; background: #f9f9f9; padding: 8px 12px; border-radius: 8px; }
.invitation-item code { color: #4f46e5; font-size: 0.8rem; word-break: break-all; }
.invite-actions { margin: 24px 0; }

/* No image placeholder */
.no-image { width: 100%; height: 180px; background: #f0f0f0; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 0.85rem; }

h1 { font-size: 1.6rem; margin-bottom: 20px; }
h3 { font-size: 1rem; margin-bottom: 10px; color: #555; }

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

.photo-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}

.photo-card:hover { transform: translateY(-2px); }
.photo-card a { text-decoration: none; color: #333; display: block; }
.photo-card p { padding: 10px 12px; font-size: 0.9rem; }

.thumbnail { width: 100%; height: 180px; object-fit: cover; display: block; }

.photo-show { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.photo-full-trigger {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  margin-bottom: 20px;
  cursor: zoom-in;
  text-align: left;
}

.photo-full { width: 100%; max-height: 500px; object-fit: contain; border-radius: 8px; display: block; background: #f0f0f0; }

.photo-full-hint {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #6b7280;
}

body.photo-viewer-open {
  overflow: hidden;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(12px);
}

.photo-viewer[hidden] {
  display: none !important;
}

.photo-viewer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 8px;
  color: #fff;
}

.photo-viewer-copy strong {
  display: block;
  font-size: 1rem;
}

.photo-viewer-copy span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
}

.photo-viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-viewer-control {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  min-width: 48px;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
}

.photo-viewer-control.close {
  min-width: 64px;
}

.photo-viewer-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: default;
}

.photo-viewer-stage.is-zoomed {
  cursor: grab;
}

.photo-viewer-stage.is-zoomed:active {
  cursor: grabbing;
}

.photo-viewer-image {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  pointer-events: auto;
  touch-action: none;
}

.photo-show h1 { margin-bottom: 8px; }
.photo-show p { color: #666; margin-bottom: 20px; }

.reactions { margin-bottom: 24px; }
.reaction-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.reaction-btn { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 20px; padding: 6px 14px; font-size: 1rem; cursor: pointer; transition: background 0.1s; }
.reaction-btn:hover { background: #e0e7ff; }

.comments-section {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid #ece8ff;
  border-radius: 16px;
  background: linear-gradient(180deg, #faf8ff 0%, #ffffff 100%);
}

.comments-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.comments-header span {
  font-size: 0.85rem;
  color: #7c6db0;
}

.comment-form textarea {
  min-height: 88px;
  margin-bottom: 10px;
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.comment-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #ece8ff;
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.comment-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.comment-author strong {
  display: block;
  font-size: 0.95rem;
}

.comment-author span {
  font-size: 0.8rem;
  color: #8a8a99;
}

.comment-author .comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.comment-body {
  margin: 0;
  color: #444;
  line-height: 1.6;
}

.comment-body span {
  display: block;
}

.comment-delete {
  border: none;
  background: #fff1f2;
  color: #e11d48;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
}

.comments-empty {
  margin-top: 12px;
  color: #8a8a99;
  font-size: 0.9rem;
}

.share-section { margin-bottom: 24px; }
.share-section input { width: 100%; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 0.85rem; cursor: pointer; background: #f9f9f9; }
.share-section small { color: #999; font-size: 0.75rem; }

.actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.actions a { text-decoration: none; color: #4f46e5; }
.actions form button { background: #fee2e2; border: none; color: #dc2626; padding: 6px 14px; border-radius: 8px; cursor: pointer; }

form div { margin-bottom: 16px; }
form label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
form input[type=text], form textarea { width: 100%; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 1rem; }
form textarea { resize: vertical; }
form input[type=file] { font-size: 0.9rem; }
form input[type=submit] { background: #4f46e5; color: #fff; padding: 10px 24px; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; }

.errors { background: #fee2e2; border: 1px solid #fca5a5; padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; color: #dc2626; }

.upload-status {
  margin-top: 10px;
  min-height: 1.4em;
  font-size: 0.92rem;
  color: #6b7280;
}

.upload-status[data-tone="success"] {
  color: #047857;
}

.upload-status[data-tone="error"] {
  color: #dc2626;
}

body.upload-overlay-open {
  overflow: hidden;
}

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(6px);
}

.upload-overlay[hidden] {
  display: none;
}

.upload-overlay-card {
  width: min(100%, 320px);
  padding: 28px 24px;
  border-radius: 20px;
  text-align: center;
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

.upload-overlay-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.05rem;
  color: #111827;
}

.upload-overlay-card p {
  margin: 0;
  color: #6b7280;
  line-height: 1.5;
}

.upload-overlay-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 999px;
  border: 4px solid #dbeafe;
  border-top-color: #2563eb;
  animation: upload-spin 0.9s linear infinite;
}

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

@media (max-width: 768px) {
  nav {
    padding: 12px 16px;
  }

  .nav-title {
    font-size: 0.95rem;
  }

  .nav-right {
    gap: 8px;
  }

  .nav-user-name {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-header,
  .family-header,
  .family-selector-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .family-actions,
  .family-selector-header {
    width: 100%;
  }

  .family-selector-header .btn-primary {
    width: 100%;
    text-align: center;
  }

  .photo-viewer-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 12px 8px;
  }

  .photo-viewer-controls {
    justify-content: space-between;
  }

  .photo-viewer-control {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
  }

  .photo-viewer-image {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 164px);
  }

  input:not([type=hidden]),
  textarea,
  select,
  button {
    font-size: 16px !important;
  }
}
