:root {
  --bg-color: #f0f4f8;
  --container-bg-color: #ffffff;
  --text-color: #4e73df;
  --grid-border: rgba(78, 115, 223, 0.1);
  --header-bg: #4e73df;
  --header-text: white;
}

[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --container-bg-color: #151313;
  --text-color: #8b9eff;
  --grid-border: rgba(139, 158, 255, 0.1);
  --header-bg: #2d2d2d;
  --header-text: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.background-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background-color: var(--bg-color);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, 2cm);
  grid-auto-rows: 2cm;
  width: 100%;
  height: 100%;
  gap: 2px;
}

.grid-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  z-index: -1;
}

.grid-item {
  width: 2cm;
  height: 2cm;
  background-color: transparent;
  border: 1px solid var(--grid-border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.grid-item:hover {
  background-color: var(--text-color) !important;
  box-shadow: 0 0 20px var(--text-color);
  transform: scale(1.05);
  z-index: 1;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: transparent;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 100vh;
  padding: 0 20px;
  position: relative;
  transition: all 0.3s ease;
}

header {
  background-color: var(--header-bg);
  color: var(--header-text);
  width: 100%;
  padding: 15px 20px;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 20px;
  margin-top: 20px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

header nav h1 {
  font-size: 28px;
  font-weight: 600;
}

.theme-switch {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  background: #9ab1f6;
  color: var(--header-text);
  border: 2px solid var(--text-color);
  padding: 12px;
  border-radius: 50%;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.theme-switch:hover {
  transform: translateY(-50%) translateY(-2px);
}

.theme-switch:active {
  transform: translateY(-50%) translateY(0);
}

.theme-switch img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin: 2rem 0;
  width: 100%;
  flex-grow: 1;
}

.section {
  background-color: var(--container-bg-color);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  width: 45%;
  min-height: 400px;
  min-width: 350px;
  padding: 2rem;
  margin: 1rem;
  transition: all 0.2s ease;
}

.section:hover {
  border-color: #4e73df;
}

.title {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f1f1f1;
}

.title h2 {
  font-size: 1.5rem;
  color: #4e73df;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

.links a {
  text-decoration: none;
  color: #4e73df;
  font-size: 1.1rem;
  background-color: var(--container-bg-color);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  transition: all 0.2s ease;
}

.links a:hover {
  background-color: #4e73df;
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.works {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.works a {
  text-decoration: none;
  color: #4e73df;
  font-size: 18px;
  background-color: #ffffff;
  padding: 10px 0;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: 0.3s ease;
}

.works a:hover {
  background-color: #4e73df;
  color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.footer {
  background-color: var(--header-bg);
  color: var(--header-text);
  text-align: center;
  padding: 15px;
  border-radius: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.footer a:hover {
  background-color: var(--header-bg);
  color: var(--header-text);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.footer p {
  margin: 5px 0;
}

.footer strong {
  font-size: 18px;
}

/* Media Queries pour responsive */
@media screen and (max-width: 1200px) {
  .container {
    gap: 15px;
  }

  .section {
    width: 45%;
    min-width: 320px;
    padding: 1.5rem;
  }
}

@media screen and (max-width: 992px) {
  .section {
    width: 80%;
    min-width: 300px;
  }

  .container {
    flex-direction: column;
    align-items: center;
  }

  header nav h1 {
    font-size: 24px;
  }
}

@media screen and (max-width: 768px) {
  body {
    padding: 0 15px;
  }

  header {
    padding: 15px;
    margin: 15px 0;
  }

  header nav h1 {
    font-size: 20px;
  }

  .theme-switch {
    width: 45px;
    height: 45px;
    right: 15px;
    padding: 10px;
  }

  .theme-switch img {
    width: 20px;
    height: 20px;
  }

  .section {
    width: 95%;
    min-width: 280px;
    padding: 1.5rem;
    margin: 0.5rem;
  }

  .title h2 {
    font-size: 1.3rem;
  }

  .links a {
    font-size: 1rem;
    padding: 0.8rem;
  }

  .container {
    margin: 1rem 0;
  }
}

@media screen and (max-width: 480px) {
  body {
    padding: 0 10px;
  }

  header {
    padding: 12px 10px;
  }

  header nav h1 {
    font-size: 18px;
  }

  .theme-switch {
    width: 40px;
    height: 40px;
    right: 10px;
    padding: 8px;
  }

  .theme-switch img {
    width: 18px;
    height: 18px;
  }

  .section {
    width: 100%;
    min-width: 250px;
    padding: 1rem;
    margin: 0.3rem 0;
  }

  .title {
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
  }

  .title h2 {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
  }

  .links a {
    font-size: 0.95rem;
    padding: 0.7rem;
  }

  .footer {
    padding: 12px;
    margin-bottom: 15px;
  }

  .footer strong {
    font-size: 16px;
  }

  .background-grid {
    gap: 1px;
    padding: 1px;
  }

  .grid-container {
    grid-template-columns: repeat(auto-fill, 1.5cm);
    grid-auto-rows: 1.5cm;
    gap: 1px;
  }

  .grid-item {
    width: 1.5cm;
    height: 1.5cm;
  }
}

@media screen and (max-width: 320px) {
  .section {
    min-width: 220px;
    padding: 0.8rem;
  }

  .title h2 {
    font-size: 1rem;
  }

  .links a {
    font-size: 0.9rem;
    padding: 0.6rem;
  }

  header nav h1 {
    font-size: 16px;
  }

  .theme-switch {
    width: 35px;
    height: 35px;
    padding: 6px;
  }

  .theme-switch img {
    width: 16px;
    height: 16px;
  }
}
