/* THEME VARIABLES */
:root {
  /* Default fallbacks set by JS or hardcoded */
  --bg-color-light: #016293;
  --bg-color-dark: #131313;
  --bg-image-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 28' width='56' height='28'%3E%3Cpath fill='%23014669' fill-opacity='0.2' d='M56 26v2h-7.75c2.3-1.27 4.94-2 7.75-2zm-26 2a2 2 0 1 0-4 0h-4.09A25.98 25.98 0 0 0 0 16v-2c.67 0 1.34.02 2 .07V14a2 2 0 0 0-2-2v-2a4 4 0 0 1 3.98 3.6 28.09 28.09 0 0 1 2.8-3.86A8 8 0 0 0 0 6V4a9.99 9.99 0 0 1 8.17 4.23c.94-.95 1.96-1.83 3.03-2.63A13.98 13.98 0 0 0 0 0h7.75c2 1.1 3.73 2.63 5.1 4.45 1.12-.72 2.3-1.37 3.53-1.93A20.1 20.1 0 0 0 14.28 0h2.7c.45.56.88 1.14 1.29 1.74 1.3-.48 2.63-.87 4-1.15-.11-.2-.23-.4-.36-.59H26v.07a28.4 28.4 0 0 1 4 0V0h4.09l-.37.59c1.38.28 2.72.67 4.01 1.15.4-.6.84-1.18 1.3-1.74h2.69a20.1 20.1 0 0 0-2.1 2.52c1.23.56 2.41 1.2 3.54 1.93A16.08 16.08 0 0 1 48.25 0H56c-4.58 0-8.65 2.2-11.2 5.6 1.07.8 2.09 1.68 3.03 2.63A9.99 9.99 0 0 1 56 4v2a8 8 0 0 0-6.77 3.74c1.03 1.2 1.97 2.5 2.79 3.86A4 4 0 0 1 56 10v2a2 2 0 0 0-2 2.07 28.4 28.4 0 0 1 2-.07v2c-9.2 0-17.3 4.78-21.91 12H30zM7.75 28H0v-2c2.81 0 5.46.73 7.75 2zM56 20v2c-5.6 0-10.65 2.3-14.28 6h-2.7c4.04-4.89 10.15-8 16.98-8zm-39.03 8h-2.69C10.65 24.3 5.6 22 0 22v-2c6.83 0 12.94 3.11 16.97 8zm15.01-.4a28.09 28.09 0 0 1 2.8-3.86 8 8 0 0 0-13.55 0c1.03 1.2 1.97 2.5 2.79 3.86a4 4 0 0 1 7.96 0zm14.29-11.86c1.3-.48 2.63-.87 4-1.15a25.99 25.99 0 0 0-44.55 0c1.38.28 2.72.67 4.01 1.15a21.98 21.98 0 0 1 36.54 0zm-5.43 2.71c1.13-.72 2.3-1.37 3.54-1.93a19.98 19.98 0 0 0-32.76 0c1.23.56 2.41 1.2 3.54 1.93a15.98 15.98 0 0 1 25.68 0zm-4.67 3.78c.94-.95 1.96-1.83 3.03-2.63a13.98 13.98 0 0 0-22.4 0c1.07.8 2.09 1.68 3.03 2.63a9.99 9.99 0 0 1 16.34 0z'%3E%3C/path%3E%3C/svg%3E");
  --bg-image-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 28' width='56' height='28'%3E%3Cpath fill='%23313131' fill-opacity='0.2' d='M56 26v2h-7.75c2.3-1.27 4.94-2 7.75-2zm-26 2a2 2 0 1 0-4 0h-4.09A25.98 25.98 0 0 0 0 16v-2c.67 0 1.34.02 2 .07V14a2 2 0 0 0-2-2v-2a4 4 0 0 1 3.98 3.6 28.09 28.09 0 0 1 2.8-3.86A8 8 0 0 0 0 6V4a9.99 9.99 0 0 1 8.17 4.23c.94-.95 1.96-1.83 3.03-2.63A13.98 13.98 0 0 0 0 0h7.75c2 1.1 3.73 2.63 5.1 4.45 1.12-.72 2.3-1.37 3.53-1.93A20.1 20.1 0 0 0 14.28 0h2.7c.45.56.88 1.14 1.29 1.74 1.3-.48 2.63-.87 4-1.15-.11-.2-.23-.4-.36-.59H26v.07a28.4 28.4 0 0 1 4 0V0h4.09l-.37.59c1.38.28 2.72.67 4.01 1.15.4-.6.84-1.18 1.3-1.74h2.69a20.1 20.1 0 0 0-2.1 2.52c1.23.56 2.41 1.2 3.54 1.93A16.08 16.08 0 0 1 48.25 0H56c-4.58 0-8.65 2.2-11.2 5.6 1.07.8 2.09 1.68 3.03 2.63A9.99 9.99 0 0 1 56 4v2a8 8 0 0 0-6.77 3.74c1.03 1.2 1.97 2.5 2.79 3.86A4 4 0 0 1 56 10v2a2 2 0 0 0-2 2.07 28.4 28.4 0 0 1 2-.07v2c-9.2 0-17.3 4.78-21.91 12H30zM7.75 28H0v-2c2.81 0 5.46.73 7.75 2zM56 20v2c-5.6 0-10.65 2.3-14.28 6h-2.7c4.04-4.89 10.15-8 16.98-8zm-39.03 8h-2.69C10.65 24.3 5.6 22 0 22v-2c6.83 0 12.94 3.11 16.97 8zm15.01-.4a28.09 28.09 0 0 1 2.8-3.86 8 8 0 0 0-13.55 0c1.03 1.2 1.97 2.5 2.79 3.86a4 4 0 0 1 7.96 0zm14.29-11.86c1.3-.48 2.63-.87 4-1.15a25.99 25.99 0 0 0-44.55 0c1.38.28 2.72.67 4.01 1.15a21.98 21.98 0 0 1 36.54 0zm-5.43 2.71c1.13-.72 2.3-1.37 3.54-1.93a19.98 19.98 0 0 0-32.76 0c1.23.56 2.41 1.2 3.54 1.93a15.98 15.98 0 0 1 25.68 0zm-4.67 3.78c.94-.95 1.96-1.83 3.03-2.63a13.98 13.98 0 0 0-22.4 0c1.07.8 2.09 1.68 3.03 2.63a9.99 9.99 0 0 1 16.34 0z'%3E%3C/path%3E%3C/svg%3E");
  
  --bg-color: var(--bg-color-light);
  --bg-image: var(--bg-image-light);
  
  /* Shared variables */
  --img-snow-d: url(images/bg_snow_light.jpg);
  --calc-input-bg: #fff;
  --calc-input-color: #212529;
  --calc-input-border: #ced4da;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: var(--bg-color-dark);
    --bg-image: var(--bg-image-dark);
    --img-snow-d: url(images/bg_snow_dark.jpg);
    --calc-input-bg: #23272b;
    --calc-input-color: #f8f9fa;
    --calc-input-border: #495057;
  }
}

/* Forced Overrides (Applied to html or body) */
:is(html, body).light-mode {
  --bg-color: var(--bg-color-light) !important;
  --bg-image: var(--bg-image-light) !important;
  --img-snow-d: url(images/bg_snow_light.jpg);
  --calc-input-bg: #fff;
  --calc-input-color: #212529;
  --calc-input-border: #ced4da;
}

:is(html, body).dark-mode {
  --bg-color: var(--bg-color-dark) !important;
  --bg-image: var(--bg-image-dark) !important;
  --img-snow-d: url(images/bg_snow_dark.jpg);
  --calc-input-bg: #23272b;
  --calc-input-color: #f8f9fa;
  --calc-input-border: #495057;
}

body {
  /*var used here*/
  background-color: var(--bg-color);
  background-image: var(--bg-image);
  color: white;
  font-family: "Nunito", sans-serif;
  background-repeat: repeat;
  background-size: initial;
  font-size: 1.5em;
  transition-property: background;
  transition-duration: 5s;
  transition-delay: 0;
  font-weight: normal;
  margin-top: 1rem;
  animation: bg-diagonal-move var(--bg-animate-duration, 20s) linear infinite;
  animation-play-state: running;
}

body.paused {
  animation-play-state: paused;
}

body.xmas {
  background-image: var(--img-snow-d);
  animation-name: bg-downward-move;
  animation-duration: 80s;
}

.caja {
  width: 1346px;
  margin-left: auto;
  margin-right: auto;
  max-width: 95vw; /* Fallback for smaller screens */
}

.caja.fullwidth {
   width: 100%;
   max-width: 100% !important;
   padding-left: 20px;
   padding-right: 20px;
}

#fecha,
#reminder {
  display: inline-block;
  font-family: "Inconsolata", monospace;
  font-size: 1.4em;
  line-height: 40px;
  margin-top: 7px;
  margin-bottom: 10px;
  max-width: 100%;
  text-wrap: balance;
}

/*#reminder {
  margin-right: 0;
  margin-left: 0.5em;
}*/

#fecha span {
  background-color: #93007c;
}

#fecha a span,
#fecha a:visited span {
  color: white;
}

#fecha a:has(span),
#fecha a:visited:has(span) {
  text-decoration-color: white;
}

h1 {
  font-family: "Exo", sans-serif;
  font-size: 5rem;
  font-weight: 200;
  margin-bottom: 0px;
  border-bottom: 12px solid color-mix(in srgb, var(--bg-color) 70%, white);
  transition-property: color, border-bottom-color;
  transition-duration: 5s;
  text-wrap: balance;
}

h2 {
  font-family: "Exo", sans-serif;
  font-size: 3rem;
  font-weight: 600;
}

a,
a:visited {
  color: #83d3fa;
}

a:hover {
  color: #c4eafd;
}

links,
.morelinks {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  margin-left: -1.2rem;
  margin-right: -1.2rem;
}

.tooltip {
  font-size: 1rem;
}

.tree {
  display: flex;
  width: 100%;
  padding-top: 2rem;
  justify-content: center;
  margin-top: 2rem;
}

.item {
  display: block;
  width: 100px;
  height: 100px;
  margin: 1.2rem;
  /*margin-bottom: 3rem;*/
}

.item a {
  display: block;
  width: 100px;
  height: 100px;
  font-size: 0em;
  text-decoration: none;
  border: none;
  background-size: cover;
  border-radius: 15%;
  transition-property: all;
  transition-duration: 0.2s;
  /*margin-right: 4rem;*/
  /*margin-bottom: 3rem;*/
}

.item a:hover {
  width: 105px;
  height: 105px;
  box-shadow: 4px 4px 4px 4px rgba(0, 0, 0, 0.2);
  transition-property: all;
  transition-duration: 0.2s;
  margin: -2.5px;
}

ul.columns {
  column-count: 3;
  column-gap: normal;
}

/* TV */

.links.tv {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: 0.5fr 0.5fr;
  margin-left: -1.2rem;
  margin-right: -1.2rem;
}

.links.tv .item {
  width: 150px;
  height: 150px;
}

.links.tv .item a {
  border-radius: 100%;
  width: 150px;
  height: 150px;
}

.links.tv .item a:hover {
  margin: -5.5px;
}

/* CALCULADORA */

.input-group.mb-3 {
  width: 500px;
}

.dias-calc-input {
  max-width: 120px;
}
.dias-calc-date {
  max-width: 180px;
}
.dias-calc-resultado {
  font-weight: bold;
  font-size: 1.2em;
}
.dias-calc-dia {
  font-weight: bold;
  font-size: 1.2em;
}
.dias-calc-section {
  margin-top: 1em;
  margin-bottom: 2em;
}

.form-control.dias-calc-input {
  font-size: large;
}

/* NIGHT MODE */

/* Calculator Dark Overrides (Now driven by vars) */
.form-control.dias-calc-input,
.form-control.dias-calc-date {
  background-color: var(--calc-input-bg) !important;
  color: var(--calc-input-color) !important;
  border-color: var(--calc-input-border) !important;
}
.form-control.dias-calc-input:focus,
.form-control.dias-calc-date:focus {
  background-color: var(--calc-input-bg) !important;
  color: var(--calc-input-color) !important;
  border-color: #86b7fe !important;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}
.input-group-text {
  background-color: var(--calc-input-bg) !important;
  color: var(--calc-input-color) !important;
  border-color: var(--calc-input-border) !important;
}

@keyframes bg-diagonal-move {
  0% {
    background-position: 0 0;
  }
  100% {
    /* Loop exactly one tile size for seamless infinite scroll */
    /* Using independent width and height for perfect rectangular alignment */
    background-position: var(--bg-pattern-width, 56px) var(--bg-pattern-height, 56px);
  }
}

@keyframes bg-downward-move {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 640px 640px;
  }
}

/* RESPONSIVE */

@media only screen and (min-width: 1600px) {
  .caja {
    width: 95%;
    max-width: 1600px;
  }
  
  .caja.fullwidth {
    width: 100%;
    max-width: 100% !important;
  }

  .links,
  .morelinks {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: 0.5fr 0.5fr;
    /*flex-wrap: normal;
        flex-direction: row;*/
    margin-left: -1.2rem;
    margin-right: -1.2rem;
  }

  .item {
    margin: 1.2rem;
  }
}

@media only screen and (max-width: 1599px) {
  .caja {
    width: 95%;
    max-width: 100vw;
  }

  .links,
  .morelinks {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: 0.5fr 0.5fr;
    /*flex-wrap: normal;
        flex-direction: row;*/
    margin-left: -1.2rem;
    margin-right: -1.2rem;
  }

  .item {
    margin: 1.2rem;
  }

  .links.tv {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media only screen and (max-width: 1378px) {
  h1 {
    font-size: 6rem;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(9, 1fr);
  }
}

@media only screen and (max-width: 1262px) {
  h1 {
    font-size: 5rem;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(8, 1fr);
  }
  .links.tv {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media only screen and (max-width: 1122px) {
  h1 {
    font-size: 4rem;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(7, 1fr);
  }
}

@media only screen and (max-width: 1024px) {
  .caja {
    margin-top: 0.5%;
  }

  .links,
  .morelinks {
    grid-template-columns: repeat(6, 1fr);
  }
  .links.tv {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media only screen and (max-width: 830px) {
  .links,
  .morelinks {
    grid-template-columns: repeat(5, 1fr);
  }
  .links.tv {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media only screen and (max-width: 685px) {
  h1 {
    font-size: 3rem;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(4, 1fr);
  }
  ul.columns {
    column-count: 2;
  }
}

@media only screen and (max-width: 540px) {
  #fecha,
  #reminder {
    font-size: 1em;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(3, 1fr);
  }
  .links.tv {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media only screen and (max-width: 400px) {
  h1 {
    font-size: 2rem;
  }
  .links,
  .morelinks {
    grid-template-columns: repeat(2, 1fr);
  }
  ul.columns {
    column-count: 1;
  }
}

/* ONBOARDING OVERLAY */
#onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.d-none {
  display: none !important;
}

.onboarding-card {
  background: #1e2226;
  padding: 3rem;
  border-radius: 15px;
  max-width: 800px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  color: white;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-container {
  display: none;
}
.step-container.active {
  display: block;
}

.app-selection-container {
  display: flex;
  gap: 20px;
  text-align: left;
  height: 500px;
}

.catalog-section,
.my-apps-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  border-radius: 10px;
  overflow: hidden;
}

.app-grid-scroll,
.my-apps-scroll {
  flex-grow: 1;
  overflow-y: auto;
  margin-top: 10px;
}

.catalog-item,
.my-app-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}
.catalog-item:hover,
.my-app-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-icon-mini {
  width: 24px;
  height: 24px;
  background-size: cover;
  border-radius: 4px;
  margin-right: 10px;
}

.btn-action {
  margin-left: auto;
  border: none;
  background: none;
  color: white;
  cursor: pointer;
}

.btn-action:hover {
  color: #0dcaf0;
}

/* Scrollbar styling for overlay */
.app-grid-scroll::-webkit-scrollbar,
.my-apps-scroll::-webkit-scrollbar {
  width: 8px;
}
.app-grid-scroll::-webkit-scrollbar-track,
.my-apps-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.app-grid-scroll::-webkit-scrollbar-thumb,
.my-apps-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Floating Alerts */
#alertContainer {
  /* Positioned by class fixed-top but we add specifics if needed, 
     though bootstrap fixed-top handles top:0 left:0 right:0. 
     We want it centered and specific top offset. */
  top: 20px;
  z-index: 10000;
  pointer-events: none; /* Let clicks pass through container */
}

#alertContainer .alert {
  pointer-events: auto; /* Re-enable clicks on the alert itself */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.4s ease-out forwards;
  min-width: 300px;
  max-width: 90%;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Top Right Settings Icon */
.settings-icon,
.home-icon {
  position: absolute;
  top: 15px;
  right: 20px;
  z-index: 1000;
}
.home-icon {
  right: auto;
  left: 20px; /* Top Left for Home */
}

.settings-icon a,
.home-icon a {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  transition: color 0.3s;
}
.settings-icon a:hover,
.home-icon a:hover {
  color: white;
}

/* Custom Links Container */
.custom-links-container {
  margin-top: 20px;
  text-align: left;
}

.custom-links-container h2 {
  column-span: all;
  -webkit-column-span: all;
}

/* Column Logic classes applied by JS */
.links-cols-1 {
  column-count: 1;
}
.links-cols-2 {
  column-count: 2;
}
.links-cols-3 {
  column-count: 3;
}
.links-cols-4 {
  column-count: 4;
}

/*.custom-links-container ul {
  list-style: none;
  padding: 0;
  margin: 0;
}*/

.custom-links-container li {
  margin-bottom: 5px;
  break-inside: avoid;
}

.custom-links-container a {
  color: #ddd;
  text-decoration: none;
  font-size: 1em;
  transition: color 0.2s;
}
.custom-links-container a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Responsive adjustments for columns */
@media (max-width: 768px) {
  .links-cols-4,
  .links-cols-3,
  .links-cols-2 {
    column-count: 1 !important;
  }
}

/* SETTINGS TOOLTIP */
.settings-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  width: 250px;
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: "Nunito", sans-serif;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  z-index: 1001;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: fadeIn 0.5s ease-out;
}

.settings-tooltip::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(0, 0, 0, 0.9);
}

.tooltip-text {
  flex: 1;
  line-height: 1.4;
  text-align: left;
}

.tooltip-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
.tooltip-close:hover {
  color: #fff;
}

/* SPECIAL DAYS ANIMATION */
/* Base styles for the special day span */
#fecha span.special-day-green,
#fecha span.special-day-orange {
  position: relative;
  display: inline-block;
  background-color: transparent;
  z-index: 1; /* Keep text on top */
  color: white; /* Ensure text is readable */
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5); /* Slight shadow for readability */
  /* No padding change or scale on the element itself to prevent jitter */
}

/* Common Magical Glow Logic via Pseudo-element */
#fecha .special-day-green::before,
#fecha .special-day-orange::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%; /* Slightly wider than text */
  height: 120%; /* Slightly taller */
  border-radius: 50%; /* Oval shape */
  z-index: -1;
  filter: blur(8px); /* Soften the edges significantly */
  opacity: 0.6;
  pointer-events: none;
}

/* Green Specifics */
#fecha .special-day-green::before {
  background: radial-gradient(
    circle,
    rgba(72, 255, 0, 0.6) 0%,
    rgba(40, 167, 69, 0) 70%
  );
  box-shadow: 0 0 10px rgba(72, 255, 0, 0.4);
  animation: magicPulseGreen 4s infinite ease-in-out;
}

/* Orange Specifics */
#fecha .special-day-orange::before {
  background: radial-gradient(
    circle,
    rgba(255, 165, 0, 0.8) 0%,
    rgba(253, 126, 20, 0) 70%
  );
  box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
  animation: magicPulseOrange 4s infinite ease-in-out;
}

/* Animations - Affecting only the Glow (Pseudo-element) */
@keyframes magicPulseGreen {
  0% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.9);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.1); /* Subtle breathing */
  }
  100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

@keyframes magicPulseOrange {
  0% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.95);
  }
  50% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.95);
  }
}
