/* ── Ruta Manager - Shared styles ────────────────────────────────────────── */
:root {
  --bg: #0f1117;
  --surface: #1a1d28;
  --surface2: #232735;
  --border: #2e3346;
  --text: #e8eaed;
  --text-dim: #9aa0b0;
  --accent: #4f9eff;
  --accent2: #00c853;
  --warn: #ffab40;
  --danger: #ff5252;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Public form ─────────────────────────────────────────────────────────── */
.form-page {
  max-width: 520px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.form-page h1 { margin-bottom: 1.5rem; font-size: 1.4rem; text-align: center; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .3rem; color: var(--text-dim); font-size: .85rem; }
.form-group input, .form-group textarea {
  width: 100%; padding: .6rem .8rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: .95rem;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); outline: none; }
.btn {
  padding: .6rem 1.2rem; border: none; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-weight: 600; transition: .15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-success { background: var(--accent2); color: white; }
.btn-warn { background: var(--warn); color: #1a1d28; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.alert {
  padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}
.alert-success { background: rgba(0,200,83,.15); border: 1px solid var(--accent2); }

/* ── Admin panel ─────────────────────────────────────────────────────────── */
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.admin-header h1 { font-size: 1.2rem; }
.admin-header-actions { display: flex; gap: .5rem; align-items: center; }

.admin-grid {
  display: grid; grid-template-columns: 340px 1fr; gap: 1rem; padding: 1rem;
  max-height: calc(100vh - 64px); overflow: hidden;
}

.panel {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-header {
  padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}

/* Client search */
.search-box {
  padding: .5rem 1rem; border-bottom: 1px solid var(--border);
}
.search-box input {
  width: 100%; padding: .5rem .7rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: .9rem;
}
.client-scroll { flex: 1; overflow-y: auto; padding: .5rem; }
.client-card {
  padding: .6rem .8rem; margin-bottom: .4rem; background: var(--surface2);
  border-radius: 8px; cursor: pointer; transition: .1s; border: 1px solid transparent;
}
.client-card:hover { border-color: var(--accent); }
.client-card .cc-name { font-weight: 600; font-size: .9rem; }
.client-card .cc-addr { color: var(--text-dim); font-size: .8rem; margin-top: .15rem; }
.client-card .cc-zone {
  display: inline-block; font-size: .7rem; padding: .1rem .4rem; border-radius: 4px;
  background: rgba(79,158,255,.15); color: var(--accent); margin-top: .2rem;
}

/* Route stops */
.route-stops { flex: 1; overflow-y: auto; padding: .5rem; }
.stop-card {
  display: flex; align-items: flex-start; gap: .6rem; padding: .6rem .8rem;
  margin-bottom: .5rem; background: var(--surface2); border-radius: 8px;
  border: 1px solid var(--border); transition: .15s;
}
.stop-card:hover { border-color: var(--accent); }
.stop-card.done { opacity: .5; }
.stop-card.done .stop-name { text-decoration: line-through; }
.stop-num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: white; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: .8rem;
}
.stop-card.done .stop-num { background: var(--accent2); }
.drag-handle {
  flex-shrink: 0; width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  color: var(--text-dim); cursor: grab; font-size: 1rem;
  user-select: none; border-radius: 4px;
}
.drag-handle:hover { background: var(--bg); color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.stop-card.dragging { opacity: .4; border-color: var(--accent); }
.stop-card.drag-over-top { border-top: 2px solid var(--accent); }
.stop-info { flex: 1; min-width: 0; }
.stop-name { font-weight: 600; font-size: .9rem; }
.stop-addr { color: var(--text-dim); font-size: .8rem; margin-top: .1rem; }
.stop-refs { color: var(--text-dim); font-size .75rem; margin-top: .15rem; font-style: italic; }
.stop-instr { font-size: .8rem; color: var(--warn); margin-top: .15rem; }
.stop-type {
  display: inline-block; font-size: .7rem; padding: .1rem .4rem; border-radius: 4px;
  margin-left: .3rem;
}
.stop-type.entregar { background: rgba(79,158,255,.2); color: var(--accent); }
.stop-type.recoger { background: rgba(255,171,64,.2); color: var(--warn); }
.stop-actions { display: flex; flex-direction: column; gap: .2rem; }
.stop-actions a, .stop-actions button {
  font-size: .75rem; padding: .2rem .4rem; border-radius: 4px; border: none;
  cursor: pointer; background: var(--bg); color: var(--text); text-decoration: none;
  text-align: center;
}
.stop-actions a:hover { color: var(--accent); }

/* Zone group */
.zone-group { margin-bottom: 1rem; }
.zone-group h3 {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dim); margin-bottom: .4rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}

/* Bottom panel */
.bottom-panel {
  grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 0 1rem 1rem;
}
.wa-box, .pending-box {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 1rem;
}
.wa-box textarea, .import-textarea {
  width: 100%; padding: .5rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .85rem; resize: vertical; min-height: 60px;
}
.wa-result { margin-top: .5rem; font-size: .85rem; }

.pending-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem .8rem; background: var(--surface2); border-radius: 8px; margin-bottom: .4rem;
}
.pending-card .pc-info { flex: 1; }
.pending-card .pc-info b { font-size: .9rem; }
.pending-card .pc-info small { display: block; color: var(--text-dim); font-size: .8rem; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.7); z-index: 100; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 1.5rem; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 1rem; }
.modal textarea {
  width: 100%; min-height: 200px; padding: .5rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: .85rem;
}
.modal-actions { display: flex; gap: .5rem; margin-top: 1rem; }

/* ── Messenger view (mobile) ─────────────────────────────────────────────── */
.ruta-page { max-width: 500px; margin: 0 auto; padding: 1rem; }
.ruta-header { text-align: center; padding: 1rem 0; }
.ruta-header h1 { font-size: 1.3rem; }
.ruta-header .fecha { color: var(--text-dim); font-size: .9rem; }
.mstop-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 1rem; margin-bottom: .8rem;
}
.mstop-card.done { opacity: .5; border-color: var(--accent2); }
.mstop-card.done .mstop-name { text-decoration: line-through; }
.mstop-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.mstop-num {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: white;
}
.mstop-num.entregar { background: var(--accent); }
.mstop-num.recoger { background: var(--warn); color: #1a1d28; }
.mstop-num.done { background: var(--accent2); }
.mstop-name { font-weight: 700; font-size: 1rem; }
.mstop-addr { color: var(--text); font-size: .9rem; margin-bottom: .3rem; }
.mstop-refs { color: var(--text-dim); font-size: .85rem; margin-bottom: .3rem; font-style: italic; }
.mstop-instr { color: var(--warn); font-size: .85rem; margin-bottom: .5rem; }
.mstop-contact { color: var(--text-dim); font-size: .85rem; margin-bottom: .5rem; }
.mstop-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.mstop-actions a, .mstop-actions button {
  flex: 1; padding: .5rem; text-align: center; border-radius: 8px; font-size: .85rem;
  border: none; cursor: pointer; text-decoration: none; min-width: 100px;
}
.btn-maps { background: var(--accent); color: white; }
.btn-wa { background: var(--accent2); color: white; }
.btn-done { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-done.is-done { background: var(--accent2); color: white; border-color: var(--accent2); }

@media (max-width: 768px) {
  .admin-grid { grid-template-columns: 1fr; }
  .bottom-panel { grid-template-columns: 1fr; }
}
