/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #071526;
  --bg2:     #0d2040;
  --bg3:     #152b52;
  --accent:  #FF5C00;
  --blue:    #1a6fd4;
  --text:    #ffffff;
  --muted:   #7a9fc2;
  --radius:  10px;
  --shadow:  0 12px 40px rgba(0,0,0,0.6);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; }

/* ── Viewer Toggle ── */
.viewer-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg3);
  border: 1px solid #1a3a5c;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
}
.toggle-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 0.2rem;
  white-space: nowrap;
}
.toggle-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 5px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border-color: var(--accent);
}
.badge-test {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid #1a3a5c;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--accent);
}
.logo-area a {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.site-logo {
  height: 40px;
  width: 40px;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}
.logo-fallback {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

/* ── Gallery ── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.5rem;
}
.magazine-card {
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #1a3a5c;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.magazine-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.cover-wrap {
  width: 100%;
  height: 340px;
  overflow: hidden;
  background: #0d2040;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.magazine-info {
  padding: 0.75rem 1rem 1rem;
}
.magazine-info h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.magazine-info p {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Viewer ── */
.viewer-body {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-content {
  text-align: center;
}
.loading-content p {
  margin: 1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.viewer-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.viewer-header {
  background: var(--bg2);
  border-bottom: 1px solid #1a3a5c;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.back-btn {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--text); }
.viewer-header h2 {
  flex: 1;
  font-size: 0.98rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-counter {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.flipbook-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  overflow: auto;
  padding: 1rem;
}
.nav-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1;
}
.nav-btn:hover { background: rgba(255,255,255,0.14); }
#flipbook {
  transform-origin: center;
  transition: transform 0.2s ease;
}
.viewer-footer {
  background: var(--bg2);
  border-top: 1px solid #1a3a5c;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.zoom-btn {
  background: var(--bg3);
  border: 1px solid #1a3a5c;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.zoom-btn:hover { background: #1a3a5c; }

/* ── Viewer selector (upload form) ── */
.viewer-select-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.viewer-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg3);
  border: 1px solid #1a3a5c;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.viewer-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(255,92,0,0.08);
}
.viewer-option input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.viewer-option-label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.viewer-option-label strong {
  font-size: 0.92rem;
}
.viewer-option-label small {
  font-size: 0.78rem;
  color: var(--muted);
}
.badge-test-sm {
  background: #FF5C0022;
  color: #FF5C00;
  border: 1px solid #FF5C0055;
  border-radius: 3px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

/* ── Admin ── */
.admin-body { background: var(--bg); }
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth-box {
  background: var(--bg2);
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid #1a3a5c;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-box h2 { text-align: center; margin-bottom: 0.5rem; }
.auth-box input[type="password"] {
  background: var(--bg3);
  border: 1px solid #1e4070;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: white;
  font-size: 1rem;
  width: 100%;
}
.auth-box button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s;
}
.auth-box button:hover { opacity: 0.88; }
.admin-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}
.upload-section, .magazines-section {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid #1a3a5c;
  padding: 2rem;
}
.upload-section h2, .magazines-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.15rem;
}
.form-group { margin-bottom: 1.4rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.form-group input[type="text"] {
  background: var(--bg3);
  border: 1px solid #1e4070;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  color: white;
  font-size: 1rem;
  width: 100%;
  transition: border-color 0.15s;
}
.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.file-drop-zone {
  border: 2px dashed #1a3a5c;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s;
}
.file-drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(255,92,0,0.04);
}
.file-drop-zone p { font-size: 0.9rem; }
.file-drop-zone button {
  background: var(--bg3);
  border: 1px solid #2a4a6c;
  color: var(--text);
  padding: 0.5rem 1.4rem;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.file-drop-zone button:hover { background: #1a3a5c; }
.file-name {
  color: var(--accent);
  font-size: 0.88rem;
  margin-top: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 0.85rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.upload-progress { margin-bottom: 1.2rem; }
.upload-progress p { margin-top: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.upload-progress .progress-bar { width: 100%; }
.magazine-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--bg3);
  border-radius: 7px;
  margin-bottom: 0.6rem;
  border: 1px solid #1a3a5c;
}
.magazine-item-info { flex: 1; min-width: 0; }
.magazine-item-info h4 {
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.magazine-item-info p { font-size: 0.78rem; color: var(--muted); }
.btn-view {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid #1a3a5c;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.btn-view:hover { color: var(--text); border-color: #555; }
.btn-delete {
  background: transparent;
  border: 1px solid #5c1a1a;
  color: #f77;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-delete:hover { background: rgba(255,80,80,0.1); }

/* ── Shared ── */
.progress-bar {
  background: var(--bg3);
  border-radius: 100px;
  height: 4px;
  overflow: hidden;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #1a3a5c;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
.error { color: #f77; font-size: 0.85rem; }

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--muted);
}
.empty-state a {
  color: var(--accent);
  display: inline-block;
  margin-top: 1rem;
  text-decoration: none;
  font-size: 0.95rem;
}
.btn-admin {
  color: #000;
  background: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 5px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-admin:hover { opacity: 0.85; }

/* ── Gallery title ── */
.gallery-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  text-align: center;
}

/* ── Site footer ── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid #1a3a5c;
  text-align: center;
  padding: 0.9rem 1rem;
  font-size: 0.75rem;
  color: #3a5a7c;
}

/* ── Admin layout (two-column) ── */
.admin-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 64px);
}

/* ── Tenants panel (left) ── */
.tenants-panel {
  background: var(--bg2);
  border-right: 1px solid #1a3a5c;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}
.tenants-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tenants-panel-header h2 { font-size: 1rem; }
.btn-new-tenant {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 5px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-new-tenant:hover { opacity: 0.85; }
.tenants-list { display: flex; flex-direction: column; gap: 0.4rem; }

.tenant-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg3);
  border: 1px solid #1a3a5c;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tenant-card:hover { border-color: #2a4a7c; background: #1a3050; }
.tenant-card.active { border-color: var(--accent); background: rgba(255,92,0,0.07); }
.tenant-card-logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tenant-card-logo-placeholder {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #1a3a5c;
  flex-shrink: 0;
}
.tenant-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.tenant-card-info strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-card-info span { font-size: 0.75rem; color: var(--muted); }

/* ── Create tenant form ── */
.create-form {
  background: var(--bg3);
  border: 1px solid #1a3a5c;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.create-form h3 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.slug-preview { font-size: 0.75rem; color: var(--accent); margin-top: 0.3rem; }
.create-form-actions { display: flex; gap: 0.5rem; }
.create-form-actions .btn-primary { flex: 1; padding: 0.6rem; font-size: 0.88rem; }
.btn-cancel {
  background: transparent;
  border: 1px solid #1a3a5c;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-cancel:hover { border-color: #555; color: var(--text); }

/* ── Tenant detail (right) ── */
.tenant-detail {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}
.tenant-detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg2);
  border: 1px solid #1a3a5c;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.tenant-logo-wrap { flex-shrink: 0; }
.detail-logo {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1a3a5c;
}
.detail-logo-placeholder {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #152b52;
  border: 2px dashed #1a3a5c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--muted);
}
.tenant-detail-info { flex: 1; min-width: 0; }
.tenant-detail-info h2 { font-size: 1.2rem; margin-bottom: 0.25rem; }
.detail-url { font-size: 0.82rem; color: var(--accent); font-family: monospace; }

/* ── Admin sections ── */
.admin-section {
  background: var(--bg2);
  border: 1px solid #1a3a5c;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.admin-section h3 { font-size: 0.95rem; margin-bottom: 1rem; color: var(--muted); }
.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo-upload-row input[type="file"] {
  flex: 1;
  color: var(--muted);
  font-size: 0.88rem;
}
.logo-upload-row input[type="text"] {
  flex: 1;
  background: var(--bg3);
  border: 1px solid #1e4070;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  color: white;
  font-size: 0.95rem;
}
.upload-status { font-size: 0.85rem; margin-top: 0.6rem; color: var(--muted); }
.success-text  { color: #4ade80; }

/* ── Danger zone ── */
.danger-zone { border-color: #5c1a1a; }
.danger-zone h3 { color: #f77; }
.btn-delete-tenant {
  background: transparent;
  border: 1px solid #5c1a1a;
  color: #f77;
  padding: 0.5rem 1.2rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.btn-delete-tenant:hover { background: rgba(255,80,80,0.1); }

/* ── Responsive ── */

/* Tablet */
@media (max-width: 860px) {
  .admin-layout { grid-template-columns: 1fr; }
  .tenants-panel { border-right: none; border-bottom: 1px solid #1a3a5c; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.2rem; }
  .cover-wrap { height: 280px; }
}

/* Mobile */
@media (max-width: 600px) {
  /* Header compacto */
  header { padding: 0 1rem; }
  .header-inner { height: 54px; }
  .site-logo { height: 32px; width: 32px; }
  .gallery-title { font-size: 0.9rem; }
  .btn-admin { font-size: 0.75rem; padding: 0.35rem 0.7rem; }

  /* Galería: 2 columnas en móvil */
  main { padding: 1rem; }
  .gallery { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .cover-wrap { height: 220px; }
  .magazine-info { padding: 0.5rem 0.6rem 0.75rem; }
  .magazine-info h3 { font-size: 0.82rem; }
  .magazine-info p  { font-size: 0.7rem; }

  /* Visor */
  .tenant-detail { padding: 1rem; }
}

/* Móvil pequeño */
@media (max-width: 380px) {
  .gallery { grid-template-columns: 1fr; }
  .cover-wrap { height: 300px; }
}
