body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Poppins", sans-serif;
  background: #eaf4ff;
  color: #003366;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.page {
  display: none;
  height: 100%;
}

.page.active {
  display: block;
}

/* Add overlay for better readability */
.page {
    position: relative;
    min-height: 100vh;
}

/* LOGIN PAGE */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.title {
  font-size: 2em;
  margin-bottom: 20px;
  color: #004d99;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 300px;
  text-align: center;
}

.login-box input {
  display: block;
  width: 93%;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid #b3d9ff;
  border-radius: 8px;
  font-size: 16px;
  transition: 0.3s;
}

.login-box input:focus {
  border-color: #007bff;
  outline: none;
}

.login-box button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #007bff;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: 0.3s;
}

.login-box button:hover {
  background: #005fcc;
}

.error-msg {
  color: red;
  font-size: 0.9em;
  margin-top: 10px;
}

/* GALLERY PAGE */
header {
  background: #007bff;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
}

header h2 {
  margin: 0;
}

header button {
  background: white;
  color: #007bff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
}

header button:hover {
  background: #cce5ff;
}

.grid-container {
    width: 97%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    padding: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 150, 255, 0.5) rgba(0, 0, 0, 0.1);
}

.grid-container::-webkit-scrollbar {
    width: 8px;
}

.grid-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.grid-container::-webkit-scrollbar-thumb {
    background: rgba(0, 150, 255, 0.5);
    border-radius: 4px;
}

.video-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

/* Responsive breakpoints */
@media (max-width: 1600px) {
    .grid-container {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 900px) {
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.click-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 2;
}

.thumb-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, #1a1a1a, #333);
}

.play-icon {
  color: white;
  font-size: 48px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.video-thumb:hover .play-icon {
  opacity: 1;
}

.video-thumb p {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0, 0, 32, 0.9));
  color: white;
  text-align: center;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Optional hover effect */
.video-thumb:hover p {
  background: rgba(0,0,0,0.8);
}

/* MODAL PLAYER */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9) url('bg.png');
  background-blend-mode: multiply;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.modal-content {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#videoPlayer {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(rgba(0,0,0,0.7), transparent);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    z-index: 1002;
}

.video-title {
    display: none;  /* Hidden by default */
    position: absolute;
    top: 20px;
    left: 150px;
    color: white;
    font-size: 1.2em;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 32, 0.8);
    background: linear-gradient(90deg, rgba(0, 0, 32, 0.8), transparent);
    padding: 8px 20px;
    border-radius: 4px;
    z-index: 1002;
}

/* Show title only in single video mode */
.modal[data-mode="1"] .video-title {
    display: block;
}

#closeModal {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.7);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  z-index: 1001;
}

#closeModal:hover {
  background: rgba(255,0,0,0.7);
}

.volume-controls {
    position: absolute;
    top: 60px;
    left: 20px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 5px;
    border-radius: 30px;
    z-index: 1002;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Show controls when active */
.volume-controls.show {
    opacity: 1;
    pointer-events: auto;
}

.volume-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#volumeSlider {
    width: 0;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.volume-row:hover #volumeSlider {
    width: 100px;
    opacity: 1;
}

#muteBtn, #loopBtn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.9;
    min-width: 45px;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loopBtn {
    margin-left: 10px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 32px;  /* Larger size for better visibility */
    font-weight: normal;
}

#loopBtn.active-control {
    color: #007bff;
    opacity: 1;
    text-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
    background: rgba(0, 123, 255, 0.2);
    border-radius: 50%;
}

.preview-controls {
    display: flex;
    gap: 10px;
}

.preview-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preview-btn.active {
    background: white;
    color: #007bff;
}

.grid-container[data-layout="1"] {
    grid-template-columns: repeat(1, 1fr);
    max-width: 800px;
}

.grid-container[data-layout="4"] {
    grid-template-columns: repeat(2, 1fr);
    max-width: 1200px;
}

.grid-container[data-layout="6"] {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1600px;
}

.multi-video-container {
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    display: grid;
    gap: 20px;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    padding-top: 36px;
}

.video-wrapper video {
    width: 100%;
    height: calc(100% - 36px);
    object-fit: contain;
}

.multi-video-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    color: white;
    font-size: 14px;
    padding: 8px;
    background: rgba(0, 0, 32, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.video-wrapper.loading .multi-video-title {
    opacity: 0;
}
