/* =============================================
   GALLERY PAGE
   ============================================= */

.gallery-dashboard {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

/* ---- Page header ---- */
.gallery-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.gallery-page-title {
  font-size: 22px;
  font-weight: 700;
  color: #BB5D4C;
  letter-spacing: -0.01em;
}

.gallery-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-recalibrate-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: #f0e9de;
  border: 1px solid #d4c5b0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #7a6855;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}
.gallery-recalibrate-btn:hover { background: #e2d8cb; }
.gallery-recalibrate-btn.hidden { display: none; }

.gallery-new-canvas-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #BB5D4C;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}
.gallery-new-canvas-btn:hover { background: #99473A; }

/* ---- Day cards container ---- */
.day-cards-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Day card ---- */
.gallery-day-card {
  background: #fffdf9;
  border: 1px solid #e8ddd0;
  border-radius: 16px;
  overflow: hidden;
}

.gallery-day-card.is-today {
  border-color: #BB5D4C;
  border-width: 1.5px;
}

.day-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 10px;
  gap: 10px;
}

.day-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #4a3728;
  min-width: 0;
}

.day-today-chip {
  display: inline-block;
  padding: 2px 8px;
  background: #BB5D4C;
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.day-future-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #e8ddd0;
  color: #7a6855;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.day-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #f0e9de;
  border: 1px solid #d4c5b0;
  border-radius: 8px;
  cursor: pointer;
  color: #7a6855;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.day-add-btn:hover { background: #BB5D4C; color: #fff; border-color: #BB5D4C; }

.day-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.day-header-count {
  font-size: 12px;
  color: #a08060;
  font-weight: 500;
  margin-left: 4px;
}

.day-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #f0e9de;
  border: 1px solid #d4c5b0;
  border-radius: 8px;
  cursor: pointer;
  color: #7a6855;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.day-icon-btn:hover { background: #e2d8cb; }
.day-icon-btn--dark {
  background: #2c1f17;
  color: #f0e6db;
  border-color: #2c1f17;
}
.day-icon-btn--dark:hover { background: #1a120d; border-color: #1a120d; }
.day-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Photo strip ---- */
.day-photo-strip-wrap {
  position: relative;
}
.day-photo-strip-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: calc(100% - 6px); /* leave room for scrollbar */
  background: linear-gradient(to right, transparent, #fff9f4);
  pointer-events: none;
  border-radius: 0 12px 0 0;
}
.day-photo-strip {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  min-height: 112px;
  align-items: flex-start;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #b8a590 #ede5d8;
}
.day-photo-strip::-webkit-scrollbar { height: 6px; }
.day-photo-strip::-webkit-scrollbar-track { background: #ede5d8; border-radius: 3px; }
.day-photo-strip::-webkit-scrollbar-thumb { background: #b8a590; border-radius: 3px; }

.day-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 90px;
  font-size: 13px;
  color: #b5a090;
  font-style: italic;
  border: 2px dashed #e2d8cb;
  border-radius: 10px;
  padding: 16px;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.day-empty-hint:hover { border-color: #BB5D4C; color: #BB5D4C; }

/* ---- Photo card ---- */
.gallery-photo-card {
  flex-shrink: 0;
  width: 80px;
  position: relative;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  border-radius: 8px;
  overflow: hidden;
  background: #f0e9de;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.gallery-photo-card:active { cursor: grabbing; }

.gallery-photo-card.is-dragging {
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  opacity: 0.95;
  cursor: grabbing;
  transition: box-shadow 0.1s;
}

.gallery-photo-card.shift-right { transform: translateX(88px); transition: transform 0.15s ease; }
.gallery-photo-card.shift-left  { transform: translateX(-88px); transition: transform 0.15s ease; }

.photo-thumb {
  width: 80px;
  height: 100px;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.photo-card-num {
  position: absolute;
  bottom: 4px;
  left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  pointer-events: none;
}

.photo-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.0);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 4px;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.gallery-photo-card.overlay-visible .photo-card-overlay {
  opacity: 1;
  background: rgba(0,0,0,0.35);
}

.photo-delete-btn,
.photo-copy-single-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1;
  transition: opacity 0.12s;
}

.photo-delete-btn {
  background: rgba(192,57,43,0.9);
  color: #fff;
  font-size: 14px;
  width: 22px;
  height: 22px;
  padding: 0;
}

.photo-copy-single-btn {
  background: rgba(255,255,255,0.88);
  color: #4a3728;
  font-size: 10px;
}

/* ---- Day card footer ---- */
.day-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 14px;
  gap: 10px;
  flex-wrap: wrap;
}

.day-photo-count {
  font-size: 12px;
  color: #a08060;
  font-weight: 500;
}

.day-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: #2c1f17;
  color: #f0e6db;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}
.day-download-btn:hover { background: #1a120d; }
.day-download-btn:disabled { background: #c9b8aa; cursor: not-allowed; }

.day-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: #f0e9de;
  border: 1px solid #d4c5b0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #7a6855;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}
.day-copy-btn:hover { background: #e2d8cb; }

/* =============================================
   MODALS (shared)
   ============================================= */

.gallery-modal {
  position: fixed;
  inset: 0;
  background: rgba(44,31,23,0.72);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.gallery-modal.hidden { display: none; }

.gallery-modal-inner {
  background: #fffdf9;
  border-radius: 18px;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

/* ---- Calibration modal ---- */
.calibration-inner {
  max-width: 520px;
  padding: 20px 16px;
}

.calibration-header {
  margin-bottom: 14px;
}

.calibration-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c1f17;
  margin-bottom: 5px;
}

.calibration-subtitle {
  font-size: 13px;
  color: #7a6855;
  line-height: 1.5;
}

.calibration-img-wrap {
  position: relative;
  width: 100%;
  max-height: 60vh;
  overflow: hidden;
  border-radius: 10px;
  background: #1a1410;
  margin-bottom: 16px;
  line-height: 0;
  user-select: none;
  -webkit-user-select: none;
}

.calibration-img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Darkener overlays */
.crop-dark {
  position: absolute;
  background: rgba(0,0,0,0.62);
  pointer-events: none;
}

/* Crop rectangle */
.crop-rect {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
  box-sizing: border-box;
  cursor: move;
  touch-action: none;
}

/* Corner handles */
.crop-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  background: #fff;
  border: 2px solid #4a3728;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  touch-action: none;
  cursor: pointer;
}
.crop-handle.tl { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.tr { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.bl { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.br { bottom: -6px; right: -6px; cursor: se-resize; }

/* Edge handles */
.crop-edge {
  position: absolute;
  background: rgba(255,255,255,0.75);
  border-radius: 3px;
  touch-action: none;
}
.crop-edge.t, .crop-edge.b { left: 50%; transform: translateX(-50%); width: 40px; height: 6px; cursor: n-resize; }
.crop-edge.l, .crop-edge.r { top: 50%; transform: translateY(-50%); width: 6px; height: 40px; cursor: e-resize; }
.crop-edge.t { top: -4px; }
.crop-edge.b { bottom: -4px; }
.crop-edge.l { left: -4px; }
.crop-edge.r { right: -4px; }

.calibration-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calibration-save-btn {
  width: 100%;
  padding: 13px;
  background: #BB5D4C;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.calibration-save-btn:hover { background: #99473A; }

.calibration-skip-btn {
  width: 100%;
  padding: 11px;
  background: transparent;
  color: #a08060;
  border: 1px solid #d4c5b0;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.calibration-skip-btn:hover { background: #f0e9de; }

/* ---- New canvas modal ---- */
.new-canvas-inner {
  max-width: 360px;
}
.new-canvas-title {
  font-size: 18px;
  font-weight: 700;
  color: #2c1f17;
  margin-bottom: 5px;
}
.new-canvas-subtitle {
  font-size: 13px;
  color: #7a6855;
  margin-bottom: 16px;
}
.new-canvas-date-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #a08060;
  border-radius: 10px;
  background: #fff;
  color: #4a3728;
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
  margin-bottom: 16px;
}
.new-canvas-date-input:focus { outline: none; border-color: #BB5D4C; }
.new-canvas-actions {
  display: flex;
  gap: 10px;
}
.new-canvas-confirm-btn {
  flex: 1;
  padding: 11px;
  background: #BB5D4C;
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.new-canvas-confirm-btn:hover { background: #99473A; }
.new-canvas-cancel-btn {
  flex: 1;
  padding: 11px;
  background: #f0e9de;
  color: #7a6855;
  border: 1px solid #d4c5b0;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.new-canvas-cancel-btn:hover { background: #e2d8cb; }

/* Mobile tweaks */
@media (max-width: 480px) {
  .gallery-photo-card { width: 76px; }
  .photo-thumb { width: 76px; height: 95px; }
  .gallery-page-header { flex-wrap: wrap; }
}
