/* =========================================================================
   TeknTek 3D Projects – Estilos globales
   Cubre: visor público (/p/{slug}) y panel administrativo (/admin/).
   Identidad profesional, técnica y minimalista. Responsive, prioridad móvil.
   ========================================================================= */

:root {
  --bg:            #eef1f5;
  --viewer-bg:     #f4f6f9;
  --panel:         #ffffff;
  --ink:           #0f172a;
  --ink-soft:      #475569;
  --ink-faint:     #64748b;
  --line:          #d9dee6;
  --brand:         #0f766e;
  --brand-dark:    #0b5750;
  --danger:        #b91c1c;
  --danger-dark:   #991b1b;
  --warn:          #b45309;
  --ok:            #15803d;
  --shadow:        0 2px 10px rgba(15, 23, 42, 0.08);
  --radius:        12px;
}

* { box-sizing: border-box; }

/* ------------------------------- Marca ------------------------------- */
.brand__mark {
  display: inline-flex; align-items: baseline; gap: 1px;
  font-weight: 800; letter-spacing: 0.02em; font-size: 1.05rem; color: var(--ink);
}
.brand__accent {
  color: var(--brand); font-weight: 800;
  border: 2px solid var(--brand); border-radius: 6px;
  padding: 0 4px; margin-left: 4px; font-size: 0.85em; line-height: 1.3;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ======================================================================
   ============================ VISOR PÚBLICO ===========================
   ====================================================================== */

body.viewer-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.app-header__brand {
  display: inline-block; font-size: 0.72rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand);
}
.app-header__title {
  margin: 3px 0 0; font-size: 1.2rem; letter-spacing: 0.01em; font-weight: 700;
}
.app-header__subtitle { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-soft); }

/* Información dinámica del proyecto (visor público) */
.project-info {
  padding: 16px; max-width: 760px; margin: 0 auto; width: 100%;
}
.project-info__title {
  margin: 0 0 8px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint);
}
.project-info__desc  { margin: 0 0 8px; font-size: 0.95rem; color: var(--ink); line-height: 1.5; }
.project-info__notes { margin: 0; font-size: 0.86rem; color: var(--ink-soft); line-height: 1.5; }

.viewer {
  position: relative;
  flex: 1 1 auto;
  min-height: 62vh; min-height: 62dvh;
  background: var(--viewer-bg);
}
model-viewer {
  width: 100%; height: 100%; min-height: inherit;
  display: block; background-color: var(--viewer-bg);
  --poster-color: transparent;
  --progress-bar-color: var(--brand);
  outline: none;
}
.viewer:fullscreen, .viewer:-webkit-full-screen {
  width: 100vw; height: 100vh; background: var(--viewer-bg);
}
.viewer:fullscreen model-viewer, .viewer:-webkit-full-screen model-viewer { height: 100vh; }

/* Cargando */
.loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--viewer-bg); z-index: 5;
}
.loader__spinner {
  width: 42px; height: 42px;
  border: 4px solid rgba(15, 118, 110, 0.2); border-top-color: var(--brand);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader__text { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.loader__track {
  width: min(220px, 60%); height: 5px;
  background: rgba(15, 23, 42, 0.1); border-radius: 4px; overflow: hidden;
}
.loader__bar { height: 100%; width: 0%; background: var(--brand); transition: width 0.2s ease; }

/* Error */
.viewer-error {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 24px; background: var(--viewer-bg); z-index: 6;
}
.viewer-error__title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.viewer-error__hint  { margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.viewer-error__detail {
  margin: 6px 0 0; font-size: 0.78rem; color: var(--ink-faint);
  max-width: 90%; word-break: break-word;
}

/* Botones flotantes */
.viewer-tools {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 8px; z-index: 4;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(4px);
  color: var(--ink); font-size: 0.82rem; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, transform 0.1s ease;
}
.tool-btn:hover { background: #fff; }
.tool-btn:active { transform: scale(0.97); }
.tool-btn__icon { font-size: 1.05rem; line-height: 1; }
.tool-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand-dark); color: #fff; }

/* Ayuda */
.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  max-width: min(92%, 520px); padding: 9px 14px;
  background: rgba(15, 23, 42, 0.82); color: #fff; border-radius: 999px;
  z-index: 3; text-align: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.hint__text { margin: 0; font-size: 0.78rem; line-height: 1.3; }
.hint.is-hidden { opacity: 0; visibility: hidden; }

/* Nota de obra */
.site-note {
  padding: 16px; text-align: center;
  background: var(--panel); border-top: 1px solid var(--line);
}
.site-note__main { margin: 0 0 6px; font-weight: 800; letter-spacing: 0.04em; color: var(--warn); font-size: 0.92rem; }
.site-note__small { margin: 0 auto; max-width: 640px; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.4; }

.share-row { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.share-btn {
  padding: 10px 22px; min-height: 44px; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow); transition: background 0.15s ease, transform 0.1s ease;
}
.share-btn:hover { background: var(--brand-dark); }
.share-btn:active { transform: scale(0.97); }
.share-toast { font-size: 0.82rem; color: var(--brand-dark); font-weight: 600; }

.app-footer {
  margin-top: auto; padding: 14px 16px; text-align: center;
  font-size: 0.75rem; color: var(--ink-faint);
  background: var(--panel); border-top: 1px solid var(--line);
}

/* Página "no encontrado" */
.notfound {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
}
.notfound h1 { margin: 0; font-size: 1.4rem; }
.notfound p  { margin: 0; color: var(--ink-soft); }

/* ======================================================================
   ========================= PANEL ADMINISTRATIVO =======================
   ====================================================================== */

body.admin { background: var(--bg); }

.admin-header {
  padding: 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.admin-header .brand__mark { font-size: 1.15rem; }
.admin-header__titles { display: flex; flex-direction: column; }
.admin-header h1 { margin: 0; font-size: 1.25rem; }
.admin-header p  { margin: 3px 0 0; color: var(--ink-soft); font-size: 0.88rem; }

.admin-footer {
  padding: 16px; text-align: center; font-size: 0.78rem; color: var(--ink-faint);
  background: var(--panel); border-top: 1px solid var(--line);
}

.admin-main {
  max-width: 820px; margin: 0 auto; width: 100%;
  padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 20px;
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h2 { margin: 0 0 16px; font-size: 1.05rem; }

/* Campos */
.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field__opt { font-weight: 400; color: var(--ink-faint); }
.field input[type="text"],
.field textarea {
  width: 100%; padding: 11px 12px; font-size: 0.95rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  resize: vertical;
}
.field input[type="text"]:focus,
.field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: #fbfcfe; padding: 26px 16px; text-align: center; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.is-drag { border-color: var(--brand); background: rgba(15, 118, 110, 0.06); }
.dropzone__icon { font-size: 1.8rem; color: var(--brand); }
.dropzone__text { margin: 8px 0 0; font-size: 0.95rem; }
.dropzone__or   { margin: 6px 0; color: var(--ink-faint); font-size: 0.8rem; }
.dropzone__hint { margin: 10px 0 0; font-size: 0.76rem; color: var(--ink-faint); }

/* Info de archivo */
.file-info {
  margin-top: 12px; display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: #f1f5f9; border-radius: 8px; font-size: 0.85rem;
}
.file-info__name { font-weight: 600; word-break: break-all; }
.file-info__size { color: var(--ink-soft); white-space: nowrap; }

/* Progreso */
.progress { margin-top: 12px; height: 8px; background: rgba(15,23,42,0.1); border-radius: 6px; overflow: hidden; }
.progress__bar { height: 100%; width: 0%; background: var(--brand); transition: width 0.2s ease; }

.status { margin: 10px 0 0; font-size: 0.85rem; }
.status--info  { color: var(--ink-soft); }
.status--error { color: var(--danger); font-weight: 600; }
.status--ok    { color: var(--ok); font-weight: 600; }

.form-actions { margin-top: 16px; }

/* Botones genéricos */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; min-height: 42px; border-radius: 10px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; transition: background 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn--outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--outline:hover { background: #f8fafc; }
.btn--small { padding: 7px 12px; min-height: 38px; font-size: 0.8rem; background: #fff; border-color: var(--line); color: var(--ink); }
.btn--small:hover { background: #f8fafc; }
.btn--danger { color: var(--danger); border-color: #f1c9c9; }
.btn--danger:hover { background: #fef2f2; }

/* Resultado */
.result {
  margin-top: 18px; padding: 16px; border: 1px solid #bbf7d0;
  background: #f0fdf4; border-radius: var(--radius);
}
.result__title { margin: 0 0 8px; font-weight: 700; color: var(--ok); }
.result__label { margin: 0 0 4px; font-size: 0.8rem; color: var(--ink-soft); }
.result__url input {
  width: 100%; padding: 10px 12px; font-size: 0.88rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.result__actions { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Lista de proyectos */
.empty { color: var(--ink-faint); font-size: 0.9rem; }
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.project {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.project__info { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 240px; }
.project__name { font-weight: 700; font-size: 0.98rem; }
.project__desc { font-size: 0.82rem; color: var(--ink-soft); }
.project__meta { display: flex; flex-direction: column; gap: 2px; }
.project__meta code {
  font-size: 0.76rem; color: var(--ink-soft); word-break: break-all;
  background: #f1f5f9; padding: 2px 6px; border-radius: 5px; align-self: flex-start;
}
.project__stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.project__size { font-size: 0.74rem; color: var(--ink-soft); }
.project__date { font-size: 0.74rem; color: var(--ink-faint); }
.chip {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.chip--ok   { background: #dcfce7; color: var(--ok); }
.chip--warn { background: #fef3c7; color: var(--warn); }
.project__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.replacing { font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }
.replacing.ok { color: var(--ok); }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 560px) {
  .viewer { min-height: 70vh; min-height: 70dvh; }
  .tool-btn { padding: 0; width: 46px; height: 46px; justify-content: center; }
  .tool-btn__label { display: none; }
  .tool-btn__icon { font-size: 1.2rem; }

  .project { flex-direction: column; align-items: stretch; }
  .project__actions { justify-content: flex-start; }
  .project__actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .loader__spinner { animation: none; }
  .hint { transition: none; }
}
