/* ------------------ Variables base ------------------ */
:root {
  --font-main: 'Segoe UI', sans-serif;

  /* Modo claro */
  --bg-color: #f4efe6;
  --text-color: #2b2b2b;
  --accent-color: #a67955;
  --header-bg: #e3d9c5;
  --box-bg: #ffffff;
  --header-logo-filter: none; /* No filter for light mode */

  /* Modo oscuro */
  --bg-color-dark: #1f2933;
  --text-color-dark: #e0e0e0;
  --accent-color-dark: #89a7bd;
  --header-bg-dark: #2b3a47;
  --box-bg-dark: #27323f;
  /* Nuevo filtro azul para el logo en modo oscuro */
  --header-logo-filter-dark: hue-rotate(190deg) brightness(1.1) saturate(1.2);
}

/* ------------------ Reset + Base ------------------ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.4s ease, color 0.4s ease;
  padding: 10px;
}

h1, h2, h3 {
  font-weight: bold;
  margin-bottom: 0.5em;
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1000px;
  margin: auto;
  padding: 20px;
}

/* ------------------ Navbar & Header ------------------ */
.header-container {
  background-color: var(--header-bg);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  transition: background-color 0.4s ease;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Align items to the start to keep buttons at top right */
  margin-bottom: 10px;
  flex-wrap: wrap; /* Allow wrapping for responsiveness */
}

.title-and-image {
  display: flex;
  align-items: center;
  gap: 15px; /* Space between title and image */
}

.header-container h1 {
  font-size: 2.2rem;
  margin: 0; /* Remove default margin */
  line-height: 1; /* Adjust line height for multiline title */
}

.header-logo {
  max-width: 80px; /* Adjust size as needed */
  height: auto;
  filter: var(--header-logo-filter);
  transition: filter 0.4s ease; /* Smooth transition for filter */
}

.top-controls {
  display: flex;
  flex-direction: column; /* Stack theme and layout switchers */
  gap: 10px; /* Space between switchers */
  align-items: flex-end; /* Align buttons to the right */
}

.theme-switcher,
.layout-switcher {
  display: flex;
  gap: 5px; /* Space between buttons within each switcher */
}

.theme-switcher button,
.layout-switcher button {
  font-size: 1.2rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: var(--header-bg);
  color: var(--text-color);
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}

.theme-switcher button:hover,
.layout-switcher button:hover {
  background: var(--accent-color);
  color: white;
}

/* Navegación como botones al lado */
nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  list-style: none;
  gap: 10px; /* Reduced gap for more compact buttons */
  padding: 10px 0;
}

nav li a {
  font-weight: 600;
  padding: 8px 15px; /* Increased padding for better button feel */
  border-radius: 8px;
  transition: background 0.3s, color 0.3s;
  display: inline-block; /* Treat links as inline-block for button-like behavior */
  background-color: var(--header-bg); /* Match header background */
  color: var(--text-color); /* Match text color */
  border: 1px solid rgba(0,0,0,0.1); /* Subtle border for button look */
}

nav li a:hover {
  background-color: var(--accent-color);
  color: #fff;
  text-decoration: none; /* Remove underline on hover */
}

/* ------------------ Secciones ------------------ */
.welcome-section {
  text-align: center;
  margin-bottom: 30px;
}

.image-placeholder img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 20px 0;
}

.bottom-sections {
  display: grid; /* Use grid for better layout control */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive grid */
  gap: 20px;
}

.section-box {
  background: var(--box-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.08);
  transition: background-color 0.4s ease;
}

.section-box h3 {
  margin-bottom: 10px;
}

.small-widget-visits {
    font-size: 0.9em;
    color: #777;
    margin-bottom: 10px;
}

.widget-area {
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    padding: 15px;
    margin-top: 15px;
    text-align: center;
    color: #555;
    font-style: italic;
    border-radius: 8px;
}


/* ------------------ Footer ------------------ */
footer {
  margin-top: 40px;
  padding: 20px;
  text-align: center;
  color: #777;
  font-size: 0.9rem;
  position: relative;
}

.scroll-top-button {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  text-decoration: none;
  background-color: var(--accent-color);
  color: white;
  padding: 5px 10px;
  border-radius: 50%;
  line-height: 1; /* Ensures the arrow is centered vertically */
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: background-color 0.3s;
}

.scroll-top-button:hover {
  background-color: darken(var(--accent-color), 10%);
  text-decoration: none;
}


/* ------------------ Modo Oscuro ------------------ */
body.dark-mode {
  background-color: var(--bg-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .header-container {
  background-color: var(--header-bg-dark);
}

body.dark-mode .header-logo {
  filter: var(--header-logo-filter-dark); /* Aplica el nuevo filtro azul */
}

body.dark-mode nav li a {
  background-color: var(--header-bg-dark); /* Dark mode nav button bg */
  color: var(--text-color-dark);
  border: 1px solid rgba(255,255,255,0.1);
}

body.dark-mode nav li a:hover {
  background-color: var(--accent-color-dark);
  color: white;
}

body.dark-mode .section-box {
  background: var(--box-bg-dark);
}

body.dark-mode .theme-switcher button,
body.dark-mode .layout-switcher button {
  background-color: var(--header-bg-dark);
  color: var(--text-color-dark);
}

body.dark-mode .theme-switcher button:hover,
body.dark-mode .layout-switcher button:hover {
  background-color: var(--accent-color-dark);
  color: #fff;
}

body.dark-mode .scroll-top-button {
    background-color: var(--accent-color-dark);
}

body.dark-mode .widget-area {
    background-color: #3f4e5e;
    border-color: #5a6d80;
    color: #c0c0c0;
}


/* ------------------ Layout Estático ------------------ */
body.static-layout {
  max-width: 100%;
}

body.static-layout .container {
  max-width: 1200px; /* Aumenta el ancho máximo para el modo estático */
}

/* ------------------ Responsive mejorado ------------------ */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 10px;
  }

  .header-top-row {
    flex-direction: column;
    align-items: center; /* Center items in column layout */
    text-align: center;
    gap: 15px; /* Add space between title/image and buttons */
  }

  .title-and-image {
    flex-direction: column; /* Stack title and image vertically on small screens */
    gap: 5px;
  }

  .header-container h1 {
    font-size: 2rem; /* Slightly smaller on mobile */
  }

  .header-logo {
    max-width: 60px; /* Smaller logo on mobile */
  }

  .top-controls {
    flex-direction: row; /* Keep buttons side-by-side but allow wrapping */
    justify-content: center;
    gap: 10px;
    width: 100%; /* Take full width */
  }

  .theme-switcher,
  .layout-switcher {
    flex-wrap: wrap; /* Allow buttons to wrap if needed */
    justify-content: center;
  }

  .theme-switcher button,
  .layout-switcher button {
    flex: 1; /* Distribute space evenly among buttons */
    min-width: unset; /* Remove min-width to allow flexibility */
    max-width: 48%; /* Adjust for two buttons per row */
    padding: 8px 10px; /* Slightly less padding */
    font-size: 1rem;
  }

  nav ul {
    flex-direction: row; /* Keep buttons side by side, but allow wrapping */
    justify-content: center;
    gap: 8px; /* Reduce gap between nav items */
    margin-top: 15px; /* Add space between controls and nav */
  }

  nav li a {
    padding: 8px 12px;
    font-size: 0.95rem; /* Slightly smaller font for nav items */
  }

  .bottom-sections {
    grid-template-columns: 1fr; /* Stack sections vertically on small screens */
  }

  .section-box {
    padding: 15px;
  }

  .scroll-top-button {
    position: static;
    display: block;
    margin: 10px auto 0;
    transform: none;
    font-size: 1.2rem; /* Smaller button */
    padding: 8px 12px; /* Adjust padding */
    border-radius: 4px; /* More square button */
  }

  footer {
    padding-top: 30px;
  }
}

/* Media query for very small screens to ensure buttons don't break layout */
@media (max-width: 480px) {
    .theme-switcher button,
    .layout-switcher button {
        max-width: 100%; /* Force buttons to stack on very small screens */
    }
    nav ul {
        flex-direction: column; /* Stack nav buttons on very small screens */
        align-items: center;
    }
    nav li a {
        width: 100%; /* Full width for stacked nav buttons */
        text-align: center;
    }
}
