/**
 * Andarurales Chat – Styles v1.1.0
 * Prefixed with .ar-chat- to avoid theme conflicts.
 */

/* =========================================================
   CSS Variables (Andarurales palette)
   ========================================================= */
:root {
  --ar-green: #274c30;
  --ar-green-dark: #1b3521;
  --ar-green-light: #e8f2ea;
  --ar-yellow: #f6bf39;
  --ar-yellow-dark: #d9a81e;
  --ar-yellow-light: #fef9ec;
  --ar-text: #2c2c2c;
  --ar-text-light: #666;
  --ar-border: #dce3dc;
  --ar-white: #fff;
  --ar-bubble-size: 56px;
  --ar-panel-w: 370px;
  --ar-panel-h: 500px;
  --ar-radius: 14px;
  --ar-shadow: 0 10px 40px rgba(39, 76, 48, 0.22);
  --ar-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ar-z: 99990;
}

/* =========================================================
   Floating widget wrapper
   ========================================================= */
.ar-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ar-z);
  font-family: var(--ar-font);
}

/* =========================================================
   Bubble button
   ========================================================= */
.ar-chat-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ar-bubble-size);
  height: var(--ar-bubble-size);
  border-radius: 50%;
  background: var(--ar-green);
  color: var(--ar-white);
  border: 3px solid var(--ar-yellow);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(39, 76, 48, 0.45);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
}

.ar-chat-bubble:hover,
.ar-chat-bubble:focus-visible {
  background: var(--ar-green-dark);
  transform: scale(1.07);
  box-shadow: 0 6px 24px rgba(39, 76, 48, 0.55);
  outline: 2px solid var(--ar-yellow);
  outline-offset: 2px;
}

.ar-chat-bubble svg { pointer-events: none; }

/* Badge */
.ar-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--ar-yellow);
  color: var(--ar-green-dark);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--ar-white);
}

/* =========================================================
   Chat panel
   ========================================================= */
.ar-chat-panel {
  position: fixed;
  bottom: calc(24px + var(--ar-bubble-size) + 14px);
  right: 24px;
  width: var(--ar-panel-w);
  height: var(--ar-panel-h);
  background: var(--ar-white);
  border-radius: var(--ar-radius);
  box-shadow: var(--ar-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  border: 1px solid rgba(39, 76, 48, 0.12);
  z-index: 99995;
}

.ar-chat-panel.ar-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* =========================================================
   Panel – Header
   ========================================================= */
.ar-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--ar-green);
  color: var(--ar-white);
  flex-shrink: 0;
  border-bottom: 3px solid var(--ar-yellow);
}

.ar-chat-header__info { flex: 1; }
.ar-chat-header__title { font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.ar-chat-header__sub { font-size: 11px; opacity: 0.8; margin-top: 1px; }

.ar-chat-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ar-white);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s;
}

.ar-chat-close:hover { background: rgba(246,191,57,0.25); }

/* =========================================================
   Panel – Body (messages)
   ========================================================= */
.ar-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #f7faf7;
}

.ar-chat-body::-webkit-scrollbar { width: 5px; }
.ar-chat-body::-webkit-scrollbar-track { background: transparent; }
.ar-chat-body::-webkit-scrollbar-thumb { background: var(--ar-border); border-radius: 4px; }

/* =========================================================
   Messages
   ========================================================= */
.ar-chat-msg {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ar-chat-msg--mine { align-self: flex-end; align-items: flex-end; }
.ar-chat-msg--theirs { align-self: flex-start; align-items: flex-start; }

.ar-chat-msg__sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--ar-green);
  padding: 0 2px;
}

.ar-chat-msg__bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.ar-chat-msg--mine .ar-chat-msg__bubble {
  background: var(--ar-green);
  color: var(--ar-white);
  border-bottom-right-radius: 4px;
}

.ar-chat-msg--theirs .ar-chat-msg__bubble {
  background: var(--ar-white);
  color: var(--ar-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--ar-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ar-chat-msg__meta {
  font-size: 11px;
  color: var(--ar-text-light);
  padding: 0 2px;
}

/* =========================================================
   Panel – Footer (input)
   ========================================================= */
.ar-chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--ar-border);
  background: var(--ar-white);
  flex-shrink: 0;
}

.ar-chat-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--ar-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--ar-font);
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s;
  background: #f7faf7;
}

.ar-chat-input:focus {
  border-color: var(--ar-green);
  background: var(--ar-white);
}

.ar-chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--ar-yellow);
  color: var(--ar-green-dark);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  font-weight: 700;
}

.ar-chat-send:hover { background: var(--ar-yellow-dark); transform: scale(1.05); }
.ar-chat-send:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* =========================================================
   CTA – Not logged in
   ========================================================= */
.ar-chat-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  padding: 24px;
  text-align: center;
}

.ar-chat-cta p { font-size: 14px; color: var(--ar-text); margin: 0; }
.ar-chat-cta__actions { display: flex; gap: 10px; }

.ar-chat-cta .btn-andar,
.ar-chat-cta a {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}

.ar-chat-cta .btn-andar { background: var(--ar-green); color: var(--ar-white); }
.ar-chat-cta .btn-andar:hover { background: var(--ar-green-dark); }
.ar-chat-cta .btn-andar--outline { background: transparent; color: var(--ar-green); border: 2px solid var(--ar-green); }
.ar-chat-cta .btn-andar--outline:hover { background: var(--ar-green-light); }

/* =========================================================
   Loading / info states
   ========================================================= */
.ar-chat-loading { text-align: center; color: var(--ar-text-light); font-size: 13px; padding: 20px; }

.ar-chat-notice {
  font-size: 13px;
  color: var(--ar-text-light);
  text-align: center;
  padding: 12px 16px;
  background: var(--ar-green-light);
  border-radius: 8px;
  border-left: 3px solid var(--ar-green);
}

.ar-chat-error {
  font-size: 13px;
  color: #c53030;
  text-align: center;
  padding: 8px 12px;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 6px;
}

/* =========================================================
   My Account – Stats (profesionales)
   ========================================================= */
.ar-chat-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ar-chat-stat-card {
  background: var(--ar-white);
  border: 1.5px solid var(--ar-border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.ar-chat-stat-card__value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ar-green);
  line-height: 1;
}

.ar-chat-stat-card__label {
  font-size: 12px;
  color: var(--ar-text-light);
  margin-top: 6px;
  font-weight: 600;
}

.ar-chat-stat-card--accent {
  background: var(--ar-green);
  border-color: var(--ar-green);
}

.ar-chat-stat-card--accent .ar-chat-stat-card__value { color: var(--ar-yellow); }
.ar-chat-stat-card--accent .ar-chat-stat-card__label { color: rgba(255,255,255,0.85); }

/* =========================================================
   My Account – Inbox
   ========================================================= */
.ar-chat-inbox-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 3px solid var(--ar-yellow);
  padding-bottom: 10px;
}

.ar-chat-inbox-header h2 { margin: 0; color: var(--ar-green); }

.ar-chat-inbox-list { display: flex; flex-direction: column; gap: 10px; }

.ar-chat-inbox-row {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--ar-border);
  border-radius: var(--ar-radius);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
  background: var(--ar-white);
}

.ar-chat-inbox-row:hover {
  box-shadow: 0 2px 16px rgba(39, 76, 48, 0.14);
  border-color: var(--ar-green);
}

.ar-chat-inbox-row.ar-has-unread {
  background: var(--ar-yellow-light);
  border-color: var(--ar-yellow);
}

.ar-chat-inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ar-text);
  flex: 1;
  min-width: 0;
}

.ar-chat-inbox-item__main { flex: 1; min-width: 0; }

.ar-chat-inbox-item__name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ar-green);
}

.ar-chat-inbox-item__client {
  font-size: 12px;
  color: var(--ar-text-light);
  margin-top: 2px;
  font-weight: 600;
}

.ar-chat-inbox-item__meta { font-size: 12px; color: var(--ar-text-light); margin-top: 3px; }

.ar-chat-inbox-item__pending {
  font-size: 11px;
  color: var(--ar-green-dark);
  background: var(--ar-yellow);
  border-radius: 4px;
  padding: 2px 7px;
  font-weight: 700;
  white-space: nowrap;
  margin-left: 10px;
}

.ar-chat-inbox-item__badge {
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--ar-yellow);
  color: var(--ar-green-dark);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 8px;
}

/* Delete button */
.ar-chat-inbox-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  border: none;
  border-left: 1px solid var(--ar-border);
  background: transparent;
  color: #c53030;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

.ar-chat-inbox-delete:hover { background: #fff5f5; }

/* =========================================================
   My Account – Conversation detail
   ========================================================= */
.ar-chat-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ar-green);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--ar-green-light);
  transition: background 0.15s;
}

.ar-chat-back:hover { background: #d0e5d3; text-decoration: none; }

.ar-chat-detail__title { font-size: 20px; margin-bottom: 6px; }
.ar-chat-detail__title a { color: var(--ar-green); text-decoration: none; }

.ar-chat-detail__with {
  font-size: 13px;
  color: var(--ar-text-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ar-chat-detail__with strong { color: var(--ar-green); }

.ar-chat-messages {
  border: 1.5px solid var(--ar-border);
  border-radius: var(--ar-radius);
  padding: 16px;
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7faf7;
  margin-bottom: 16px;
  scroll-behavior: smooth;
}

.ar-chat-compose { display: flex; flex-direction: column; gap: 10px; }

.ar-chat-compose .ar-chat-input {
  min-height: 80px;
  padding: 10px 12px;
  border-radius: var(--ar-radius);
}

.ar-chat-compose .ar-chat-send {
  align-self: flex-end;
  width: auto;
  height: auto;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  gap: 6px;
  background: var(--ar-green);
  color: var(--ar-white);
}

.ar-chat-compose .ar-chat-send:hover { background: var(--ar-green-dark); }

/* =========================================================
   Menu badge (WooCommerce My Account)
   ========================================================= */
.ar-chat-menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--ar-yellow);
  color: var(--ar-green-dark);
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 480px) {
  :root {
    --ar-panel-w: calc(100vw - 32px);
    --ar-panel-h: 440px;
  }

  .ar-chat-widget { bottom: 16px; right: 16px; }
  .ar-chat-stats { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   Tooltip – hide when panel is open or dismissed
   ========================================================= */
.ar-chat-widget.ar-tooltip-dismissed .ar-chat-tooltip,
.ar-chat-widget:has(.ar-chat-panel.ar-open) .ar-chat-tooltip {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Tooltip entrada animada */
@keyframes ar-tooltip-in {
  from { opacity: 0; transform: translateY(50%) translateX(8px); }
  to   { opacity: 1; transform: translateY(50%) translateX(0); }
}
.ar-chat-tooltip {
  animation: ar-tooltip-in 0.3s ease 1.5s both;
}

/* ==========================================================================
   Unified Widget — Selector screen
   ========================================================================== */

.ar-chat-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.ar-chat-option {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1.5px solid #e0e8e0;
  border-radius: 12px;
  padding: 16px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  font-family: inherit;
  width: 100%;
}

.ar-chat-option:hover {
  border-color: #274c30;
  box-shadow: 0 2px 10px rgba(39,76,48,0.1);
  transform: translateY(-1px);
}

.ar-chat-option--book {
  border-color: #f6bf39;
}

.ar-chat-option--book:hover {
  border-color: #e6af2a;
  box-shadow: 0 2px 10px rgba(246,191,57,0.2);
}

.ar-chat-option__icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #f0f6f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #274c30;
}

.ar-chat-option--book .ar-chat-option__icon {
  background: #fef9ec;
  color: #b8860b;
}

.ar-chat-option__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ar-chat-option__text strong {
  font-size: 15px;
  font-weight: 700;
  color: #1b3521;
}

.ar-chat-option__text span {
  font-size: 12px;
  color: #666;
}

.ar-chat-option__arrow {
  color: #aaa;
  flex-shrink: 0;
}

/* ==========================================================================
   Unified Widget — Booking screens (inside chat panel)
   ========================================================================== */

.ar-book-back-row {
  margin-bottom: 12px;
}

.ar-chat-back-btn {
  background: none;
  border: none;
  color: #274c30;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  opacity: 0.75;
  transition: opacity 0.15s;
}

.ar-chat-back-btn:hover { opacity: 1; }

.ar-chat-step-title {
  font-size: 15px;
  font-weight: 700;
  color: #1b3521;
  margin: 0 0 5px;
}

.ar-chat-step-desc {
  font-size: 12px;
  color: #666;
  margin: 0 0 14px;
  line-height: 1.5;
}

/* Code input */
.ar-chat-code-field { margin-bottom: 12px; }

.ar-chat-code-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #dde8dd;
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  transition: border-color 0.15s;
}

.ar-chat-code-wrap:focus-within {
  border-color: #274c30;
  box-shadow: 0 0 0 3px rgba(39,76,48,0.08);
}

.has-error .ar-chat-code-wrap { border-color: #c0392b; }

.ar-chat-code-prefix {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 13px;
  color: #274c30;
  background: #f0f6f0;
  border-right: 1px solid #dde8dd;
  height: 40px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ar-chat-code-input {
  border: none !important;
  background: transparent !important;
  padding: 8px 10px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  font-family: 'Courier New', monospace !important;
  letter-spacing: 0.5px;
  width: 100%;
  box-shadow: none !important;
  text-transform: uppercase;
}

.ar-chat-code-input:focus { outline: none; }

.ar-chat-field-error {
  display: block;
  font-size: 11px;
  color: #c0392b;
  margin-top: 3px;
  min-height: 14px;
}

.has-error > input,
.has-error > textarea { border-color: #c0392b !important; }

.ar-chat-no-card {
  text-align: center;
  font-size: 12px;
  color: #888;
  margin-top: 12px;
}

.ar-chat-link-btn {
  background: none;
  border: none;
  color: #274c30;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

/* Validated code */
.ar-chat-code-validated {
  background: #f0f6f0;
  border: 1px solid #c0dd97;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ar-chat-code-validated__badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #2d7a3e;
}

.ar-chat-code-display {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #1b3521;
  background: #fff;
  padding: 4px 12px;
  border-radius: 5px;
  border: 1px solid #dde8dd;
  letter-spacing: 0.5px;
}

/* Booking form fields */
.ar-chat-field-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.ar-chat-field-row > * { flex: 1; }

.ar-chat-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.ar-chat-field label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
}

.ar-chat-field input,
.ar-chat-field select,
.ar-chat-field textarea {
  border: 1.5px solid #dde8dd;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fafafa;
  transition: border-color 0.15s;
  box-sizing: border-box;
  width: 100%;
}

.ar-chat-field input:focus,
.ar-chat-field textarea:focus {
  outline: none;
  border-color: #274c30;
  background: #fff;
}

/* Code pill in step 2 */
.ar-chat-code-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0f6f0;
  border: 1px solid #c0dd97;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #1b3521;
  margin-bottom: 12px;
}

.ar-chat-code-pill code {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* Submit button */
.ar-chat-submit-btn {
  display: block;
  width: 100%;
  background: #274c30;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  text-align: center;
  margin-top: 4px;
}

.ar-chat-submit-btn:hover:not(:disabled) { opacity: 0.88; }
.ar-chat-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Form actions row */
.ar-chat-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.ar-chat-form-actions .ar-chat-submit-btn { flex: 1; margin-top: 0; }

/* Spinner */
.ar-chat-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ar-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

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

/* Booking success */
.ar-chat-book-success {
  text-align: center;
  padding: 12px 0;
}

.ar-chat-book-success__icon {
  width: 52px;
  height: 52px;
  background: #2d7a3e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: #fff;
}

.ar-chat-book-success h4 {
  font-size: 17px;
  color: #1b3521;
  margin: 0 0 6px;
}

.ar-chat-book-success p {
  font-size: 13px;
  color: #666;
  margin: 0 0 16px;
}

/* Notice */
.ar-chat-notice {
  color: #888;
  text-align: center;
  font-size: 13px;
  padding: 8px 0;
}
