/* ============================================================
   style.css — Estilos globales
   Paleta: oscuro industrial / acentos ámbar y verde
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

/* ---- Variables ------------------------------------------ */
:root {
  --bg:         #0f1117;
  --surface:    #181c27;
  --surface2:   #1f2435;
  --border:     #2a3045;
  --text:       #d4daf0;
  --text-dim:   #6b7590;
  --accent:     #f5a623;        /* ámbar */
  --accent2:    #3ecf8e;        /* verde éxito */
  --accent3:    #5b8dee;        /* azul proceso */
  --danger:     #e05252;
  --phone1:     #5b8dee;
  --phoneDQ:    #b06ce4;
  --phoneCoke:  #e05252;
  --radius:     8px;
  --font-mono:  'IBM Plex Mono', monospace;
  --font-sans:  'IBM Plex Sans', sans-serif;
  --shadow:     0 2px 12px rgba(0,0,0,.45);
}

/* ---- Reset básico --------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 11px;
  outline: none;
  transition: border-color .2s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ---- Scrollbar ------------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Layout base ---------------------------------------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .04em;
}
.app-header .spacer { flex: 1; }
.day-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.day-selector select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 11px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 290px;
  max-width: min(48vw, 460px);
  padding-right: 34px;
  cursor: pointer;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  transition: all .18s;
  white-space: nowrap;
  max-width: 100%;
}
.btn-primary   { background: var(--accent);  color: #000; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost     { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-danger    { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 5px 8px; }

/* ---- Tabs (teléfonos) ----------------------------------- */
.tabs-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 9px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: all .18s;
  position: relative;
  bottom: -1px;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}
.tab-btn .tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
}
/* colores por teléfono */
.tab-btn[data-phone="phone1"] .tab-badge,
.tab-btn[data-phone="phone1"].active  { border-color: var(--phone1); }
.tab-btn[data-phone="phone1"].active  { color: var(--phone1); }
.tab-btn[data-phone="phoneDQ"].active { color: var(--phoneDQ); border-color: var(--phoneDQ); }
.tab-btn[data-phone="phoneCoke"].active { color: var(--phoneCoke); border-color: var(--phoneCoke); }
.badge-phone1  { background: rgba(91,141,238,.18); color: var(--phone1); }
.badge-phoneDQ { background: rgba(176,108,228,.18); color: var(--phoneDQ); }
.badge-phoneCoke { background: rgba(224,82,82,.18); color: var(--phoneCoke); }

/* ---- Panel de pestaña ----------------------------------- */
.tab-panel {
  display: none;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform: none; } }

/* ---- Links fijos ---------------------------------------- */
.fixed-links-panel {
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(245,166,35,.03);
}
.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-heading h2 {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.section-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(245,166,35,.16);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
}
.fixed-links-toolbar { margin-bottom: 10px; }
.fixed-link-item {
  border-color: rgba(245,166,35,.35);
}
.fixed-link-pin {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
  flex-shrink: 0;
}
.empty-state.compact {
  padding: 18px 12px;
}

/* ---- Barra de herramientas del panel -------------------- */
.panel-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-toolbar .url-input {
  flex: 1;
  min-width: 200px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.panel-toolbar .note-input { width: 180px; font-size: 12px; }
.primary-link-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 270px) auto auto auto;
  align-items: stretch;
}
.primary-link-toolbar .url-input,
.primary-link-toolbar .note-input {
  width: 100%;
  min-width: 0;
}
.primary-link-toolbar .btn {
  white-space: nowrap;
}
.paste-area {
  width: 100%;
  height: 80px;
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  display: none;
  margin-bottom: 0;
}
.paste-area.visible { display: block; }
.paste-actions-row {
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.text-capture-panel {
  display: none;
  grid-template-columns: minmax(220px, 360px) minmax(260px, 1fr);
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}
.text-capture-panel.visible { display: grid; }
.text-capture-panel .url-input {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.link-texts-paste {
  width: 100%;
  min-height: 92px;
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
}
.text-actions-row {
  margin-top: 0;
  margin-bottom: 12px;
}

/* ---- Progress bar del panel ----------------------------- */
.panel-progress {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent2);
  border-radius: 2px;
  transition: width .4s ease;
}
.progress-label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}
.progress-label.all-done { color: var(--accent2); font-weight: 600; }

/* ---- Lista de links ------------------------------------- */
.links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.link-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  transition: border-color .15s, opacity .2s;
  cursor: default;
}
.link-item:hover { border-color: var(--text-dim); }
.link-item.done {
  opacity: .5;
  background: var(--surface2);
}
.link-item.done .link-note,
.link-item.done .link-texts {
  display: none;
}
.link-item.in_progress {
  border-color: var(--accent3);
  background: rgba(91,141,238,.06);
}

/* drag handle */
.drag-handle {
  color: var(--border);
  cursor: grab;
  font-size: 16px;
  padding: 0 2px;
  user-select: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

/* status selector */
.status-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  position: relative;
  transition: all .18s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.status-btn.pending   { border-color: var(--border); }
.status-btn.in_progress { border-color: var(--accent3); color: var(--accent3); }
.status-btn.done      { border-color: var(--accent2); background: var(--accent2); color: #000; }

/* url display */
.link-url {
  flex: 1 1 280px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.link-url a { color: var(--text); }
.link-url a:hover { color: var(--accent); }
.link-note {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 4px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.text-count {
  color: var(--accent);
  background: rgba(245,166,35,.12);
}
.link-texts {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  margin: 8px 12px 0 76px;
  min-width: 0;
}
.link-text-chip {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  min-height: 34px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.link-text-chip:hover { border-color: var(--accent); }
.link-text-chip.used {
  opacity: .58;
  border-color: rgba(62,207,142,.45);
}
.link-text-chip span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}
.link-text-chip strong {
  color: var(--accent2);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  flex-shrink: 0;
}

/* actions */
.link-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .15s;
}
.link-item:hover .link-actions { opacity: 1; }

/* empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: 10px; }

/* ---- Modal ---------------------------------------------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(460px, 95vw);
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.modal .form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.modal label { font-size: 12px; color: var(--text-dim); }
.modal input, .modal select, .modal textarea { width: 100%; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---- Toast ---------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  animation: slideIn .2s ease;
  pointer-events: all;
}
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: none; } }

/* ---- Day manager sidebar / modal ------------------------ */
.day-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  font-family: var(--font-mono);
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat .val { font-size: 18px; font-weight: 600; }
.stat .lbl { color: var(--text-dim); }

/* ---- Responsive ≤ 768px -------------------------------- */
@media (max-width: 768px) {
  body { font-size: 13px; }

  input, textarea, select {
    min-height: 42px;
    font-size: 16px;
  }

  .app-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .app-header h1 {
    width: 100%;
    font-size: 14px;
  }

  .day-selector {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 44px;
    gap: 8px;
  }

  .day-selector select {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .day-selector .btn {
    min-height: 40px;
    justify-content: center;
  }

  .day-selector .btn-danger {
    padding-left: 0;
    padding-right: 0;
  }

  .tabs-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 8px 12px 0;
    gap: 6px;
    overflow: visible;
  }

  .tab-btn {
    min-width: 0;
    width: 100%;
    padding: 9px 12px;
    font-size: 12px;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
  }

  .tab-btn .tab-badge {
    display: block;
    width: max-content;
    margin: 4px auto 0;
    float: none;
  }

  .tab-panel {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    overflow-x: hidden;
  }

  .fixed-links-panel {
    padding: 12px;
    margin: -2px 0 14px;
    border: 1px solid rgba(245,166,35,.2);
    border-radius: var(--radius);
  }

  .section-heading { margin-bottom: 10px; }

  .panel-toolbar {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .primary-link-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .panel-toolbar .url-input,
  .panel-toolbar .note-input {
    width: 100%;
    min-width: 0;
  }

  .panel-toolbar .btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .paste-actions-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    margin-top: 8px;
  }

  .paste-actions-row[style*="none"] {
    display: none !important;
  }

  .primary-link-toolbar .url-input,
  .primary-link-toolbar .note-input {
    grid-column: 1 / -1;
  }

  .text-capture-panel {
    grid-template-columns: 1fr;
  }

  .text-capture-panel .url-input,
  .link-texts-paste {
    min-height: 42px;
    font-size: 16px;
  }

  .text-actions-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }

  .text-actions-row[style*="none"] {
    display: none !important;
  }

  .paste-area { min-height: 116px; }

  .panel-progress {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .progress-track {
    width: 100%;
    flex: none;
  }

  .progress-label { white-space: normal; }

  .links-list { gap: 8px; }

  .link-item {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    padding: 11px 12px;
  }

  .drag-handle,
  .fixed-link-pin,
  .status-btn {
    margin-top: 1px;
  }

  .fixed-link-pin {
    font-size: 11px;
    padding-top: 5px;
  }

  .link-url {
    flex: 1 1 calc(100% - 76px);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
  }
  .link-note {
    display: block;
    flex: 1 1 100%;
    max-width: none;
    white-space: normal;
    overflow-wrap: anywhere;
    margin-left: 38px;
  }

  .link-texts {
    margin-left: 0;
    grid-template-columns: 1fr;
  }

  .link-text-chip span {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .link-actions {
    width: 100%;
    justify-content: flex-end;
    opacity: 1;
  }

  .link-actions .btn {
    min-width: 40px;
    min-height: 36px;
    justify-content: center;
  }

  .empty-state { padding: 28px 14px; }
  .empty-state.compact { padding: 16px 12px; }

  .modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 18px;
    border-radius: 12px 12px 0 0;
  }

  .modal .modal-actions {
    flex-direction: column-reverse;
  }

  .modal .modal-actions .btn {
    width: 100%;
    min-height: 42px;
    justify-content: center;
  }

  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast { width: 100%; }
}

@media (max-width: 420px) {
  .day-selector { grid-template-columns: 1fr 1fr 40px; }
  .tabs-bar { grid-template-columns: 1fr; }
  .tab-btn {
    padding-left: 10px;
    padding-right: 10px;
    text-align: left;
  }
  .tab-btn .tab-badge {
    display: inline-block;
    margin: 0 0 0 8px;
  }
  .link-url { flex-basis: calc(100% - 68px); }
  .link-note { margin-left: 0; }
  .paste-actions-row,
  .text-actions-row {
    grid-template-columns: 1fr;
  }
}
