/* Navigation Elements */
.store-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.store-badge .store-icon {
  width: 22px;
  height: 22px;
  background: var(--p-action-primary);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
}
.nav-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--p-text-subdued);
  font-weight: 700;
  padding: 10px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #4a4d50;
  cursor: pointer;
  transition: background 0.12s ease;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--p-surface-hover);
  color: var(--p-text);
}
.nav-item.active {
  background: #e4e5e7;
  color: var(--p-text);
  font-weight: 600;
}
.nav-item .nav-count {
  font-size: 0.75rem;
  background: var(--p-border);
  color: #4a4d50;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* Conversation Items */
.conv-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--p-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conv-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
}
.conv-header .live-tag {
  font-size: 0.72rem;
  color: var(--p-action-primary);
  background: #e3f1df;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.conv-list {
  flex: 1;
  overflow-y: auto;
}
.conv-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--p-border-subdued);
  cursor: pointer;
  transition: background 0.15s ease;
}
.conv-item:hover {
  background: var(--p-surface-subdued);
}
.conv-item.active {
  background: var(--p-success-bg);
  border-left: 3px solid var(--p-action-primary);
}
.conv-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.conv-customer-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.conv-time {
  font-size: 0.75rem;
  color: var(--p-text-subdued);
}
.conv-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.conv-preview {
  font-size: 0.8rem;
  color: var(--p-text-subdued);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.badge-channel {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.badge-channel.web { background: #e0f2fe; color: #0284c7; }
.badge-channel.whatsapp { background: #dcfce7; color: #15803d; }
.badge-channel.instagram { background: #fce7f3; color: #be185d; }
.badge-unread {
  width: 8px;
  height: 8px;
  background: var(--p-action-primary);
  border-radius: 50%;
}

/* Chat Area & Semaphore */
.chat-topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--p-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-customer-title {
  font-size: 1.05rem;
  font-weight: 700;
}
.chat-customer-subtitle {
  font-size: 0.78rem;
  color: var(--p-text-subdued);
  margin-top: 2px;
}
.chat-semaphore-bar {
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--p-border);
  transition: all 0.2s ease;
}
.chat-semaphore-bar.bot-mode {
  background: var(--p-success-bg);
  border-color: var(--p-success-border);
}
.chat-semaphore-bar.human-mode {
  background: var(--p-critical-bg);
  border-color: var(--p-critical-border);
}
.semaphore-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.semaphore-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--p-action-primary);
}
.semaphore-dot.human {
  background: var(--p-critical);
}
.btn-control {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-control.takeover {
  background: #ffffff;
  color: var(--p-critical);
  border-color: var(--p-critical-border);
}
.btn-control.takeover:hover {
  background: var(--p-critical);
  color: #ffffff;
}
.btn-control.resume {
  background: #ffffff;
  color: var(--p-action-primary);
  border-color: var(--p-success-border);
}
.btn-control.resume:hover {
  background: var(--p-action-primary);
  color: #ffffff;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fafbfb;
}
.session-context-header {
  text-align: center;
  margin: 10px 0 20px;
}
.session-context-header .context-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}
.session-context-header .context-title {
  font-size: 0.86rem;
  font-weight: 600;
}
.session-context-header .context-subtitle {
  font-size: 0.76rem;
  color: var(--p-text-subdued);
}

.msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}
.msg-wrapper.customer { align-self: flex-start; }
.msg-wrapper.bot, .msg-wrapper.human { align-self: flex-end; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.msg-wrapper.customer .msg-bubble {
  background: #ffffff;
  color: var(--p-text);
  border: 1px solid var(--p-border);
  border-bottom-left-radius: 2px;
}
.msg-wrapper.bot .msg-bubble {
  background: var(--p-success-bg);
  color: #0d3824;
  border: 1px solid var(--p-success-border);
  border-bottom-right-radius: 2px;
}
.msg-wrapper.human .msg-bubble {
  background: var(--p-action-primary);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}
.msg-meta {
  font-size: 0.72rem;
  color: var(--p-text-subdued);
  margin-top: 4px;
  padding: 0 4px;
}
.msg-wrapper.bot .msg-meta, .msg-wrapper.human .msg-meta {
  text-align: right;
}

/* Composer Area */
.chat-composer {
  padding: 16px 20px;
  background: #ffffff;
  border-top: 1px solid var(--p-border);
}
.composer-inner {
  border: 1px solid #c9cccf;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.composer-inner:focus-within {
  border-color: var(--p-action-primary);
  box-shadow: 0 0 0 1px var(--p-action-primary);
}
.composer-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--p-text);
  min-height: 48px;
}
.composer-textarea:disabled {
  background: transparent;
  color: #8c9196;
  cursor: not-allowed;
}
.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--p-border-subdued);
  padding-top: 8px;
}
.quick-replies-tray {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.pill-btn {
  background: var(--p-surface-subdued);
  border: 1px solid var(--p-border);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 500;
  color: #4a4d50;
  cursor: pointer;
  white-space: nowrap;
}
.pill-btn:hover {
  background: var(--p-surface-hover);
  color: var(--p-text);
}
.btn-send-message {
  background: var(--p-action-primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-send-message:disabled {
  background: var(--p-border);
  color: #8c9196;
  cursor: not-allowed;
}

/* Barra de Herramientas Copiloto */
.copilot-toolbar {
  padding: 8px 20px;
  background: var(--p-surface-subdued);
  border-top: 1px solid var(--p-border);
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
}
.copilot-btn {
  padding: 5px 12px;
  background: #ffffff;
  border: 1px solid var(--p-border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--p-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.copilot-btn:hover {
  background: var(--p-surface-hover);
  border-color: #c9cccf;
}
.copilot-btn.primary {
  background: #f1f8f5;
  color: var(--p-action-primary);
  border-color: var(--p-success-border);
}
.copilot-btn.primary:hover {
  background: #e3f1df;
}

/* Modales Operativos */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  width: 90%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--p-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--p-text);
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--p-text-subdued);
}
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--p-text-subdued);
}
.form-group input, .form-group select {
  padding: 8px 12px;
  border: 1px solid var(--p-border);
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--p-text);
  outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--p-action-primary);
  box-shadow: 0 0 0 1px var(--p-action-primary);
}
.modal-footer {
  padding: 14px 20px;
  background: var(--p-surface-subdued);
  border-top: 1px solid var(--p-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-cancel {
  padding: 8px 16px;
  border: 1px solid var(--p-border);
  background: #ffffff;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-submit {
  padding: 8px 16px;
  border: none;
  background: var(--p-action-primary);
  color: #ffffff;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-submit:hover {
  background: var(--p-action-primary-hover);
}

/* Layout del Modal POS */
.modal-card.modal-pos {
  max-width: 780px;
  width: 95%;
}
.modal-pos-body {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  min-height: 330px;
}
.pos-column-form {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--p-border);
}
.btn-add-item {
  flex: 1;
  padding: 9px 14px;
  background: var(--p-surface-subdued);
  border: 1px solid var(--p-action-primary);
  color: var(--p-action-primary);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-add-item:hover {
  background: #f1f8f5;
}

/* Columna del Ticket */
.pos-column-ticket {
  padding: 18px 20px;
  background: #fcfdfe;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.pos-ticket-header {
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--p-border);
  padding-bottom: 8px;
}
.pos-ticket-items {
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pos-empty-state {
  text-align: center;
  font-size: 0.78rem;
  color: var(--p-text-subdued);
  margin-top: 40px;
}
.pos-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  background: #ffffff;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--p-border);
}
.pos-item-info {
  display: flex;
  flex-direction: column;
  max-width: 170px;
}
.pos-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pos-item-unit {
  font-size: 0.7rem;
  color: var(--p-text-subdued);
}
.pos-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pos-qty-badge {
  font-weight: 700;
  padding: 2px 6px;
  background: var(--p-surface-subdued);
  border-radius: 4px;
}
.pos-btn-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--p-critical);
  font-size: 0.85rem;
}

/* Totales */
.pos-ticket-summary {
  border-top: 1px dashed var(--p-border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--p-text-subdued);
}
.summary-line.discount {
  color: var(--p-action-primary);
  font-weight: 600;
}
.summary-line.total {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--p-text);
  border-top: 1px solid var(--p-border);
  padding-top: 6px;
  margin-top: 4px;
}

.chat-chip-btn {
  display: inline-block;
  margin: 4px 2px;
  padding: 3px 8px;
  background: #f0f7ff;
  color: #2c6ecb;
  border: 1px solid #cce4ff;
  border-radius: 12px;
  font-size: 0.73rem;
  font-weight: 600;
}