/* ============================================================
   Guía ECOEMS — protected viewer
   Palette: cursoecoems (#9D2555 primary, #6B1E3A dark)
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #1a1d1d;
  color: #1a1d1d;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Block printing */
@media print {
  body * { display: none !important; visibility: hidden !important; }
  body::before {
    content: "Esta guía no se puede imprimir.";
    display: block !important;
    visibility: visible !important;
    font-size: 24px;
    text-align: center;
    padding: 40px;
  }
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #9D2555 0%, #6B1E3A 100%);
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 32px 28px;
}

.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: #6B1E3A;
  font-weight: 700;
}
.login-header p { margin: 0; color: #565959; font-size: 14px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form label {
  font-size: 13px;
  font-weight: 600;
  color: #1A1D1D;
}
#login-form input[type="email"] {
  padding: 12px 14px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
#login-form input[type="email"]:focus { border-color: #9D2555; }

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: #565959;
  cursor: pointer;
}
.remember-row input { width: 16px; height: 16px; accent-color: #9D2555; }
.remember-row span { user-select: none; }

#btn-enter {
  margin-top: 8px;
  padding: 14px;
  background: #9D2555;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
#btn-enter:hover { background: #6B1E3A; }
#btn-enter:disabled { opacity: 0.6; cursor: wait; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  background: #fff3f5;
  border: 1px solid #f5c6cd;
  color: #8a1a2f;
  font-size: 13px;
  border-radius: 8px;
}
.login-help {
  margin: 14px 0 0;
  text-align: center;
  color: #888;
  font-size: 12px;
}
.login-help a { color: #9D2555; text-decoration: none; font-weight: 600; }

.login-footer {
  margin-top: 28px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
}

/* ============================================================
   VIEWER
   ============================================================ */
.viewer-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  background: #1a1d1d;
}

.viewer-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #9D2555 0%, #6B1E3A 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.viewer-brand strong { font-size: 16px; letter-spacing: 0.2px; }
.viewer-user { display: flex; align-items: center; gap: 12px; }
#viewer-email { font-size: 13px; opacity: 0.9; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
#btn-logout:hover { background: rgba(255,255,255,0.25); }

.viewer-toolbar {
  position: sticky;
  top: 56px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: #2a2d2d;
  color: #ddd;
  font-size: 13px;
  border-bottom: 1px solid #3a3d3d;
}
.viewer-toolbar button {
  width: 32px;
  height: 32px;
  background: #3a3d3d;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.viewer-toolbar button:hover { background: #9D2555; }
#zoom-label { min-width: 48px; text-align: center; }
.toolbar-sep { color: #555; }

.pdf-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 12px 60px;
  overflow-x: auto;
}

.page-wrap {
  position: relative;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  max-width: 100%;
}
.page-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Watermark overlay — drawn ON TOP of canvas so screenshots include it */
.watermark-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
  mix-blend-mode: multiply;
  opacity: 0.08;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 29, 29, 0.92);
  color: #fff;
  z-index: 100;
  gap: 16px;
}
.loading-overlay[hidden] { display: none; }
.loading-overlay .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.progress-bar {
  width: min(280px, 70vw);
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 99px;
  transition: width 0.2s ease;
}

@media (max-width: 480px) {
  #viewer-email { max-width: 120px; font-size: 11px; }
  .viewer-brand strong { font-size: 14px; }
  .viewer-toolbar { top: 52px; }
}
