/* ==================== PHOTO LIBRARY - FULL STYLES ==================== */

:root {
  --accent: #3b82f6;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e2937;
  transition: background 0.3s, color 0.3s;
}

body[data-theme="dark"] {
  background: #0f172a;
  color: #e2e8f0;
}

/* ==================== HEADER ==================== */
header {
  background: #1e2937;
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 52px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header h1 {
  margin: 0;
  font-size: 1.35em;
  font-weight: 600;
  color: white;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#stats {
  font-weight: 600;
  font-size: 1.05em;
  color: #cbd5e1;
}

.logout-btn {
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

/* Download Buttons */
.download-btn {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  white-space: nowrap;
}

.download-btn:hover {
  background: #2563eb;
}

/* Hamburger Menu */
.hamburger {
  background: none;
  border: none;
  font-size: 1.8em;
  color: #e2e8f0;
  cursor: pointer;
  padding: 8px;
  display: none;
}

.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 8px;
  position: absolute;
  top: 60px;
  right: 16px;
  background: #1e2937;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  z-index: 150;
  min-width: 160px;
}

/* ==================== ACCORDION - FIXED ==================== */
.folder-group {
  margin: 10px 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

body[data-theme="dark"] .folder-group {
  background: #1e2937;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.folder-header {
  padding: 18px 20px;
  font-size: 1.1em;
  font-weight: 600;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

body[data-theme="dark"] .folder-header {
  background: #334155;
  color: #e2e8f0;
}

.folder-header:hover {
  background: #f1f5f9;
}

body[data-theme="dark"] .folder-header:hover {
  background: #475569;
}

.count {
  opacity: 0.7;
  font-weight: normal;
  font-size: 0.95em;
}

.folder-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s ease;
}

.folder-content.active {
  max-height: none;
}

/* ==================== GALLERY GRID - RESPONSIVE ==================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 16px;
  background: #ffffff;
}

body[data-theme="dark"] .gallery-grid {
  background: #1e2937;
}

.grid-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.grid-item img,
.grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Video Play Icon */
.grid-item.video::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1;
}

.grid-item.video::before {
  content: '▶';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: white;
  z-index: 2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.filename {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: white;
  font-size: 0.8em;
  padding: 12px 8px 8px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== VIEWER ==================== */
#viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.98);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 10px;
}

#viewer-media {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewer-media img,
#viewer-media video {
  max-width: 100%;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Navigation Buttons */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 62px;
  height: 110px;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2010;
  opacity: 0.85;
  transition: all 0.2s;
  user-select: none;
}

.nav-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.9);
}

.prev-btn { left: 12px; }
.next-btn { right: 12px; }

#close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  font-size: 28px;
  border-radius: 50%;
  z-index: 2020;
  cursor: pointer;
}

/* ==================== LOGIN PAGE ==================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}

.login-container {
  background: #1e2937;
  padding: 40px 30px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-container h1 {
  margin: 0 0 8px 0;
  font-size: 2em;
  color: white;
}

.login-container p {
  color: #94a3b8;
  margin-bottom: 30px;
}

/* Password Field with Toggle */
.password-wrapper {
  position: relative;
  margin: 10px 0 20px;
}

.password-wrapper input {
  width: 100%;
  padding: 14px 50px 14px 16px;
  background: #334155;
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1.1em;
  box-sizing: border-box;
}

.toggle-eye {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4em;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

.toggle-eye:hover {
  color: #cbd5e1;
}

.remember {
  text-align: left;
  margin: 15px 0;
  color: #cbd5e1;
  font-size: 0.95em;
}

.remember input[type="checkbox"] {
  accent-color: #3b82f6;
}

.login-container button {
  width: 100%;
  padding: 14px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-container button:hover {
  background: #2563eb;
}

.error {
  color: #f87171;
  margin: 10px 0;
}

/* ==================== DOWNLOAD MODAL ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #1e2937;
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 15px 50px rgba(0,0,0,0.6);
}

.progress-container {
  margin: 20px 0;
}

.progress-bar {
  height: 10px;
  background: #334155;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  width: 0%;
  transition: width 0.4s ease;
}

#progress-text {
  display: block;
  margin-top: 8px;
  font-weight: 600;
  color: #94a3b8;
}

.cancel-btn {
  background: #475569;
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 15px;
}

/* ==================== RESPONSIVE & HAMBURGER ==================== */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 6px;
    padding: 12px;
  }

  .header-right .download-btn,
  .header-right .logout-btn {
    display: none;
  }

  .hamburger {
    display: block;
  }

  .mobile-menu {
    display: none;
    flex-direction: column;
    gap: 8px;
    position: absolute;
    top: 60px;
    right: 16px;
    background: #1e2937;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    z-index: 150;
  }

  .mobile-menu .download-btn,
  .mobile-menu .logout-btn {
    display: block;
    width: 100%;
    text-align: left;
    margin: 4px 0;
  }
}

/* Theme Toggle */
#theme-toggle {
  background: none;
  border: none;
  font-size: 1.6em;
  cursor: pointer;
  padding: 8px;
  color: inherit;
}
/* ==================== PASSWORD TOGGLE - HIGH SPECIFICITY ==================== */
.password-wrapper {
    position: relative;
    margin: 10px 0 20px;
}

.password-wrapper input {
    width: 100%;
    padding: 14px 50px 14px 16px !important;
    background: #334155;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1.1em;
    box-sizing: border-box;
}

/* Override general button styles for the toggle */
.password-wrapper .toggle-eye {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    border: none !important;
    color: #94a3b8;
    font-size: 1.35em;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    z-index: 10;
    width: auto !important;
    height: auto !important;
}

.password-wrapper .toggle-eye:hover {
    color: #cbd5e1;
}