:root {
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --border: #e1e1e5;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --accent: #ed1c24;
  --accent-hover: #c1131a;
  --accent-soft: #fdecec;
  --error: #c62828;
  --success: #1e7e34;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04), 0 1px 8px rgba(20, 20, 30, 0.03);
  --shadow-md: 0 4px 16px rgba(20, 20, 30, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Columna a pantalla completa para que el footer quede a la vista al pie
     incluso en paginas cortas como el login. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  position: relative;
}

/* Foto de fondo al azar (public/img/login-bg/), si hay alguna cargada. Sin
   background-image seteado (carpeta vacia) queda igual que antes: el
   fondo solido de --bg del body. Va sin z-index negativo a proposito: el
   background del <body> se "promueve" al canvas de la pagina y se pinta
   por debajo de cualquier elemento con z-index negativo, asi que un
   z-index negativo aca dejaria esta capa siempre invisible. Alcanza con
   que quede primera en el DOM (antes de .page-center) para pintarse detras.*/
.login-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(245, 245, 247, 0.55);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.auth-brand img {
  width: 34px;
  height: 34px;
}

.brand-word {
  font-weight: 800;
  color: #e70505;
  letter-spacing: -0.02em;
}

.auth-brand .brand-word {
  font-size: 1.4rem;
}

.brand-word .accent {
  color: var(--text);
  font-weight: 300;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.card h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.card .subtitle {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.password-field {
  position: relative;
  margin-bottom: 16px;
}

.password-field input[type="password"],
.password-field input[type="text"] {
  margin-bottom: 0;
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px 8px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text);
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}

button.primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.form-footer {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.form-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

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

.error-box {
  background: #fdecea;
  color: var(--error);
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.error-box.visible {
  display: block;
}

/* --- Topbar / navegacion --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar .brand img {
  width: 28px;
  height: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg);
}

.nav-links a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.provider-badge {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
  text-decoration: none;
  transition: background 0.15s;
}

.provider-badge:hover {
  background: #fbdada;
}

.topbar .user-email {
  color: var(--muted);
  font-size: 0.85rem;
}

button.link-button {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
}

button.link-button:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

main.container {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px;
}

main.container-wide {
  max-width: 960px;
}

main.container h2 {
  letter-spacing: -0.01em;
}

.hero-empty {
  text-align: center;
  padding: 64px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 24px;
}

.hero-empty img {
  border-radius: 12px;
  margin-bottom: 16px;
}

.hero-empty h2 {
  margin: 0 0 8px;
}

.hero-empty p {
  color: var(--muted);
  margin: 0 0 20px;
}

.explorer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.explorer-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.select-all-label input {
  margin: 0;
  width: auto;
}

.entry-select {
  flex-shrink: 0;
  margin: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.95rem;
}

.breadcrumb button {
  background: none;
  color: var(--accent);
  padding: 3px 6px;
  font-weight: 500;
  border-radius: 6px;
}

.breadcrumb button:not(:disabled):hover {
  background: var(--accent-soft);
}

.breadcrumb button:disabled {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.breadcrumb .sep {
  color: var(--muted);
}

.new-folder-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.new-folder-form input {
  margin: 0;
  padding: 8px 10px;
  width: 220px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 16px 0;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.upload-item-name {
  flex: 0 0 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.upload-item-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.upload-item-status {
  flex: 0 0 90px;
  color: var(--muted);
  text-align: right;
}

.upload-item.is-error .upload-item-status {
  color: var(--error);
}

.upload-item.is-error .upload-item-bar-fill {
  background: var(--error);
}

.upload-item.is-done .upload-item-status {
  color: var(--success);
}

.entry-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.entry-row:last-child {
  border-bottom: none;
}

.entry-row.is-folder {
  cursor: pointer;
}

.entry-row.is-folder:hover {
  background: var(--bg);
}

.entry-icon {
  font-size: 1.3rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.entry-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.entry-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-size {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.entry-download {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 1rem;
}

.entry-download:hover {
  background: var(--accent-soft);
}

.entry-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--error);
  cursor: pointer;
  font-size: 0.95rem;
}

.entry-delete:hover {
  background: #fdecea;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6f4ea;
  color: var(--success);
  margin-left: 8px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  padding: 8px 14px;
}

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

.btn-primary-sm {
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
}

.btn-primary-sm:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: #fdecea;
  color: var(--error);
  padding: 8px 14px;
}

.btn-danger:hover {
  background: #fbdada;
}

a.btn-primary-sm {
  text-decoration: none;
  display: inline-block;
}

.success-box {
  background: #e6f4ea;
  color: var(--success);
  border: 1px solid #b7dfc0;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-top: 16px;
}

/* --- Aviso de subida y aceptacion de terminos --- */

.upload-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
  margin: 16px 0 10px;
}

.upload-notice strong {
  color: var(--accent-hover);
}

/* --- Terminos y condiciones --- */

.terms-content {
  max-width: 760px;
}

.terms-content .updated {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -8px 0 24px;
}

.terms-content h2 {
  margin: 32px 0 12px;
  font-size: 1.15rem;
}

.terms-content h2:first-of-type {
  margin-top: 8px;
}

.terms-content p {
  margin: 0 0 16px;
  line-height: 1.6;
  color: var(--text);
}

/* --- Footer --- */

.site-footer {
  margin-top: 48px;
  background: #e70505;
  color: #fff;
  padding: 32px 24px 20px;
  /* Por encima del fondo fijo del login (.login-bg), que es un elemento
     posicionado y sino pintaria su velo claro sobre el footer. */
  position: relative;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}

.footer-col .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  margin-bottom: 8px;
}

.footer-col .brand img {
  width: 22px;
  height: 22px;
  /* El logo tiene fondo transparente; sobre el footer rojo necesita un
     circulo blanco detras para que el rojo y el gris del logo se lean. */
  background: #fff;
  border-radius: 50%;
}

/* Sobre el fondo rojo el wordmark va todo en blanco. */
.site-footer .brand-word,
.site-footer .brand-word .accent {
  color: #fff;
}

.footer-col h4 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.8);
}

.footer-col p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.5;
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 9px;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-address {
  margin-bottom: 10px;
}

.footer-map-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  padding: 12px 14px;
  text-decoration: none;
  color: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.footer-map-card:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.22);
}

.footer-map-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.footer-map-text {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
}

.footer-map-text strong {
  color: #fff;
  font-size: 0.9rem;
}

.footer-bottom {
  max-width: 960px;
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.78rem;
  text-align: center;
}
