/* === BASE STYLES === */
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: url('./image/mybackground.jpg') no-repeat center center fixed;
  background-size: cover;
  color: #333;
  transition: background 0.3s ease, color 0.3s ease;
}

body.dark {
  background: url('./image/dark-background.jpg') no-repeat center center fixed;
  background-size: cover;
  color: #f1f1f1;
}

/* === RAINBOW TITLE EFFECT === */
.rainbow-text {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(
    -45deg,
    red,
    orange,
    yellow,
    green,
    cyan,
    blue,
    violet,
    red
  );
  background-size: 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow 8s linear infinite;
}

@keyframes rainbow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

/* === HEADER === */
.site-header {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 9999;
  padding: 10px 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.site-title {
  font-size: 24px;
  font-weight: bold;
  color: #222;
  margin: 0;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  text-decoration: none;
  font-weight: 500;
  color: #444;
  transition: color 0.3s, border-bottom 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #007bff;
  border-bottom: 2px solid #007bff;
  padding-bottom: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* === SEARCH BAR === */
.search-bar {
  display: flex;
  align-items: center;
  background: #f1f1f1;
  border-radius: 6px;
  padding: 4px 8px;
  gap: 6px;
  flex: 1;
}

.search-bar input[type="text"] {
  border: none;
  background: transparent;
  padding: 8px;
  font-size: 14px;
  outline: none;
  width: 180px;
  flex: 1;
}

.search-bar button {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
}

/* === THEME TOGGLE === */
#themeToggle {
  background: #007bff;
  color: white;
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
}

#themeToggle:hover {
  background: #0056b3;
}

/* === MAIN CONTENT === */
main {
  padding: 30px 20px;
  max-width: 1200px;
  margin: auto;
  position: relative;
  z-index: 1;
}

h2 {
  margin-top: 40px;
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: bold;
  text-align: left;
  text-shadow: 1px 1px 2px white;
}

body.dark h2 {
  text-shadow: 1px 1px 2px black;
}

/* === CARD STYLES === */
.card-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  z-index: 0;
}

.card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  width: 300px;
  padding: 15px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 10px;
}

.card h3 {
  margin: 10px 0 5px;
  font-size: 18px;
}

.card p {
  font-size: 14px;
  color: #555;
}

.card small {
  font-size: 12px;
  color: #999;
}

.card.highlighted {
  outline: 2px solid #007bff;
  background-color: #e6f0ff;
}

/* === PAGINATION === */
.pagination {
  display: flex;
  justify-content: center;
  margin: 10px 0 30px;
  gap: 6px;
}

.pagination button {
  background: #fff;
  border: 1px solid #ccc;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s ease, color 0.2s ease;
}

.pagination button.active {
  background: #007bff;
  color: #fff;
  font-weight: bold;
}

/* === CODE VIEWER === */
.code-container {
  position: relative;
  background: #7b1c1c;
  color: #fff;
  border-radius: 6px;
  padding: 16px;
  overflow: auto;
  font-family: monospace;
  margin: 20px 0;
  z-index: 0;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  color: #333;
  border: none;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s ease;
  z-index: 2;
}

.copy-btn:hover {
  background: #e0e0e0;
}

/* === FIX FOR SCRIPT PAGE STICKY HEADER === */
#script-details {
  padding-top: 100px;
  margin-top: -60px;
  position: relative;
  z-index: 0;
}

/* === FOOTER === */
.site-footer {
  text-align: center;
  padding: 20px 10px;
  font-size: 14px;
  color: #666;
  width: 100%;
}

body.dark .site-footer {
  color: #aaa;
}

/* === DARK MODE === */
body.dark .site-header {
  background: rgba(42, 42, 42, 0.7);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark .nav-links a {
  color: #f1f1f1;
}

body.dark .nav-links a.active {
  color: #66b2ff;
}

body.dark #themeToggle {
  background-color: #66b2ff;
  color: #000;
}

body.dark .card {
  background: rgba(42, 42, 42, 0.9);
  color: #ddd;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

body.dark .card:hover {
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.08);
}

body.dark .card p,
body.dark .card small {
  color: #aaa;
}

body.dark .pagination button {
  background: #333;
  color: #f1f1f1;
  border-color: #555;
}

body.dark .pagination button.active {
  background: #66b2ff;
  color: #000;
}

body.dark .search-bar input[type="text"] {
  background: #2a2a2a;
  color: #f1f1f1;
  border: 1px solid #555;
}

body.dark .search-bar input[type="text"]::placeholder {
  color: #aaa;
}

body.dark .search-bar button {
  background-color: #66b2ff;
  color: #000;
}

body.dark .code-container {
  background: #2a2a2a;
  color: #f1f1f1;
}

body.dark .copy-btn {
  background: #444;
  color: #f1f1f1;
}

body.dark .copy-btn:hover {
  background: #666;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .search-bar {
    width: 100%;
    flex-direction: row;
  }

  .search-bar input[type="text"],
  .search-bar button {
    width: 100%;
  }

  #themeToggle {
    width: 100%;
    padding: 10px;
    font-size: 14px;
  }

  .card {
    width: 95%;
    max-width: 400px;
  }

  h2 {
    font-size: 22px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .site-title {
    font-size: 20px;
  }

  .card {
    width: 100%;
    padding: 12px;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .search-bar input[type="text"],
  .search-bar button {
    width: 100%;
  }

  #themeToggle {
    margin-top: 6px;
  }
}
