/* =====================================================
   Google Photos-inspired UI
   ===================================================== */

:root {
  --gp-blue: #1a73e8;
  --gp-blue-dark: #1557b0;
  --gp-surface: #fff;
  --gp-bg: #f8f9fa;
  --gp-text: #202124;
  --gp-text-muted: #5f6368;
  --gp-text-light: #9aa0a6;
  --gp-border: #dadce0;
  --gp-hover: #f1f3f4;
  --gp-active-bg: #e8f0fe;
  --gp-topbar-h: 64px;
  --gp-sidebar-w: 72px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  background: var(--gp-surface);
  color: var(--gp-text);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--gp-blue);
  text-decoration: none;
}

/* =====================================================
   Top Bar
   ===================================================== */

.gp-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--gp-topbar-h);
  background: var(--gp-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.gp-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.gp-logo svg {
  width: 36px;
  height: 36px;
}

.gp-logo-text {
  font-size: 22px;
  font-weight: 400;
  color: var(--gp-text-muted);
  letter-spacing: -0.5px;
}

.gp-topbar-spacer {
  flex: 1;
}

.gp-user-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gp-username {
  font-size: 13px;
  color: var(--gp-text-muted);
}

/* =====================================================
   Sidebar
   ===================================================== */

.gp-sidebar {
  position: fixed;
  top: var(--gp-topbar-h);
  left: 0;
  bottom: 0;
  width: var(--gp-sidebar-w);
  background: var(--gp-surface);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  gap: 2px;
  overflow: hidden;
}

.gp-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  border-radius: 16px;
  cursor: pointer;
  text-decoration: none;
  color: var(--gp-text-muted);
  font-size: 11px;
  width: 64px;
  text-align: center;
  transition: background 0.15s;
}

.gp-nav-item:hover {
  background: var(--gp-hover);
  color: var(--gp-text);
}

.gp-nav-item.active {
  background: var(--gp-active-bg);
  color: var(--gp-blue);
}

.gp-nav-item .material-icons {
  font-size: 24px;
}

/* =====================================================
   Main Content Area
   ===================================================== */

.gp-main {
  margin-top: var(--gp-topbar-h);
  margin-left: var(--gp-sidebar-w);
  padding: 0 24px 48px;
  min-height: calc(100vh - var(--gp-topbar-h));
}

.gp-main-full {
  margin-top: var(--gp-topbar-h);
  margin-left: 0;
  padding: 0 24px 48px;
}

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

.btn-gp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-gp .material-icons {
  font-size: 18px;
}

.btn-gp-primary {
  background: var(--gp-blue);
  color: #fff;
}

.btn-gp-primary:hover {
  background: var(--gp-blue-dark);
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.35);
  color: #fff;
}

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

.btn-gp-secondary:hover {
  background: var(--gp-active-bg);
  color: var(--gp-blue);
}

.btn-gp-danger {
  background: transparent;
  color: #d93025;
  border: 1px solid #fce8e6;
}

.btn-gp-danger:hover {
  background: #fce8e6;
}

.btn-gp-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
}

.btn-gp-icon .material-icons {
  font-size: 20px;
}

/* =====================================================
   Album Grid (Albums page)
   ===================================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 400;
  color: var(--gp-text);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding-bottom: 24px;
}

.album-card {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.2s;
}

.album-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  color: inherit;
}

.album-cover-wrap {
  position: relative;
  width: 100%;
  padding-top: 100%; /* square */
  overflow: hidden;
  background: var(--gp-bg);
  border-radius: 8px;
}

.album-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

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

.album-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f1f3f4, #dadce0);
  color: var(--gp-text-light);
}

.album-cover-placeholder .material-icons {
  font-size: 56px;
}

.album-info {
  padding: 8px 2px 4px;
}

.album-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-count {
  font-size: 12px;
  color: var(--gp-text-muted);
  margin-top: 1px;
}

/* =====================================================
   Album Detail Header
   ===================================================== */

.album-header {
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--gp-border);
  margin-bottom: 8px;
}

.album-header-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.album-title-wrap {
  flex: 1;
  min-width: 200px;
}

.album-title-input {
  font-size: 26px;
  font-weight: 400;
  border: none;
  outline: none;
  border-bottom: 2px solid transparent;
  padding: 2px 0;
  transition: border-color 0.2s;
  background: transparent;
  color: var(--gp-text);
  width: 100%;
  font-family: inherit;
}

.album-title-input:hover {
  border-bottom-color: var(--gp-border);
}

.album-title-input:focus {
  border-bottom-color: var(--gp-blue);
}

.album-desc-input {
  font-size: 14px;
  color: var(--gp-text-muted);
  border: none;
  outline: none;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  transition: border-color 0.2s;
  background: transparent;
  width: 100%;
  font-family: inherit;
  margin-top: 6px;
}

.album-desc-input:hover {
  border-bottom-color: var(--gp-border);
}

.album-desc-input:focus {
  border-bottom-color: var(--gp-blue);
}

.album-meta {
  font-size: 13px;
  color: var(--gp-text-muted);
  margin-top: 6px;
}

.album-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* =====================================================
   Share Panel
   ===================================================== */

.share-panel {
  background: var(--gp-bg);
  border: 1px solid var(--gp-border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  display: none;
}

.share-panel.open {
  display: block;
}

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

.share-panel-label {
  font-size: 14px;
  font-weight: 500;
}

.share-panel-sub {
  font-size: 12px;
  color: var(--gp-text-muted);
  margin-top: 2px;
}

.share-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.share-toggle-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gp-blue);
  cursor: pointer;
}

.share-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-link-input {
  flex: 1;
  border: 1px solid var(--gp-border);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gp-text-muted);
  background: var(--gp-surface);
  cursor: text;
  user-select: all;
  font-family: monospace;
}

/* =====================================================
   Sort Mode Banner
   ===================================================== */

.sort-banner {
  background: var(--gp-blue);
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 8px 16px;
  position: sticky;
  top: var(--gp-topbar-h);
  z-index: 150;
  display: none;
}

.sort-banner.active {
  display: block;
}

/* =====================================================
   Upload Drop Zone
   ===================================================== */

.upload-zone {
  border: 2px dashed var(--gp-border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--gp-bg);
  margin-top: 24px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--gp-blue);
  background: var(--gp-active-bg);
}

.upload-zone .material-icons {
  font-size: 56px;
  color: var(--gp-border);
  display: block;
  margin-bottom: 12px;
}

.upload-zone-title {
  font-size: 16px;
  color: var(--gp-text-muted);
  margin-bottom: 4px;
}

.upload-zone-sub {
  font-size: 12px;
  color: var(--gp-text-light);
}

.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 115, 232, 0.12);
  border: 4px solid var(--gp-blue);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.active {
  display: flex;
}

.drop-overlay-inner {
  background: #fff;
  border-radius: 16px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.drop-overlay-inner .material-icons {
  font-size: 64px;
  color: var(--gp-blue);
}

.drop-overlay-text {
  font-size: 20px;
  color: var(--gp-text);
  margin-top: 8px;
}

/* =====================================================
   Photo Grid
   ===================================================== */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 3px;
  padding-top: 8px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--gp-bg);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
  display: block;
}

.photo-item:hover img {
  transform: scale(1.03);
}

/* Overlay (caption + action buttons) */
.photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, transparent 45%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px;
}

.photo-item:hover .photo-overlay {
  opacity: 1;
}

.photo-caption-preview {
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Action buttons (top-right on hover) */
.photo-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.photo-item:hover .photo-actions {
  opacity: 1;
}

.photo-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gp-text-muted);
  transition: background 0.15s, color 0.15s;
  backdrop-filter: blur(4px);
}

.photo-action-btn:hover {
  background: #fff;
  color: var(--gp-blue);
}

.photo-action-btn.danger:hover {
  color: #d93025;
}

.photo-action-btn .material-icons {
  font-size: 15px;
}

/* Caption editor (inline) */
.caption-editor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 8px;
  display: none;
  z-index: 20;
}

.caption-editor.active {
  display: block;
}

.caption-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 12px;
  outline: none;
  padding: 2px 0;
  font-family: inherit;
}

.caption-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Sort mode */
.photo-grid.sort-mode .photo-item {
  cursor: grab;
}

.photo-grid.sort-mode .photo-item:active {
  cursor: grabbing;
}

.photo-grid.sort-mode .photo-overlay,
.photo-grid.sort-mode .photo-actions,
.photo-grid.sort-mode .caption-editor {
  display: none !important;
  opacity: 0 !important;
}

.photo-grid.sort-mode .photo-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.08);
}

.sortable-ghost {
  opacity: 0.45;
  outline: 2px solid var(--gp-blue);
}

/* =====================================================
   Lightbox
   ===================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  background: #111;
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.lightbox.open {
  display: flex;
}

.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
  z-index: 10;
}

.lb-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lb-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.lb-icon-btn .material-icons {
  font-size: 24px;
}

.lb-counter {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  padding: 0 4px;
}

.lightbox-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  transition: opacity 0.15s ease;
  user-select: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 5;
}

.lb-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lb-nav .material-icons {
  font-size: 28px;
}

.lb-nav.prev {
  left: 12px;
}

.lb-nav.next {
  right: 12px;
}

.lb-nav:disabled,
.lb-nav[data-hidden] {
  visibility: hidden;
}

.lightbox-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 24px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
  z-index: 10;
}

.lb-caption {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  max-width: 680px;
}

/* =====================================================
   Upload Progress Panel
   ===================================================== */

.upload-progress-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 320px;
  background: var(--gp-surface);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 800;
  overflow: hidden;
}

.upload-progress-header {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  background: var(--gp-bg);
  border-bottom: 1px solid var(--gp-border);
}

.upload-progress-list {
  max-height: 260px;
  overflow-y: auto;
}

.upload-progress-item {
  padding: 10px 16px;
  border-bottom: 1px solid #f5f5f5;
}

.upload-progress-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  color: var(--gp-text);
}

.upload-progress-name.done {
  color: #1e8e3e;
}

.upload-progress-name.error {
  color: #d93025;
}

.upload-bar-track {
  height: 3px;
  background: var(--gp-border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-bar {
  height: 100%;
  background: var(--gp-blue);
  border-radius: 2px;
  transition: width 0.1s linear;
  width: 0%;
}

/* =====================================================
   Modal
   ===================================================== */

.gp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
}

.gp-modal-backdrop.open {
  display: flex;
}

.gp-modal {
  background: var(--gp-surface);
  border-radius: 8px;
  padding: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.gp-modal-title {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--gp-text);
}

.gp-field {
  margin-bottom: 20px;
}

.gp-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--gp-text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.gp-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--gp-border);
  padding: 8px 0;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  color: var(--gp-text);
  background: transparent;
}

.gp-input:focus {
  border-bottom-color: var(--gp-blue);
}

.gp-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* =====================================================
   Toast
   ===================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: 4px;
  font-size: 14px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* =====================================================
   Empty State
   ===================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.empty-state .material-icons {
  font-size: 80px;
  color: var(--gp-border);
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 400;
  color: #3c4043;
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 14px;
  color: var(--gp-text-muted);
  max-width: 380px;
  margin-bottom: 24px;
}

/* =====================================================
   Login Page
   ===================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gp-bg);
}

.login-card {
  background: var(--gp-surface);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 400px;
  max-width: calc(100vw - 32px);
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}

.login-title {
  font-size: 24px;
  font-weight: 400;
  color: var(--gp-text);
  text-align: center;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 14px;
  color: var(--gp-text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.login-error {
  background: #fce8e6;
  color: #c5221f;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* =====================================================
   Utilities
   ===================================================== */

.spacer { flex: 1; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 768px) {
  .gp-sidebar {
    display: none;
  }

  .gp-main {
    margin-left: 0;
    padding: 0 12px 48px;
  }

  .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

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

  .album-header-top {
    flex-direction: column;
    gap: 12px;
  }

  .album-actions {
    width: 100%;
  }

  .lb-nav {
    width: 40px;
    height: 40px;
  }

  .lb-nav.prev { left: 4px; }
  .lb-nav.next { right: 4px; }
}

@media (max-width: 480px) {
  .album-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
