*{box-sizing:border-box}
:root{--bg:#0f172a;--card:#111827ee;--text:#e5e7eb;--muted:#94a3b8;--accent:#22c55e;--surface:#0b1222;--border:#1f2937}
html,body{height:100%}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:linear-gradient(180deg,var(--surface),var(--bg));color:var(--text)}
h1,h2,h3{margin:0 0 .75rem}
a{color:inherit;text-decoration:none}

.login{display:grid;place-items:center;padding:2rem;background:url('images/fondo.jpg') center/cover no-repeat fixed}
.card{width:min(92vw,420px);background:rgba(17,24,39,.85);border:1px solid var(--border);border-radius:20px;padding:2rem;backdrop-filter:blur(10px);box-shadow:0 10px 30px rgba(0,0,0,.35)}
.card h1{text-align:center;letter-spacing:.5px}
.card form{display:grid;gap:.75rem;margin-top:1rem}
label{font-size:.95rem;color:var(--muted)}
input{width:100%;padding:.9rem 1rem;border-radius:12px;border:1px solid var(--border);background:#0b1222;color:var(--text);outline:none}
input:focus{border-color:#334155;box-shadow:0 0 0 4px rgba(51,65,85,.35)}
button{padding:.9rem 1.1rem;border:none;border-radius:12px;background:linear-gradient(135deg,#16a34a,#22c55e);color:white;font-weight:700;cursor:pointer;transition:transform .05s}
button:active{transform:translateY(1px)}

.topbar{display:flex;justify-content:space-between;align-items:center;padding:1rem 1.25rem;border-bottom:1px solid var(--border);background:rgba(11,18,34,.65);backdrop-filter:blur(6px);position:sticky;top:0;z-index:10}
.brand{font-weight:800;letter-spacing:.5px}
.actions{display:flex;gap:.75rem;align-items:center}
.actions #obraSpan{color:var(--muted);font-size:.95rem}
.actions button{background:#ef4444;border-radius:10px;padding:.5rem .8rem}

.container{padding:1rem 1.25rem 2rem;max-width:1200px;margin-inline:auto}
.grid{display:grid;grid-template-columns:repeat(4,minmax(160px,1fr));gap:1rem}
.tile{display:grid;place-items:center;gap:.35rem;padding:1.25rem;border:1px solid var(--border);border-radius:18px;background:rgba(17,24,39,.6);cursor:pointer;transition:transform .08s, border-color .2s}
.tile:hover{transform:translateY(-1px);border-color:#334155}
.icon{font-size:2rem;display:grid;place-items:center}
.label{color:var(--muted)}

.viewer-section{display:grid;grid-template-columns:420px 1fr;gap:1rem;margin-top:1.25rem;min-height:70vh}
.list{border:1px solid var(--border);border-radius:16px;background:rgba(17,24,39,.6);padding:1rem}
.hint{font-size:.85rem;color:var(--muted);margin:.25rem 0 .75rem}
.file-list{list-style:none;margin:0;padding:0;display:grid;gap:.5rem;max-height:65vh;overflow:auto}
.file-list li{padding:.6rem .75rem;border:1px solid var(--border);border-radius:12px;display:flex;justify-content:space-between;align-items:center;gap:.5rem;background:#0b1222;cursor:pointer}
.file-list li:hover{border-color:#334155}
.file-list small{color:var(--muted)}

.viewer{border:1px solid var(--border);border-radius:16px;background:rgba(17,24,39,.6);display:grid;grid-template-rows:auto 1fr;min-height:65vh;overflow:hidden}
/* FIX: el iframe estaba oculto con display:none. Lo dejamos visible. */
#pdfViewer{width:100%;height:100%;border:0;display:block}
.empty{display:grid;place-items:center;color:var(--muted);font-size:1rem}
@media (max-width: 980px){
  .grid{grid-template-columns:repeat(2,1fr)}
  .viewer-section{grid-template-columns:1fr;grid-template-rows:auto auto}
}


/* ===== Tarjeta de Presentación del Cliente / Obra ===== */
.client-card{
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(17,24,39,.6);
  padding:0.9rem 1rem 1rem;
  margin-bottom:1rem;
}
.client-card__header{
  font-weight:700;
  margin-bottom:0.35rem;
}
.client-card__row{
  display:flex; gap:.5rem; font-size:.95rem; margin:.2rem 0;
}
.client-card__row span{ color:var(--muted); min-width:90px; }
.client-card__map{ margin-top:.5rem; border-radius:12px; overflow:hidden; border:1px solid var(--border); }
.client-card__map iframe{ width:100%; height:180px; border:0; display:block; }
.client-card__link{ display:inline-block; margin-top:.5rem; color:#93c5fd; font-size:.92rem; }
@media (max-width: 980px){
  .client-card__map iframe{ height:220px; }
}
/* ===== Fin Tarjeta de Presentación ===== */
.datetime {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  margin-right: 15px;
  font-size: 14px;
  color: #fff;
}

#reloj {
  font-weight: bold;
  font-size: 16px;
}

#fecha {
  font-size: 12px;
  opacity: 0.8;
}
/* Ajustes para pantallas pequeñas */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    padding: 10px;
  }

  .viewer-section {
    flex-direction: column;
  }

  .topbar {
    flex-wrap: wrap;
    justify-content: space-between;
    text-align: center;
  }

  .actions {
    flex-direction: column;
    align-items: center;
  }

  .datetime {
    margin: 5px 0;
  }

  iframe#pdfViewer {
    height: 60vh;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  button, .tile {
    font-size: 14px;
  }
}

/* Ajustes aún más compactos (móviles) */
@media (max-width: 480px) {
  h2, h3 {
    font-size: 1.1rem;
  }
  .brand {
    font-size: 1rem;
  }
  .datetime {
    font-size: 12px;
  }
}
.login-logo {
  display: block;
  margin: 0 auto 1rem auto;
  width: 140px;
  height: auto;
  border-radius: 10px;
}
/* === Botón flotante de WhatsApp === */
.whatsapp-float {
  position: fixed;
  width: 50px;
  height: 50px;
  bottom: 25px;
  right: 25px;
  background-color: #25d366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, background 0.3s ease;
  z-index: 9999;
}
.whatsapp-float img {
  width: 35px;
  height: 35px;
}
.whatsapp-float:hover {
  background-color: #1ebe5d;
  transform: scale(1.1);
}
/* === BOTÓN Y CHATBOT COMPLETOS === */
#chatbot-toggle {
  position: fixed;
  bottom: 95px;
  right: 25px;
  background: #25d366;
  color: #111;
  font-size: 24px;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10000;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s;
  animation: waveRobot 3s ease-in-out infinite;
}
#chatbot-toggle:hover { transform: scale(1.1); }

.robot-icon { width: 28px; height: 28px; }

/* Tooltip */
#chatbot-tooltip {
  position: absolute;
  right: 70px;
  bottom: 12px;
  background: #111;
  color: #fff;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#chatbot-tooltip.show { opacity: 1; transform: translateX(0); }

/* Ventana del chatbot */
#chatbot-container {
  position: fixed;
  bottom: 160px;
  right: 25px;
  width: 320px;
  background: #111;
  border: 1px solid #333;
  border-radius: 10px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
  z-index: 9999;
}
#chatbot-container.active { display: flex; }

#chatbot-header {
  background: #1e1e1e;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #333;
}
#chatbot-header img.chatbot-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
}

#chatbot-messages {
  padding: 10px;
  height: 250px;
  overflow-y: auto;
  color: #fff;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-msg, .bot-msg {
  padding: 8px 10px;
  border-radius: 8px;
  max-width: 80%;
  line-height: 1.4;
}
.user-msg { background: #333; align-self: flex-end; text-align: right; }
.bot-msg { background: #25d366; color: #111; align-self: flex-start; }

#chatbot-input {
  display: flex;
  padding: 8px;
  background: #000;
}
#chatbot-input input {
  flex: 1;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
}
#chatbot-input button {
  background: #25d366;
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  margin-left: 5px;
  cursor: pointer;
  transition: background 0.3s;
}
#chatbot-input button:hover { background: #1ebe5d; }

/* Animación del robot */
@keyframes waveRobot {
  0%,100%{transform:rotate(0deg)scale(1)}
  10%{transform:rotate(-10deg)scale(1.05)}
  20%{transform:rotate(10deg)scale(1.05)}
  30%{transform:rotate(-6deg)scale(1.05)}
  40%{transform:rotate(6deg)scale(1.05)}
  50%{transform:rotate(0deg)scale(1)}
}
/* === Pie de página profesional === */
#site-footer {
  background: #0d0d0d;
  color: #ccc;
  text-align: center;
  font-size: 13px;
  padding: 12px 0;
  margin-top: 20px;
  border-top: 1px solid #222;
  position: relative;
  z-index: 500;
}

#site-footer strong {
  color: #fff;
  font-weight: 600;
}

#site-footer p {
  margin: 0;
  line-height: 1.5;
}
/* ====== VISOR Y LISTA (mejor ajuste) ====== */
.viewer-section{
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1100px){
  .viewer-section{
    grid-template-columns: 1fr;
  }
}

.viewer{
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 12px;
  min-height: 520px;
}

#pdfViewer{
  width: 100%;
  height: 72vh;
  border: 0;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  display:block;
}

.file-list{
  max-height: 52vh;
  overflow: auto;
  padding-right: 6px;
}

.file-item{
  list-style: none;
  margin: 0 0 10px 0;
}
/* ====== BOTONES DE ARCHIVOS (azul/gris) ====== */
.file-btn{
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(60, 120, 200, 0.18);   /* azul gris */
  color: #eaf2ff;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}

.file-btn:hover{
  background: rgba(90, 140, 220, 0.28);
  border-color: rgba(160, 200, 255, 0.28);
  transform: translateY(-1px);
}

.file-btn:active{
  transform: translateY(0px);
}

.file-btn.is-active{
  background: rgba(90, 140, 220, 0.35);
  border-color: rgba(160, 200, 255, 0.40);
}