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

html, body {
  min-height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: #fff;
  color: #3d3558;
}

h1, h2, h3 { font-family: 'Quicksand', sans-serif; }

button { cursor: pointer; font-family: inherit; }

/* ===========================
   HOME PAGE
=========================== */
.page-wrap {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: #fff;
}

.bg-watercolor {
  position: absolute;
  inset: 0;
  background-image: url('https://d2xsxph8kpxj0f.cloudfront.net/310519663392424189/H5iSaioCjgbnNDeZvbC7R5/hero-watercolor-bg-4XctfvaiA4BQoe42WqUp8Q.webp');
  background-size: cover;
  background-position: center;
  opacity: 0.55;
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.home-header {
  padding: 2.5rem 1rem 1rem;
  text-align: center;
}

.home-title {
  font-weight: 700;
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: #3d3558;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.home-subtitle {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: #6b6585;
  margin-top: 0.5rem;
}

/* ===========================
   BUBBLE GRID
=========================== */
.bubble-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  align-content: start;
}

.bubble-btn {
  aspect-ratio: 1 / 1;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  outline: none;
  position: relative;
  overflow: hidden;
}

/* Shape variants */
.bubble-btn.shape-circle  { border-radius: 50%; }
.bubble-btn.shape-square  { border-radius: 1rem; aspect-ratio: 1 / 1; }
.bubble-btn.shape-rectangle { border-radius: 1rem; aspect-ratio: 4 / 3; }

/* Triangle uses clip-path */
.bubble-btn.shape-triangle {
  border-radius: 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.bubble-btn:hover  { transform: scale(1.07); }
.bubble-btn:active { transform: scale(0.93); }

.bubble-name {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  text-align: center;
  line-height: 1.25;
  word-break: break-word;
  hyphens: auto;
  padding: 0 0.25rem;
}

/* Triangle name offset so text sits in the lower half */
.bubble-btn.shape-triangle .bubble-name {
  margin-top: 40%;
}

/* ===========================
   ANIMATIONS
=========================== */
@keyframes floatIn {
  from { opacity: 0; transform: translateY(24px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeZoomIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble-float-in { animation: floatIn 0.5s ease-out both; }
.gallery-fade-in { animation: fadeZoomIn 0.35s ease-out both; }
.photo-slide-up  { animation: slideUp 0.4s ease-out both; }

/* ===========================
   FOOTER (shared)
=========================== */
.home-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-text {
  font-size: 0.78rem;
  color: #9b97b0;
}

.teacher-zone-btn {
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  color: #9b97b0;
  background: rgba(155, 151, 176, 0.12);
  border: 1px solid rgba(155, 151, 176, 0.3);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  transition: background 0.2s;
}

.teacher-zone-btn:hover {
  background: rgba(155, 151, 176, 0.22);
}

/* ===========================
   GALLERY PAGE
=========================== */
.gallery-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.gallery-header {
  padding: 1.5rem 1rem 1.25rem;
  border-bottom: 1.5px solid rgba(0,0,0,0.06);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.07);
  color: inherit;
  text-decoration: none;
}

.gallery-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.gallery-title {
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  line-height: 1.1;
}

.gallery-count {
  font-size: 0.9rem;
  opacity: 0.6;
  margin-top: 0.3rem;
}

.teacher-btn {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid rgba(0,0,0,0.15);
  background: rgba(0,0,0,0.06);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}

.teacher-btn.active {
  background: rgba(0,0,0,0.15);
}

/* ===========================
   PHOTO GRID
=========================== */
.photo-grid-wrap {
  flex: 1;
  padding: 1.5rem 1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 700px;
  margin: 0 auto;
}

.photo-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.08);
}

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

.photo-cell:hover img { transform: scale(1.05); }

.delete-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  color: white;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.75rem;
  text-align: center;
  grid-column: 1 / -1;
}

.empty-state p {
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  opacity: 0.6;
}

.empty-state small {
  font-size: 0.9rem;
  opacity: 0.45;
}

/* ===========================
   ADD PHOTO BUTTON
=========================== */
.add-photo-wrap {
  padding: 0.5rem 1rem 1rem;
}

.add-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 1.1rem;
  border-radius: 1rem;
  border: 2px dashed rgba(0,0,0,0.2);
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
  display: flex;
}

.add-photo-btn:hover { transform: scale(1.01); }
.add-photo-btn.disabled { opacity: 0.45; pointer-events: none; cursor: not-allowed; }

.gallery-footer {
  padding: 0.75rem 1rem 1.5rem;
  text-align: center;
}

/* ===========================
   LIGHTBOX
=========================== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  z-index: 101;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 2.8rem;
  height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: white;
  z-index: 101;
}

.lightbox-prev { left: 0.75rem; }
.lightbox-next { right: 0.75rem; }

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

.lightbox-counter {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
}

/* ===========================
   DIALOGS
=========================== */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dialog-box {
  background: white;
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.dialog-title {
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: #3d3558;
  margin-bottom: 0.5rem;
}

.dialog-body {
  font-size: 0.88rem;
  color: #6b6585;
  margin-bottom: 1.25rem;
}

.dialog-input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e2e0ec;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  outline: none;
  margin-bottom: 0.5rem;
  background: #fafafa;
}

.dialog-input:focus { border-color: #a89fc8; }

.dialog-error {
  font-size: 0.82rem;
  color: #ef4444;
  margin-bottom: 0.75rem;
}

.dialog-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.btn-cancel {
  flex: 1;
  padding: 0.7rem;
  border-radius: 0.75rem;
  border: 1.5px solid #e2e0ec;
  background: white;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  color: #6b6585;
}

.btn-confirm {
  flex: 1;
  padding: 0.7rem;
  border-radius: 0.75rem;
  border: none;
  background: #a89fc8;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #3d3558;
  transition: background 0.2s;
}

.btn-confirm:hover { background: #9589bc; }
.btn-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  flex: 1;
  padding: 0.7rem;
  border-radius: 0.75rem;
  border: none;
  background: #ef4444;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
}

.full-width { width: 100%; margin-top: 0.5rem; }

/* ===========================
   ADMIN PAGE
=========================== */
.admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #f5f3ff 0%, #ede9fe 100%);
}

.admin-login-box {
  background: white;
  border-radius: 1.5rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(100,80,180,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.admin-lock { font-size: 3rem; margin-bottom: 0.5rem; }

.admin-login-title {
  font-weight: 700;
  font-size: 1.6rem;
  color: #3d3558;
}

.admin-login-sub {
  font-size: 0.9rem;
  color: #6b6585;
  margin-bottom: 0.75rem;
}

.admin-login-box .dialog-input { margin-top: 0.5rem; }

.back-link {
  font-size: 0.85rem;
  color: #9b97b0;
  text-decoration: none;
  margin-top: 0.75rem;
}

.back-link:hover { text-decoration: underline; }

.admin-panel {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.admin-title {
  font-weight: 700;
  font-size: 1.8rem;
  color: #3d3558;
}

.admin-sub {
  font-size: 0.9rem;
  color: #6b6585;
  margin-top: 0.2rem;
}

.admin-section {
  background: white;
  border: 1.5px solid #ede9fe;
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(100,80,180,0.06);
}

.admin-section-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #3d3558;
  margin-bottom: 1.25rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.setting-label {
  font-weight: 500;
  font-size: 0.95rem;
  color: #3d3558;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shape-group { gap: 0.4rem; }

.btn-toggle {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid #e2e0ec;
  background: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #6b6585;
  transition: all 0.15s;
}

.btn-toggle.active {
  background: #a89fc8;
  border-color: #a89fc8;
  color: #3d3558;
  font-weight: 700;
}

.save-feedback {
  font-size: 0.85rem;
  color: #22c55e;
  margin-top: 0.5rem;
  font-weight: 600;
}

/* Student list */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.student-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  background: #fafafa;
  border: 1px solid #e2e0ec;
}

.student-row-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  color: #3d3558;
}

.student-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: #3d3558;
  outline: none;
}

.btn-small {
  padding: 0.3rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e0ec;
  background: white;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  color: #6b6585;
  transition: background 0.15s;
}

.btn-small:hover { background: #f0eeff; }
.btn-small.danger { color: #ef4444; border-color: #fca5a5; }
.btn-small.danger:hover { background: #fef2f2; }

.add-student-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.add-student-row .dialog-input { margin-bottom: 0; flex: 1; }
.add-student-row .btn-confirm { flex: none; padding: 0.7rem 1.2rem; }

.admin-hint {
  font-size: 0.88rem;
  color: #6b6585;
  margin-bottom: 0.75rem;
}

.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}

.admin-photo-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1.5px solid #e2e0ec;
}

.admin-photo-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.admin-photo-del {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: rgba(239,68,68,0.85);
  border: none;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ===========================
   LOADING SPINNER
=========================== */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: #a89fc8;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 0.75rem;
  grid-column: 1 / -1;
  opacity: 0.6;
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 480px) {
  .bubble-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }

  .admin-header { flex-direction: column; }
  .setting-row { flex-direction: column; align-items: flex-start; }
}
