/* ==========================================================================
   Home Lab - Google Photos Clean Light Theme
   ========================================================================== */

:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-search: #f1f3f4;
  --bg-search-focus: #ffffff;
  --bg-hover: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --border-color: #dadce0;
  --border-subtle: #f1f3f4;
  --google-blue: #1a73e8;
  --google-blue-hover: #1557b0;
  --card-radius: 20px;
  --inner-radius: 14px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px -4px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.06), 0 24px 48px -6px rgba(0, 0, 0, 0.15);
  --font-family: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Standardized 44px Google Back Button
   -------------------------------------------------------------------------- */
.gp-icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
  padding: 0;
  flex-shrink: 0;
}

.gp-icon-btn:hover {
  background-color: var(--bg-hover);
}

.gp-icon-btn:active {
  transform: scale(0.92);
}

.gp-icon-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* --------------------------------------------------------------------------
   Top Navigation Bar (Home Lab)
   -------------------------------------------------------------------------- */
.gp-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 20px;
}

.gp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
}

.gp-pinwheel {
  width: 32px;
  height: 32px;
  display: block;
}

.gp-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.gp-brand-logo.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.gp-brand-logo.placeholder-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  opacity: 0.9;
}

.gp-brand-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* Search Bar (Google Photos Pill) */
.gp-search-wrap {
  flex: 1;
  max-width: 680px;
  position: relative;
}

.gp-search-bar {
  width: 100%;
  height: 46px;
  background-color: var(--bg-search);
  border: 1px solid transparent;
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  transition: background-color 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.gp-search-bar:focus-within {
  background-color: var(--bg-search-focus);
  box-shadow: 0 1px 6px rgba(32,33,36,0.24);
  border-color: transparent;
}

.gp-search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.gp-search-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
}

.gp-search-input::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

.gp-search-clear {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  display: none;
}

.gp-search-clear:hover {
  background-color: var(--bg-hover);
}

.gp-search-clear.active {
  display: block;
}

/* PWA Install Button */
.gp-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 36px;
  flex-shrink: 0;
}

.gp-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background-color: #ffffff;
  color: var(--primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gp-install-btn:hover {
  background-color: var(--bg-hover);
  border-color: rgba(26, 115, 232, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.gp-install-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--primary);
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .gp-install-btn span {
    display: none;
  }
  .gp-install-btn {
    padding: 0 10px;
    height: 36px;
    border-radius: 50%;
  }
}

/* --------------------------------------------------------------------------
   Main Container
   -------------------------------------------------------------------------- */
.gallery-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 64px;
  flex: 1;
}

/* Filter Chips (Google Photos Category / Year filters) */
.filter-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.filter-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-chip.active {
  background: #e8f0fe;
  color: var(--google-blue);
  border-color: #d2e3fc;
  font-weight: 500;
}

.section-header {
  margin: 12px 0 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.2px;
}

.section-count {
  font-size: 14px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Albums Grid with Date Information
   -------------------------------------------------------------------------- */
.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px;
}

.album-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--card-radius);
  padding: 10px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s;
}

.album-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(26, 115, 232, 0.3);
}

.album-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--inner-radius);
  overflow: hidden;
  background-color: var(--bg-search);
}

.album-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.album-card:hover .album-cover-wrap img {
  transform: scale(1.04);
}

.album-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f1f3f4;
  color: #bdc1c6;
  font-size: 38px;
}

.album-info {
  padding: 12px 6px 6px;
}

.album-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}

.album-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-dot {
  font-size: 10px;
  color: var(--text-muted);
}

.album-date-badge {
  color: var(--text-secondary);
  font-weight: 400;
}

.album-count-badge {
  background: #f1f3f4;
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Inside Album: Modern Grid & Month/Year Date Grouping
   -------------------------------------------------------------------------- */
.album-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.album-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.album-detail-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.2px;
}

.album-detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Date Category Groups */
.photo-date-group {
  margin-bottom: 32px;
}

.photo-date-header {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 16px 4px 10px;
  letter-spacing: 0.1px;
}

/* Final Tiles / Mosaic Modern Grid */
.final-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  grid-auto-rows: 170px;
  grid-auto-flow: dense;
  gap: 10px;
}

.final-tile {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--bg-search);
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s;
}

.final-tile:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  border-color: rgba(26, 115, 232, 0.25);
  z-index: 5;
}

.final-tile img,
.final-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.final-tile:hover img {
  transform: scale(1.04);
}

/* Mosaic Span Classes */
.tile-big {
  grid-column: span 2;
  grid-row: span 2;
}

.tile-wide {
  grid-column: span 2;
  grid-row: span 1;
}

.tile-tall {
  grid-column: span 1;
  grid-row: span 2;
}

.tile-normal {
  grid-column: span 1;
  grid-row: span 1;
}

/* Video Badge */
.video-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Google Photos Full-Screen Lightbox (Viewer)
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.96);
  display: flex;
  flex-direction: column;
}

.lightbox[hidden] {
  display: none !important;
}

.lightbox-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  color: #ffffff;
  z-index: 10;
  flex-shrink: 0;
}

.lightbox-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lightbox .gp-icon-btn {
  color: #ffffff;
}

.lightbox .gp-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-caption {
  font-size: 14px;
  font-weight: 500;
  color: #e8eaed;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.download-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s;
}

.download-btn:hover {
  background-color: rgba(255, 255, 255, 0.24);
}

.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0 48px;
}

.lightbox-stage img,
.lightbox-stage video {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Lightbox Nav Chevrons */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  color: #ffffff;
  font-size: 28px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
  z-index: 5;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

/* --------------------------------------------------------------------------
   States & Footer
   -------------------------------------------------------------------------- */
.loading-state,
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--google-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
  display: block;
}

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

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.login-wrap {
  max-width: 440px;
  margin: 12vh auto 0;
  padding: 0 16px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 40px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 16px 0 8px;
}

.login-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 20px;
}

.login-footnote {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  margin-top: 24px !important;
  margin-bottom: 0 !important;
}

.gallery-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

/* --------------------------------------------------------------------------
/* Floating Mobile Bottom-Right Back Button (hidden by default on desktop) */
.floating-mobile-back {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Mobile Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .gp-topbar {
    padding: 0 12px;
    height: 56px;
    gap: 10px;
  }

  .gallery-container {
    padding: 14px 14px 84px;
  }

  .albums-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .final-tiles-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 130px;
    gap: 6px;
  }

  .lightbox-prev {
    left: 8px;
  }

  .lightbox-next {
    right: 8px;
  }

  .lightbox-topbar {
    padding: 10px 14px;
  }

  /* Floating Bottom-Right Back Button on Mobile */
  .floating-mobile-back {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 26px;
    background-color: #ffffff;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 1px 4px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    z-index: 2000;
    touch-action: manipulation;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), background-color 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .floating-mobile-back:active {
    transform: scale(0.92);
    background-color: var(--bg-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  }

  .floating-mobile-back svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
  }

  .floating-mobile-back[hidden] {
    display: none !important;
  }
}

