/* ─── DG Limpiezas App v2 — Design System ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --border: rgba(255, 255, 255, .1);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  /* Casa colors */
  --mirador: #3b82f6;
  --cason: #f59e0b;
  --gratal: #22c55e;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#page-container {
  min-height: 100dvh;
}

.page {
  padding: 16px 16px 24px;
  max-width: 520px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* ─── Loading ────────────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  z-index: 999;
  font-size: .9rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

/* ─── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: .95rem;
}

/* ─── Admin Nav ──────────────────────────────────────────────────────────── */
.admin-nav {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-nav::-webkit-scrollbar {
  display: none;
}

.admin-nav-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 100px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
  white-space: nowrap;
}

.admin-nav-btn.active {
  background: var(--primary);
  color: white;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 12px;
  color: var(--text);
}

.resumen-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}

.resumen-stat:last-child {
  border-bottom: none;
}

.resumen-stat .label {
  color: var(--text-muted);
}

/* ─── Step Progress ──────────────────────────────────────────────────────── */
.step-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0 20px;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: .2s;
}

.step-dot.done {
  background: var(--success);
}

.step-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.step-label {
  flex: 1;
  text-align: right;
  font-size: .75rem;
  color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: rgba(255, 255, 255, .07);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 8px 14px;
  font-size: .8rem;
  border-radius: 10px;
}

.w-full {
  width: 100%;
}

.btn-logout {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: .75rem;
  cursor: pointer;
  font-weight: 600;
}

.hdr-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: .78rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  transition: .15s;
  flex-shrink: 0;
}

.hdr-btn:hover {
  background: rgba(255, 255, 255, .06);
}

/* ─── Task Chips ─────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: rgba(255, 255, 255, .05);
  color: var(--text-muted);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  user-select: none;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--text);
}

.chip.chip-active {
  background: rgba(59, 130, 246, .18);
  border-color: var(--primary);
  color: var(--primary);
}

/* ─── Bottom Actions ─────────────────────────────────────────────────────── */
.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: rgba(15, 23, 42, .95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.notas {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  transition: .2s;
}

.form-input:focus,
.form-select:focus,
.notas:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(59, 130, 246, .08);
}

.form-select option {
  background: #1e293b;
}

.notas {
  resize: none;
  min-height: 80px;
  line-height: 1.5;
}

/* ─── Piso Cards ─────────────────────────────────────────────────────────── */
.piso-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.piso-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: .2s;
}

.piso-card.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, .1);
}

.piso-MIRADOR.selected {
  border-color: var(--mirador);
  background: rgba(59, 130, 246, .1);
}

.piso-CASON.selected {
  border-color: var(--cason);
  background: rgba(245, 158, 11, .1);
}

.piso-GRATAL.selected {
  border-color: var(--gratal);
  background: rgba(34, 197, 94, .1);
}

.piso-icon {
  font-size: 2rem;
}

.piso-info h3 {
  font-weight: 700;
  font-size: .95rem;
}

.piso-info p {
  color: var(--text-muted);
  font-size: .78rem;
}

/* ─── Personas Buttons ───────────────────────────────────────────────────── */
.personas-btn,
.suciedad-btn {
  background: rgba(255, 255, 255, .07);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
  flex: 1;
}

.personas-btn.selected,
.suciedad-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ─── Checklist ──────────────────────────────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: .15s;
}

.checklist-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checklist-item.done .checklist-check {
  background: var(--success);
  border-color: var(--success);
}

.checklist-item.done .checklist-check::after {
  content: '✓';
  color: white;
  font-size: .8rem;
  font-weight: 800;
}

.checklist-text {
  font-size: .9rem;
  transition: .15s;
}

.checklist-item.done .checklist-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ─── Progress Bar ───────────────────────────────────────────────────────── */
.progress-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 99px;
  transition: width .3s ease;
}

/* ─── Foto Grid ──────────────────────────────────────────────────────────── */
.foto-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.foto-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--border);
}

.foto-add-btn {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 2px;
  color: var(--text-muted);
  transition: .2s;
}

.foto-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.foto-add-btn .plus {
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
}

.foto-add-btn span:last-child {
  font-size: .65rem;
}

/* ─── Toggle switch ──────────────────────────────────────────────────────── */
.toggle-switch {
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: .2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: .2s;
}

.toggle-switch.on {
  background: var(--primary);
}

.toggle-switch.on::after {
  left: 23px;
}

/* ─── Data List ──────────────────────────────────────────────────────────── */
.data-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.data-row-main {
  flex: 1;
  min-width: 0;
}

.data-row-main h4 {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-row-main p {
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.4;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ok {
  background: rgba(34, 197, 94, .15);
  color: var(--success);
}

.badge-error {
  background: rgba(239, 68, 68, .15);
  color: #f87171;
}

.badge-pending {
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
}

/* ─── Stats Grid ─────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-card.success {
  border-color: rgba(34, 197, 94, .3);
}

.stat-card.danger {
  border-color: rgba(239, 68, 68, .4);
}

.stat-card .num {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-card .lbl {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Section Header ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  margin-top: 4px;
}

.section-header h2 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ─── Login PIN ──────────────────────────────────────────────────────────── */
.pin-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: .2s;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.1);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pin-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
  color: var(--text);
  font-family: inherit;
}

.pin-btn:active {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(.95);
}

.pin-btn.delete {
  color: var(--danger);
  font-size: 1rem;
}

/* ─── Misc ───────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: .9rem;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 600;
  max-width: 380px;
  animation: slideIn .25s ease;
  pointer-events: auto;
  box-shadow: var(--shadow);
}

.toast-success {
  background: rgba(34, 197, 94, .9);
  color: white;
}

.toast-error {
  background: rgba(239, 68, 68, .9);
  color: white;
}

.toast-info {
  background: rgba(59, 130, 246, .9);
  color: white;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(.95);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}