/* ===================================
   🎨 VARIABLES (root)
=================================== */

:root {
  /* Colores base (contraste alto) */
  --color-bg: #ffffff;             /* fondo principal blanco puro */
  --color-white: #ffffff;
  --color-black: #1a1a1a;          /* texto general con negro suave */
  --color-gray: #cccccc;           /* líneas, bordes suaves */

  /* Colores principales (azules accesibles) */
  --color-main: #1d4ed8;           /* azul intenso accesible (AA+) */
  --color-main-dark: #1e3a8a;      /* azul aún más oscuro para títulos */
  --color-accent: #2563eb;         /* acento azul ligeramente más vivo */
  --color-nav-bg: #e0ecff;         /* azul muy claro como fondo nav */

  /* Colores de éxito (verde accesible, no confuso con rojo) */
  --color-success: #d1fae5;
  --color-success-txt: #065f46;

  /* Colores de error (magenta-violeta accesible en lugar de rojo puro) */
  --color-error: #fde2e4;
  --color-error-txt: #7f1d1d;

  /* Sombras */
  --shadow: 0 4px 24px rgba(21,184,154,0.08);
  --shadow-main: 0 2px 6px rgba(37,99,235,.15);  /* usa acento azul */
  --shadow-light: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-strong: 0 8px 24px rgba(37,99,235,.18);
  --shadow-fadein: 0 2px 12px rgba(0, 0, 0, .05);

  /* Spinner */
  --color-spinner-bg: var(--color-gray);
  --color-spinner-top: var(--color-main);
  --color-overlay-bg: rgba(0,0,0,0.4);

  /* Transiciones */
  --transition-fast: 0.18s;
  --transition-default: 0.2s;

  /* Tipografía */
  --font-main: 'Inter', Arial, sans-serif;
  --font-size-base: 1rem;
  --font-size-small: 0.97rem;
  --font-size-heading: 1.35rem;

  /* Espaciado y bordes */
  --radius: 14px;
  --padding-form: .65em 1em;
  --padding-btn: .7em;
  --padding-card: 2.2rem 2rem;
  --padding-card-sm: 1rem;
}

/* ===================================
   MODO OSCURO
=================================== */
body.dark-mode,
.app.dark-mode {
  /* Colores base */
  --color-bg: #0f172a;             /* fondo general oscuro azulado */
  --color-white: #1e293b;          /* usado como fondo para tarjetas */
  --color-black: #f8fafc;          /* texto principal en modo claro inverso */
  --color-gray: #334155;          /* bordes/gris oscuro */

  /* Colores principales */
  --color-main: #60a5fa;           /* azul claro vibrante accesible */
  --color-main-dark: #3b82f6;      /* azul accesible para títulos */
  --color-accent: #93c5fd;         /* azul pastel como hover */
  --color-nav-bg: #1e293b;         /* fondo nav/tarjetas */

  /* Colores de éxito */
  --color-success: #064e3b;
  --color-success-txt: #d1fae5;

  /* Colores de error */
  --color-error: #7f1d1d;
  --color-error-txt: #fee2e2;

  /* Sombras adaptadas para fondos oscuros */
  --shadow: 0 4px 24px rgba(255, 255, 255, 0.05);
  --shadow-main: 0 2px 6px rgba(147,197,253,0.12);
  --shadow-light: 0 2px 8px rgba(255, 255, 255, 0.03);
  --shadow-strong: 0 8px 24px rgba(147,197,253,0.18);
  --shadow-fadein: 0 2px 12px rgba(255, 255, 255, .05);

  /* Spinner */
  --color-spinner-bg: var(--color-gray);
  --color-spinner-top: var(--color-accent);
  --color-overlay-bg: rgba(255,255,255,0.12);

}

body.dark-mode .form__input,
.app.dark-mode .form__input {
  background: var(--color-white);   /* caja más clara */
  color: var(--color-black);        /* texto claro */
  border-color: var(--color-gray);  /* borde visible */
}

/* ===================================
   🧱 LAYOUT GENERAL
=================================== */
body, .app {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-black);
  margin: 0; padding: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.app__main {
  flex: 1;
  padding: 2.2rem 1rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.confirm-result {
  text-align: center;
  margin-top: 2rem;
}

/* ===================================
   🔝 HEADER
=================================== */
.app__header {
  background: var(--color-white);
  color: var(--color-main);
  border-bottom: 2px solid var(--color-gray);
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 2rem;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}

.app__logo-box {
  display: flex; align-items: center; gap: .8em;
}

.app__logo-img {
  width: 44px; height: 44px; object-fit: contain;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow: var(--shadow-light);
  border: 2px solid var(--color-main);
}

.app__logo-text {
  font-size: var(--font-size-heading);
  font-weight: bold; letter-spacing: .02em;
  color: var(--color-main);
}

/* ===================================
   🧭 NAV
=================================== */
.nav {
  display: flex;
  align-items: center;
  position: relative;
}

.nav__list {
  display: flex; gap: 1rem;
  list-style: none; margin: 0; padding: 0;
  transition: all var(--transition-fast);
  background: transparent;
}

.nav__link {
  color: var(--color-main);
  text-decoration: none;
  padding: .45em 1.1em;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: var(--font-size-base);
  background: var(--color-nav-bg);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav__link:hover,
.nav__link.active {
  background: var(--color-accent);
  color: var(--color-white);
  box-shadow: var(--shadow-main);
}

.nav__toggle {
  display: none; background: none; border: none;
  color: var(--color-main);
  font-size: 2rem;
  cursor: pointer;
  margin-left: 1em;
}

/* Responsive nav */
@media (max-width: 720px) {
  .app__header {
    flex-direction: row; align-items: center;
    padding: .6rem 1rem;
  }
  .nav__list {
    flex-direction: column;
    gap: 0;
    background: var(--color-white);
    width: 100vw;
    left: 0; top: 70px;
    position: fixed;
    display: none;
    border-bottom: 2px solid var(--color-gray);
    box-shadow: var(--shadow-strong);
    padding: 0.6em 0;
    z-index: 200;
    margin: 0;
  }
  .nav__list.open { display: flex; }
  .nav__item { width: 100%; }
  .nav__link {
    display: block;
    width: 100%;
    padding: 1em 2em;
    border-radius: 0;
    text-align: left;
    box-shadow: none;
    font-size: 1.12em;
  }
  .nav__toggle {
    display: block;
    position: relative;
    z-index: 21;
  }

  .theme-toggle {
    padding-left: 0.2em;
  }

}

/* ===================================
   📄 FORMULARIOS
=================================== */
.dashboard, .form {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--padding-card);
  margin-bottom: 2.4rem;
}

h2, h3 {
  color: var(--color-main-dark);
  margin-bottom: .7rem;
}

.form__label {
  font-weight: 500;
  color: var(--color-main-dark);
}

.form__input, .form__button {
  border-radius: var(--radius);
  border: 1.5px solid var(--color-gray);
  padding: var(--padding-form);
  font-size: var(--font-size-base);
  background: var(--color-bg);
}

.form__input {
  margin-top: .2em;
}

.form__input:focus {
  border-color: var(--color-accent);
  outline: none;
}

.form__button {
  background: var(--color-main);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: background var(--transition-default), color var(--transition-default);
  margin-top: .7em;
  padding: var(--padding-btn);
}

.form__button:hover {
  background: var(--color-accent);
  color: var(--color-main);
}

.form__group {
  display: flex;
  flex-direction: column;
  gap: .2em;
  margin-bottom: 1.1em;
}

.form__info {
  margin-top: 1.3em;
  text-align: left;
  font-size: var(--font-size-small);
  color: var(--color-main-dark);
}

.form__link {
  color: var(--color-main);
  font-weight: 600;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.form__link:hover {
  color: var(--color-accent);
}

/* ===================================
   ✅ MENSAJES
=================================== */
.message {
  border-radius: var(--radius);
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  font-size: 1.08rem;
  font-weight: 500;
  box-shadow: var(--shadow-fadein);
  animation: fadeIn .5s;
}

.message--success {
  background: var(--color-success);
  color: var(--color-success-txt);
}

.message--error {
  background: var(--color-error);
  color: var(--color-error-txt);
}

/* ===================================
   📋 TABLA DE URLs
=================================== */
.url-list-wrapper {
  max-height: 60vh;
  overflow-y: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--color-white);
  padding: 2em;
}

.url-list {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1em;
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.url-list__th, .url-list__td {
  padding: .7em;
  border-bottom: 1px solid var(--color-gray);
  text-align: left;
}

.url-list__td:last-child {
  text-align: right;
}

.url-list tr:last-child td {
  border-bottom: none;
}

.url-list th, .url-list td {
  text-align: center;
}

.url-list th:first-child, .url-list td:first-child,
.url-list th:nth-child(2), .url-list td:nth-child(2) {
  text-align: left;
}

/* ===================================
   📱 MEDIA QUERIES
=================================== */
@media (max-width: 700px) {
  .url-list, .url-list__th, .url-list__td { font-size: .98em; }
  .dashboard, .form { padding: var(--padding-card-sm); }
  .app__main { padding: 1rem .4rem; }
}

@media (max-width: 500px) {
  .app__logo-text { font-size: 1rem; }
  .app__main { padding: .5rem .1rem; }
  .dashboard, .form { padding: .6rem; }
}

/* ===================================
   🔲 MODAL
=================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--color-overlay-bg);
  align-items: center;
  justify-content: center;
}

.modal--active { display: flex; }

.modal__content {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 1.6rem;
  max-width: 90vw;
  width: 340px;
  box-shadow: var(--shadow);
}

.modal__close {
  float: right;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-main-dark);
}

.modal__image {
  width: 100%;
  height: auto;
  margin-top: .7rem;
}

.modal__content--error { border-left: 5px solid var(--color-error-txt); }
.modal__content--success { border-left: 5px solid var(--color-success-txt); }


/* ===================================
    spinner-modal
=================================== */

.spinner-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: var(--color-overlay-bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.spinner-modal--active {
  display: flex;
}

/* Elemento: spinner */
.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid var(--color-spinner-bg);
  border-top: 6px solid var(--color-spinner-top);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ===================================
   🔻 FOOTER
=================================== */
.app__footer {
  background: var(--color-main);
  color: var(--color-white);
  padding: 1.1rem 0;
  text-align: center;
  letter-spacing: .03em;
  margin-top: auto;
  font-size: var(--font-size-base);
}

.footer__dot {
  color: var(--color-accent);
  font-weight: bold;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==================================
    Intercambiador de Tema
================================== */
.theme-toggle {
  margin-left: auto;
  display: flex; align-items: center;
  padding-right: 1.5em;
}

.theme-toggle__label {
  display: flex;
  gap: .5em;
  align-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  user-select: none;
}
.theme-toggle__label input[type="checkbox"] {
  appearance: none;
  width: 2.4em;
  height: 1.4em;
  background: var(--color-gray);
  border-radius: var(--radius);
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.theme-toggle__label input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 0.15em;
  left: 0.15em;
  width: 1.1em;
  height: 1.1em;
  border-radius: 50%;
  background: var(--color-white);
  transition: transform var(--transition-fast);
}
.theme-toggle__label input[type="checkbox"]:checked::before {
  transform: translateX(1em);
}
.theme-toggle__label input[type="checkbox"]:checked {
  background: var(--color-main);
}
