/* ============================================
   RECICLAJE INTELIGENTE — PWA v2
   Clean, professional, mobile-first
   ============================================ */

:root {
  --green-900: #354F10;
  --green-800: #486A1B;
  --green-700: #668F24;
  --green-600: #7CA927;
  --green-500: #87BB2A;
  --green-400: #A3CD54;
  --green-300: #B8DC86;
  --green-200: #D2E8B1;
  --green-100: #E4F1D1;
  --green-50:  #F1F8E9;

  --dark-green: #354F10;
  --text-dark:  #263238;
  --text-mid:   #546E7A;
  --text-light: #90A4AE;

  --gray-50:  #FAFAFA;
  --gray-100: #F8FAF5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;

  --red-500: #E53935;
  --red-50:  #FFEBEE;
  --amber-600: #FFB300;
  --amber-50:  #FFF8E1;

  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --font: 'Nunito', system-ui, -apple-system, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--text-dark);
  height: 100%;
  scroll-padding-top: var(--safe-top);
}

body {
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden { display: none !important; }

/* ─── SCREENS ──────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active { display: flex; flex-direction: column; }

/* ─── OFFLINE BAR ──────────────────── */
.offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--amber-600);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.3s ease;
}
.offline-bar.hidden { transform: translateY(-100%); }

/* ─── SPLASH / LOGIN ──────────────── */
.splash-bg {
  position: relative;
  background: linear-gradient(145deg, var(--green-800) 0%, var(--dark-green) 100%);
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.splash-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(76,175,80,0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(129,199,132,0.2) 0%, transparent 50%);
}

.splash-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 24px;
}

.splash-logo {
  width: 240px;
  max-width: 70vw;
  height: auto;
  filter: brightness(0) invert(1);
  margin-bottom: 8px;
}

.splash-slogan {
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

.login-sheet {
  flex: 1;
  background: #fff;
  border-radius: 28px 28px 0 0;
  margin-top: -24px;
  position: relative;
  z-index: 2;
  padding: 32px 24px 40px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.login-form {
  max-width: 400px;
  margin: 0 auto;
}

/* ─── INPUTS ──────────────────────── */
.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-light);
  pointer-events: none;
}

.input-wrap input,
.input-wrap select {
  padding-left: 44px;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  background: #fff;
  color: var(--text-dark);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.15);
}

input::placeholder {
  color: var(--text-light);
  font-weight: 400;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23546E7A' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ─── BUTTONS ─────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-primary {
  background: var(--green-800);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46,125,50,0.35);
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(46,125,50,0.3);
}
.btn-primary:disabled {
  background: var(--gray-400);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-submit {
  margin-top: 8px;
  margin-bottom: 16px;
}

.btn-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-mid);
  padding: 16px;
  cursor: pointer;
  text-align: center;
}
.btn-link strong { color: var(--green-800); }

/* ─── APP HEADER ──────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  height: 36px;
  width: auto;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-dark);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-mid);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.header-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
}

.header-badge {
  background: var(--green-50);
  color: var(--green-800);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  border: 1px solid var(--green-200);
}

/* ─── SCREEN BODY ─────────────────── */
.screen-body {
  flex: 1;
  padding: 20px 16px 120px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.screen-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

/* ─── CARDS ───────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

/* ─── STEP CARDS ──────────────────── */
.step-card {
  padding: 20px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green-800);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.3;
}

/* ─── OPTION CARDS (radio) ────────── */
.option-grid {
  display: grid;
  gap: 10px;
}
.option-grid.four-cols { grid-template-columns: repeat(4, 1fr); }
.option-grid.two-cols { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 380px) {
  .option-grid.four-cols { grid-template-columns: repeat(2, 1fr); }
}

.option-card {
  cursor: pointer;
}

.option-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 12px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: all 0.15s ease;
  min-height: 90px;
  justify-content: center;
}

.option-check {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-600);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.option-icon {
  width: 36px;
  height: 36px;
  color: var(--text-mid);
  transition: color 0.15s;
}

.option-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mid);
  text-align: center;
  line-height: 1.2;
  transition: color 0.15s;
}

/* Selected state */
.option-card input:checked + .option-visual {
  border-color: var(--green-600);
  background: var(--green-50);
}

.option-card input:checked + .option-visual .option-check {
  opacity: 1;
  transform: scale(1);
}

.option-card input:checked + .option-visual .option-icon {
  color: var(--green-800);
}

.option-card input:checked + .option-visual .option-text {
  color: var(--green-900);
}

.option-card:active .option-visual {
  transform: scale(0.96);
}

/* ─── PHOTO SECTION ───────────────── */
.photo-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  background: var(--gray-50);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: all 0.15s;
}

.photo-btn:active {
  background: var(--green-50);
  border-color: var(--green-300);
}

.photo-btn-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green-50);
  color: var(--green-700);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--green-200);
}

.photo-btn-text strong {
  display: block;
  font-size: 15px;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.photo-btn-text small {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.photo-preview {
  position: relative;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--green-500);
}

.photo-preview img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.btn-remove-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── GPS STATUS ──────────────────── */
.gps-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mid);
}

.gps-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.gps-dot.loading { background: var(--amber-600); animation: pulse 1.2s ease infinite; }
.gps-dot.ok { background: var(--green-500); }
.gps-dot.error { background: var(--red-500); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── COUNTER BAR ─────────────────── */
.counter-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--green-900);
  color: #fff;
  padding: 14px 24px;
  padding-bottom: calc(14px + var(--safe-bottom));
  display: flex;
  justify-content: space-between;
  z-index: 100;
  font-size: 14px;
  font-weight: 600;
}

.counter-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── CONFIRMACIÓN ────────────────── */
#screen-confirmacion {
  background: #fff;
}

.confirm-container {
  text-align: center;
  padding: 20vh 24px 40px;
  max-width: 400px;
  margin: 0 auto;
}

.confirm-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--green-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  animation: popIn 0.4s ease-out;
  box-shadow: 0 8px 24px rgba(76,175,80,0.35);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.confirm-container h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--green-800);
  margin-bottom: 8px;
}

.confirm-container p {
  color: var(--text-mid);
  font-size: 16px;
  margin-bottom: 36px;
}

/* ─── TOAST ───────────────────────── */
.toast {
  position: fixed;
  bottom: 70px;
  left: 16px;
  right: 16px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  z-index: 9000;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.toast.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
.toast.success { background: var(--green-800); color: #fff; }
.toast.error { background: var(--red-500); color: #fff; }
.toast.info { background: var(--text-dark); color: #fff; }

/* ─── ERROR / SUCCESS ─────────────── */
.error-msg {
  margin-top: 14px;
  padding: 14px;
  background: var(--red-50);
  color: #C62828;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: 1px solid #FFCDD2;
}

.success-msg {
  margin-top: 14px;
  padding: 14px;
  background: var(--green-50);
  color: var(--green-900);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--green-200);
}

/* ─── LOADING STATE ───────────────── */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── OFFLINE ADDITIONS v3 ────────── */

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.conn-dot.online { background: #4CAF50; box-shadow: 0 0 6px rgba(76,175,80,0.5); }
.conn-dot.offline { background: #E53935; box-shadow: 0 0 6px rgba(229,57,53,0.5); }

.btn-sync-manual {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s;
}
.btn-sync-manual:active {
  background: rgba(255,255,255,0.15);
}
.btn-sync-manual.syncing svg {
  animation: spin 1s linear infinite;
}

/* ===== RUTAS RI v4.2.2 | UNA TARJETA, UNA FILA FLEX ===== */
#screen-recoleccion .screen-body { padding-top: 28px; }
#screen-recoleccion .screen-title { display:block; margin: 0 0 34px; line-height:1.25; }
#screen-recoleccion .category-help { font-size:14px; line-height:1.55; color:#5D6F4D; margin:4px 0 20px; }
#screen-recoleccion .category-options { display:flex; flex-direction:column; gap:12px; width:100%; }
/* Label itself holds a radio and exactly one visible row */
#screen-recoleccion label.category-card {
  position:relative; display:block !important; width:100%; min-width:0; padding:0 !important;
  margin:0 !important; border:0 !important; background:transparent !important;
  box-shadow:none !important; cursor:pointer;
}
#screen-recoleccion label.category-card > input[type="radio"] {
  position:absolute !important; width:1px !important; height:1px !important;
  padding:0 !important; margin:0 !important; opacity:0 !important;
  border:0 !important; pointer-events:none; clip-path:inset(50%);
}
#screen-recoleccion label.category-card > .category-row {
  box-sizing:border-box; width:100%; min-width:0; display:flex !important;
  flex-direction:row !important; flex-wrap:nowrap !important;
  align-items:center !important; justify-content:flex-start !important; gap:12px;
  min-height:78px; padding:13px; background:#fff; border:2px solid #DCE5D3;
  border-radius:14px; transition:background .15s,border-color .15s;
}
#screen-recoleccion .category-row > .category-icon {
  display:flex !important; flex:0 0 44px !important; align-items:center; justify-content:center;
  width:44px !important; height:44px; border-radius:11px; background:#E4F1D1;
  color:#486A1B; font-size:25px; line-height:1; font-weight:700;
}
#screen-recoleccion .category-row > .category-content {
  display:flex !important; flex:1 1 0% !important; flex-direction:column !important;
  align-items:flex-start; gap:4px; width:auto !important; min-width:0 !important;
  margin:0 !important; padding:0 !important;
}
#screen-recoleccion .category-row > .category-content > strong {
  display:block; width:100%; color:#354F10; font-size:16px; line-height:1.25; font-weight:800;
}
#screen-recoleccion .category-row > .category-content > small {
  display:block; width:100%; color:#52634A; font-size:12.5px; line-height:1.45; font-weight:500;
}
#screen-recoleccion .category-row > .category-select {
  display:block !important; flex:0 0 21px !important; width:21px !important;
  height:21px; margin:0 0 0 auto !important; border:2px solid #AAB9A0;
  border-radius:50%; background:#fff;
}
#screen-recoleccion label.category-card > input:checked + .category-row {
  background:#F0F8E4; border-color:#87BB2A;
  box-shadow:0 0 0 2px rgba(135,187,42,.10);
}
#screen-recoleccion label.category-card > input:checked + .category-row > .category-select {border:6px solid #719E22;}
#screen-recoleccion label.category-card > input:checked + .category-row > .category-icon {background:#D6ECB4;}
#screen-recoleccion label.category-card > input:focus-visible + .category-row {outline:3px solid #456A1B; outline-offset:2px;}
@media(max-width:380px){
 #screen-recoleccion label.category-card > .category-row {gap:10px; padding:11px;}
 #screen-recoleccion .category-row > .category-icon {width:40px !important; flex-basis:40px !important; height:40px; font-size:23px;}
 #screen-recoleccion .category-row > .category-content > strong {font-size:15px;}
 #screen-recoleccion .category-row > .category-content > small {font-size:12px;}
}
button.counter-item { cursor:pointer; color:inherit; background:transparent; border:0; font:inherit; }
.pending-modal { position:fixed; inset:0; z-index:20000; display:flex; align-items:flex-end; background:rgba(13,29,8,.65); }
.pending-panel { width:100%; max-height:85vh; overflow:auto; border-radius:22px 22px 0 0; padding:24px 18px calc(20px + var(--safe-bottom)); background:#F8FAF5; }
.pending-head { display:flex; justify-content:space-between; gap:10px; align-items:center; }
.pending-head h2 { font-size:20px; color:#354F10; }
.pending-head button { border:0; background:#E4F1D1; border-radius:50%; width:38px; height:38px; font-size:20px; }
.pending-intro { font-size:13px; line-height:1.45; color:#52634A; margin:8px 0 15px; }
.pending-row { display:flex; flex-direction:column; gap:5px; padding:12px; background:#fff; border:1px solid #DAE5D0; border-radius:12px; margin-bottom:9px; }
.pending-row small { color:#566150; overflow-wrap:anywhere; }
.pending-empty { padding:18px 0; color:#52634A; }
#retry-pending { margin-top:15px; }
