:root {
  /* Variables de Color - Tema Claro (Default) */
  --bg-body: #f8f9fa;
  --bg-card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --accent-color: #3b82f6; /* Azul vibrante */
  --accent-hover: #2563eb;
  --border-color: #e5e7eb;
  --header-bg: rgba(255, 255, 255, 0.9);
  --sidebar-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

  /* Espaciado y Fuentes */
  --font-main: "Inter", sans-serif;
  --header-height: 70px;
  --sidebar-width: 250px;
  --container-max-width: 1200px;
}

[data-theme="dark"] {
  /* Variables de Color - Tema Oscuro */
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --accent-color: #60a5fa;
  --accent-hover: #93c5fd;
  --border-color: #334155;
  --header-bg: rgba(15, 23, 42, 0.9);
  --sidebar-bg: #1e293b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.main-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.header-content {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-image-container {
    height: 50px; /* Ajustar a la altura deseada dentro del header */
    display: flex;
    align-items: center;
}

.header-img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

.main-nav {
  display: flex;
  gap: 10px;
}

.nav-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-btn:hover,
.nav-btn.active {
  color: var(--accent-color);
  background-color: var(--bg-body); /* Sutil fondo al hover */
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.icon-btn,
.text-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-btn {
  width: auto;
  padding: 0 12px;
  font-weight: 600;
}

.icon-btn:hover,
.text-btn:hover {
  background-color: var(--border-color);
}

.mobile-only {
  display: none;
}

/* Layout Principal */
.layout-container {
  display: flex;
  max-width: var(--container-max-width);
  margin: 20px auto;
  padding: 0 20px;
  gap: 20px;
  min-height: calc(100vh - var(--header-height) - 100px); /* Ajuste altura */
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  height: fit-content;
}

.sidebar h3 {
  margin-bottom: 15px;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.sidebar ul {
  list-style: none;
}

.sidebar li {
  margin-bottom: 10px;
}

.sidebar a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.2s;
  display: block;
  padding: 5px 0;
}

.sidebar a:hover {
  color: var(--accent-color);
  transform: translateX(5px); /* Pequeña animación */
}

/* Main Content */
.main-content {
  flex: 1;
  background-color: var(--bg-card);
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.main-content h1 {
  margin-bottom: 20px;
  font-size: 2.5rem;
  background: linear-gradient(to right, var(--accent-color), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-placeholder {
  margin-top: 30px;
  height: 200px;
  background: linear-gradient(135deg, var(--bg-body), var(--border-color));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: var(--text-secondary);
}

/* Footer */
.main-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 40px 20px;
  margin-top: 40px;
  text-align: center;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.social-links a {
  color: var(--text-secondary);
  font-size: 1.5rem;
  transition: all 0.2s;
}

.social-links a:hover {
  color: var(--accent-color);
  transform: translateY(-3px);
}

.footer-links {
  margin-bottom: 15px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
}

.footer-links a:hover {
  text-decoration: underline;
}

.separator {
  margin: 0 10px;
  color: var(--border-color);
}

.copyright {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Media Queries (Responsividad) */
@media (max-width: 768px) {
  .main-nav {
    display: none; /* Ocultar menú desktop */
  }

  .main-nav.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
  }

  .mobile-only {
    display: flex;
  }

  .layout-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }
}

/* --- Estilos Sistema de Noticias --- */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.news-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.news-image {
    width: 100%;
    height: 180px;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 3rem;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.news-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.news-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.news-excerpt {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    flex: 1;
}

.read-more {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: auto;
}

/* Detalle de Noticia */
.news-detail article {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.detail-image {
    width: 100%;
    height: 300px;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 4rem;
    margin-bottom: 30px;
    border-radius: 12px;
}

.detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.detail-meta {
    display: flex;
    gap: 20px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.detail-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.detail-content p {
    margin-bottom: 20px;
}

/* Video Responsive */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* Ratio 16:9 */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 20px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Sudoku Styles --- */
#sudoku-container {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sudoku-controls-top {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.game-btn, .game-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.game-btn:hover {
    background-color: var(--border-color);
}

.game-btn.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr); /* Ensure rows are equal height */
    border: 2px solid var(--text-primary);
    background-color: var(--text-primary);
    gap: 1px;
    aspect-ratio: 1;
}

.sudoku-cell {
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
    color: var(--accent-color); /* User filled color */
}

/* Thicker borders for 3x3 boxes */
.sudoku-cell.border-right {
    border-right: 2px solid var(--text-primary);
}

.sudoku-cell.border-bottom {
    border-bottom: 2px solid var(--text-primary);
}

.sudoku-cell.pre-filled {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.sudoku-cell.selected {
    outline: 3px solid orange;
    z-index: 10;
}

.sudoku-cell.error {
    background-color: #fecaca; /* Light red */
}

[data-theme="dark"] .sudoku-cell.error {
    background-color: #7f1d1d;
}

/* Notes Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 2px;
}

.notes-grid span {
    font-size: 0.6rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Number Controls */
.number-controls {
    display: flex;
    justify-content: center;
    gap: 5px; /* Reduce gap to fit */
    flex-wrap: nowrap; /* Force single line */
    width: 100%;
}

.number-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%; /* Flexible width */
    max-width: 50px;
    height: 60px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    flex: 1; /* Distribute space evenly */
}

.number-btn:hover:not(:disabled) {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.number-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.number-btn span:first-child {
    font-size: 1.5rem;
    font-weight: 700;
}

.number-btn .count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

@media (max-width: 600px) {
    .sudoku-cell {
        font-size: 1.2rem;
    }
    .number-btn {
        height: 50px;
    }
    .number-btn span:first-child {
        font-size: 1.2rem;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 25px;
    color: var(--text-primary);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Amazon Styles */
.amazon-btn {
    background-color: #FF9900;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.amazon-btn:hover {
    background-color: #e68a00;
    color: white;
    text-decoration: none;
}

/* Minesweeper Styles */
.minesweeper-container {
    background-color: #bdbdbd;
    padding: 10px;
    border: 3px solid #fff;
    border-right-color: #7b7b7b;
    border-bottom-color: #7b7b7b;
    display: inline-block;
    user-select: none;
}

.minesweeper-header {
    background-color: #c0c0c0;
    border: 2px solid #7b7b7b;
    border-right-color: #fff;
    border-bottom-color: #fff;
    padding: 5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.minesweeper-counter {
    background-color: #000;
    color: red;
    font-family: 'Courier New', monospace;
    font-size: 24px;
    font-weight: bold;
    padding: 2px 5px;
    border: 1px solid #7b7b7b;
    min-width: 50px;
    text-align: center;
}

.minesweeper-face {
    font-size: 24px;
    width: 40px;
    height: 40px;
    border: 2px solid #fff;
    border-right-color: #7b7b7b;
    border-bottom-color: #7b7b7b;
    background-color: #c0c0c0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.minesweeper-face:active {
    border: 2px solid #7b7b7b;
    border-right-color: #fff;
    border-bottom-color: #fff;
}

.minesweeper-controls {
    margin-bottom: 10px;
    text-align: center;
}

.minesweeper-board {
    display: grid;
    gap: 0;
    border: 3px solid #7b7b7b;
    border-right-color: #fff;
    border-bottom-color: #fff;
}

.ms-cell {
    width: 30px;
    height: 30px;
    background-color: #c0c0c0;
    border: 2px solid #fff;
    border-right-color: #7b7b7b;
    border-bottom-color: #7b7b7b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
}

.ms-cell:active {
    border: 1px solid #7b7b7b; /* Slight visual feedback */
}

.ms-cell.open {
    border: 1px solid #7b7b7b;
    background-color: #c0c0c0;
}

.ms-cell.mine-hit {
    background-color: red;
}

.ms-cell[data-num="1"] { color: blue; }
.ms-cell[data-num="2"] { color: green; }
.ms-cell[data-num="3"] { color: red; }
.ms-cell[data-num="4"] { color: darkblue; }
.ms-cell[data-num="5"] { color: brown; }
.ms-cell[data-num="6"] { color: cyan; }
.ms-cell[data-num="7"] { color: black; }
.ms-cell[data-num="8"] { color: gray; }

/* Story Reader Styles */
.story-reader {
    display: flex;
    flex-direction: column;
    height: 80vh; /* Altura fija para el lector */
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
}

.story-header {
    padding: 15px 20px;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.story-header h3 {
    margin: 0;
    font-size: 1.2rem;
    flex-grow: 1;
    text-align: center;
}

.story-progress {
    font-size: 0.9rem;
    opacity: 0.9;
}

.story-content-container {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-body);
}

.story-text {
    max-width: 800px;
    font-family: 'Georgia', serif; /* Tipografía de lectura */
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text-primary);
    text-align: justify;
}

.story-controls {
    padding: 15px 20px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-btn-small {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.nav-btn-small:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-btn-small:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

#page-indicator {
    font-weight: bold;
    color: var(--text-secondary);
}

/* Responsive adjustments for story reader */
@media (max-width: 768px) {
    .story-content-container {
        padding: 20px;
    }
    .story-text {
        font-size: 1.1rem;
    }
    .story-header h3 {
        font-size: 1rem;
        margin: 0 10px;
    }
}

/* Interactive Story Styles */
.story-choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
    width: 100%;
    max-width: 600px;
}

.choice-btn {
    background-color: var(--bg-card);
    border: 2px solid var(--accent-color);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-family: 'Georgia', serif;
    transition: all 0.2s;
    text-align: left;
}

.choice-btn:hover {
    background-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
