/* ===== Global Styles ===== */
:root {
  --theme-color: #0d6efd; /* fallback, overridden dynamically */
}

/* Sticky footer layout */
html, body {
  height: 100%;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
}
.footer {
  margin-top: auto;
}

body {
  background-color: #f8f9fa;
  font-family: 'Segoe UI', sans-serif;
  padding-top: 70px;
}

body.no-navbar {
  height: 100vh;
  padding-top: 0 !important;
  margin: 0 !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== Smooth Theme Transition ===== */
body,
body.dark-mode {
  transition: background-color 0.6s ease,
              color 0.6s ease,
              background 0.6s ease;
}

.card, .generate-card,
.dashboard-card, .settings-card, .trash-card,
.image-card, #lightboxModal .modal-content {
  transition: background 0.6s ease,
              color 0.6s ease,
              box-shadow 0.6s ease,
              border 0.6s ease;
}

/* ===== Dark Mode Parallax Background ===== */
body.dark-mode {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  color: #e0e0e0 !important;
  background-size: 200% 200%;
  animation: parallaxShift 60s ease-in-out infinite alternate;
}
@keyframes parallaxShift {
  from { background-position: 0% 0%; }
  to   { background-position: 100% 100%; }
}

/* ===== Glassmorphism for UI in Dark Mode ===== */
body.dark-mode .card,
body.dark-mode .generate-card,
body.dark-mode .dashboard-card,
body.dark-mode .settings-card,
body.dark-mode .trash-card {
  background: rgba(30, 30, 47, 0.65) !important;
  color: #f1f1f1 !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  backdrop-filter: blur(12px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(150%) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* Dark mode inputs */
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode input[type="url"],
body.dark-mode input[type="search"],
body.dark-mode textarea,
body.dark-mode select {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
}
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: rgba(255,255,255,0.5) !important;
}
body.dark-mode .navbar,
body.dark-mode .footer {
  background: #0d0d1a !important;
  border-color: #222 !important;
}

/* ===== Navbar Enhancements ===== */
.navbar .nav-link {
  position: relative;
  padding: 8px 12px;
  font-weight: 500;
  transition: color 0.2s;
}
.navbar .nav-link.active,
.navbar .nav-link:hover {
  color: var(--theme-color) !important;
}
.navbar .nav-link.active::after,
.navbar .nav-link:hover::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--theme-color);
  border-radius: 2px;
}

/* ===== Themed Buttons ===== */
.btn-primary {
  background-color: var(--theme-color) !important;
  border-color: var(--theme-color) !important;
  color: #fff !important;
  font-weight: 600;
  border-radius: 6px;
  transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: color-mix(in srgb, var(--theme-color) 85%, black) !important;
  border-color: color-mix(in srgb, var(--theme-color) 85%, black) !important;
  transform: translateY(-1px);
}
.btn-primary:active {
  background-color: color-mix(in srgb, var(--theme-color) 70%, black) !important;
  border-color: color-mix(in srgb, var(--theme-color) 70%, black) !important;
  transform: translateY(0);
}
.btn-outline-primary {
  color: var(--theme-color) !important;
  border-color: var(--theme-color) !important;
}
.btn-outline-primary:hover {
  background-color: var(--theme-color) !important;
  color: #fff !important;
}

/* ===== Footer ===== */
.footer .nav-link { font-size: 14px; color: #ddd !important; transition: color 0.2s; }
.footer .nav-link:hover { color: var(--theme-color) !important; }
.footer { border-top: 1px solid rgba(255,255,255,0.1); }

/* ===== Auth Pages ===== */
.auth-wrapper {
  height: 100vh;
  width: 100%;
  margin: 0;
  padding: 0;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
}
.auth-wrapper .card { border-radius:12px; background:#fff; }

/* ===== Gallery Cards ===== */
.image-card {
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.image-card img { width:100%; height:auto; display:block; }
.image-card:hover { transform: scale(1.02); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.image-card .card-footer,
.image-card .card-body {
  background: #fff;
  padding: 10px;
  font-size: 14px;
  color: #333;
}
body.dark-mode .image-card {
  background: rgba(40,40,60,0.55) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  backdrop-filter: blur(10px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(10px) saturate(140%) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
body.dark-mode .image-card .card-footer,
body.dark-mode .image-card .card-body {
  background: rgba(30,30,47,0.5) !important;
  color: #f1f1f1 !important;
  border-top: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(8px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(8px) saturate(150%) !important;
}

/* ===== Lightbox Modal ===== */
#lightboxModal .modal-content { background:#000; border-radius:12px; overflow:hidden; border:none; }
body.dark-mode #lightboxModal .modal-content {
  background: rgba(20,20,35,0.7) !important;
  backdrop-filter: blur(16px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(160%) !important;
  border:1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}
body.dark-mode #lightboxModal img { border-radius:8px; box-shadow:0 6px 20px rgba(0,0,0,0.5); }
body.dark-mode #lightboxModal p { color:#f1f1f1 !important; }
body.dark-mode #lightboxModal button { background: rgba(255,255,255,0.15) !important; color:#fff !important; border:1px solid rgba(255,255,255,0.2) !important; backdrop-filter: blur(6px) !important; }
body.dark-mode #lightboxModal button:hover { background: rgba(255,255,255,0.25) !important; }

/* ===== Floating Theme Toggle ===== */
#themeToggle { transition: all 0.3s ease-in-out; }
body.no-navbar #themeToggle {
  width:44px; height:44px; border-radius:50%;
  background: rgba(30,30,47,0.7);
  border:1px solid rgba(255,255,255,0.15);
  color:#fff; font-size:18px;
  display:flex; align-items:center; justify-content:center;
  backdrop-filter: blur(10px) saturate(150%); -webkit-backdrop-filter: blur(10px) saturate(150%);
  box-shadow:0 4px 15px rgba(0,0,0,0.4);
}
body.no-navbar #themeToggle:hover { background: var(--theme-color); transform: scale(1.05); box-shadow:0 6px 20px rgba(13,110,253,0.6); }
.navbar #themeToggle { padding:6px 12px; border-radius:6px; transition: all 0.3s ease-in-out; background: rgba(255,255,255,0.1); color:#fff; border:1px solid rgba(255,255,255,0.2); }
.navbar #themeToggle:hover { background: var(--theme-color); box-shadow:0 4px 12px rgba(13,110,253,0.5); transform: translateY(-2px); }
body.dark-mode .navbar #themeToggle { background: rgba(30,30,47,0.6); border:1px solid rgba(255,255,255,0.15); backdrop-filter: blur(10px) saturate(150%); -webkit-backdrop-filter: blur(10px) saturate(150%); }

/* ===== Theme Icon Animation ===== */
#themeIcon { transition: transform 0.4s ease, opacity 0.3s ease; }
#themeIcon.animate { transform: rotate(360deg) scale(1.3); opacity:0.8; }

/* ===== Cinematic Fade Overlay ===== */
.theme-fade-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  pointer-events: none; opacity:0; z-index:9999;
  transition: opacity 0.4s ease;
}
.theme-fade-overlay.light-flash { background: rgba(255,193,7,0.5); }
.theme-fade-overlay.dark-flash  { background: var(--theme-color); }
.theme-fade-overlay.active { opacity:1; }

/* ===== Particle Background ===== */
#particle-background { position: fixed; top:0; left:0; width:100%; height:100%; z-index:-1; pointer-events:none; overflow:hidden; }
.particle { position:absolute; width:5px; height:5px; border-radius:50%; animation: floatParticle linear infinite; opacity:0.8; }
@keyframes floatParticle {
  from { transform: translateY(100vh) translateX(0) scale(1); opacity:1; }
  to   { transform: translateY(-10vh) translateX(var(--drift, 30px)) scale(0.5); opacity:0; }
}

/* ===== Shooting Stars ===== */
.shooting-star {
  position: absolute;
  width: 140px;
  height: 2px;
  opacity: 0;
  border-radius: 2px;
  animation-duration: 2s;
  animation-timing-function: ease;
  animation-fill-mode: forwards;
}
@keyframes shootStar {
  0% { opacity:0; transform: translateX(0) translateY(0) rotate(315deg) scaleX(0.3); }
  10% { opacity:1; }
  50% { opacity:1; transform: translateX(-400px) translateY(400px) rotate(315deg) scaleX(1); }
  100% { opacity:0; transform: translateX(-600px) translateY(600px) rotate(315deg) scaleX(0.2); }
}
@keyframes shootStarReverse {
  0% { opacity:0; transform: translateX(0) translateY(0) rotate(135deg) scaleX(0.3); }
  10% { opacity:1; }
  50% { opacity:1; transform: translateX(400px) translateY(400px) rotate(135deg) scaleX(1); }
  100% { opacity:0; transform: translateX(600px) translateY(600px) rotate(135deg) scaleX(0.2); }
}

/* Dark mode toggle switch fix */
body.dark-mode .form-check-input[type="checkbox"] {
  width: 2.5em; height: 1.3em; border-radius: 2em;
  background-color: #444; border: 1px solid #666;
  appearance: none; -webkit-appearance: none;
  position: relative; cursor: pointer; transition: all 0.3s ease;
}
body.dark-mode .form-check-input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 0.9em; height: 0.9em; border-radius: 50%; background: #fff;
  transition: transform 0.3s ease;
}
body.dark-mode .form-check-input:checked {
  background-color: var(--theme-color) !important;
  border-color: var(--theme-color) !important;
}
body.dark-mode .form-check-input:checked::before {
  transform: translateX(1.2em);
}

/* Sticky sidebar for settings */
.settings-sidebar { position: sticky; top: 80px; z-index: 100; }

/* ===== Placeholder for missing images ===== */
img.no-image {
  background: #e0e0e0 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='150'><rect width='100%' height='100%' fill='%23e0e0e0'/><text x='50%' y='50%' font-size='16' font-family='Arial' fill='%23999' text-anchor='middle' dominant-baseline='middle'>Image Not Available</text></svg>") center center no-repeat;
  background-size: contain; object-fit: contain;
}

/* ===== Navbar Logo & Title ===== */
.navbar {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  min-height: 50px;
}
.site-logo {
  height: 40px; max-height: 40px; width: auto;
  transition: transform 0.25s ease, filter 0.25s ease, box-shadow 0.25s ease;
}
.site-logo:hover {
  transform: scale(1.08); filter: brightness(1.1);
  box-shadow: 0 0 12px var(--theme-color);
}

/* Neon Gradient Site Title */
.navbar-brand .site-title {
  font-weight: 700;
  font-size: 1.4rem;
  background: linear-gradient(90deg, var(--theme-color), #00e0ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% auto;
  animation: neonShift 4s linear infinite;
  text-shadow: 0 0 8px var(--theme-color), 0 0 16px rgba(123,47,247,0.4);
  transition: text-shadow 0.3s ease, transform 0.2s ease;
}
.navbar-brand .site-title:hover {
  text-shadow: 0 0 12px #00e0ff, 0 0 24px rgba(123,47,247,0.7);
  transform: scale(1.05);
}

/* ===== Neon Active NavLink ===== */
.navbar .nav-link.active {
  color: var(--theme-color, #00f0ff) !important;
  text-shadow: 0 0 6px var(--theme-color, #00f0ff),
               0 0 12px var(--theme-color, #00f0ff);
  font-weight: 600;
  position: relative;
}
.navbar .nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 15%;
  width: 70%;
  height: 3px;
  background: var(--theme-color, #00f0ff);
  border-radius: 4px;
  box-shadow: 0 0 6px var(--theme-color, #00f0ff),
              0 0 12px var(--theme-color, #00f0ff),
              0 0 20px var(--theme-color, #00f0ff);
  animation: neonPulse 1.5s infinite alternate;
}

/* ===== Neon NavLink (Active + Hover) ===== */
.navbar .nav-link.active,
.navbar .nav-link:hover {
  color: var(--theme-color, #00f0ff) !important;
  text-shadow: 0 0 6px var(--theme-color, #00f0ff),
               0 0 12px var(--theme-color, #00f0ff);
  font-weight: 600;
  position: relative;
}
.navbar .nav-link.active::after,
.navbar .nav-link:hover::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 15%;
  width: 70%;
  height: 3px;
  background: var(--theme-color, #00f0ff);
  border-radius: 4px;
  box-shadow: 0 0 6px var(--theme-color, #00f0ff),
              0 0 12px var(--theme-color, #00f0ff),
              0 0 20px var(--theme-color, #00f0ff);
  animation: neonPulse 1.5s infinite alternate;
}
@keyframes neonPulse {
  from { opacity: 0.6; transform: scaleX(0.95); }
  to   { opacity: 1;   transform: scaleX(1.05); }
}
@keyframes neonShift {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.navbar-brand, .navbar-brand img, .navbar-brand .site-title { cursor: pointer; }

@media (min-width: 992px) {
  .site-logo { height: 50px; max-height: 50px; }
}

/* ===== Shrinking Navbar on Scroll ===== */
.navbar.shrink {
  padding-top: 0.15rem; padding-bottom: 0.15rem; min-height: 40px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.navbar.shrink .site-logo {
  height: 30px; max-height: 30px; transition: all 0.3s ease;
}
@media (min-width: 992px) {
  .navbar.shrink .site-logo { height: 40px; max-height: 40px; }
}
