/* =========================================================
   RESERVATION POPUP + MESSAGING — Direction C
   ========================================================= */

/* Bouton "+" discret pour ajouter une note voyageur */
.res-popup-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.res-popup-add-note-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-12, 12px);
  font-weight: var(--w-bold);
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.res-popup-add-note-btn:hover {
  background: rgba(230, 149, 0, 0.12);
  color: #e69500;
  border-color: #e69500;
}
.res-popup-add-note-btn.active {
  background: #e69500;
  color: #fff;
  border-color: #e69500;
}

/* "−" à l'intérieur de la carte "Note importante" */
.res-popup-note-header { position: relative; }
.res-popup-note-del-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(230, 149, 0, 0.5);
  background: rgba(255, 255, 255, 0.5);
  color: #b26a00;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.res-popup-note-del-btn:hover {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}
@media (prefers-color-scheme: dark) {
  .res-popup-note-del-btn {
    background: rgba(0, 0, 0, 0.25);
    color: #f6c35e;
    border-color: rgba(246, 195, 94, 0.5);
  }
  .res-popup-note-del-btn:hover {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
  }
}

/* Modal de confirmation "Êtes-vous sûr ?" */
.res-popup-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 25000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.res-popup-confirm {
  background: var(--surface-1, #fff);
  border-radius: var(--r-lg, 12px);
  padding: 20px 18px 16px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: cardIn 0.2s var(--ease-out) forwards;
}
.res-popup-confirm-title {
  font-size: var(--t-16, 16px);
  font-weight: var(--w-bold);
  color: var(--ink-1);
  margin-bottom: 4px;
}
.res-popup-confirm-sub {
  font-size: var(--t-13, 13px);
  color: var(--ink-2);
  margin-bottom: 16px;
}
.res-popup-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.res-popup-confirm-no,
.res-popup-confirm-yes {
  font-size: var(--t-14, 14px);
  font-weight: var(--w-bold);
  padding: 10px 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-width: 90px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.res-popup-confirm-no {
  background: transparent;
  color: var(--ink-1);
}
.res-popup-confirm-no:hover {
  background: rgba(0, 0, 0, 0.04);
}
.res-popup-confirm-yes {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}
.res-popup-confirm-yes:hover {
  background: #c82333;
  border-color: #c82333;
}
.res-popup-confirm-yes.saved {
  background: #28a745;
  border-color: #28a745;
}
.res-popup-confirm-yes.error {
  background: #8b1e2b;
  border-color: #8b1e2b;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-color-scheme: dark) {
  .res-popup-confirm {
    background: #1e1e20;
  }
  .res-popup-confirm-no:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* Éditeur inline de note voyageur */
.res-popup-note-editor {
  background: var(--surface-2, rgba(0,0,0,0.04));
  border: 1px solid var(--line-2);
  border-left: 3px solid #e69500;
  border-radius: var(--r-md);
  padding: 10px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.res-popup-note-editor[hidden] { display: none; }
.res-popup-note-input {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink-1);
  resize: vertical;
  min-height: 52px;
  box-sizing: border-box;
}
.res-popup-note-input:focus {
  outline: none;
  border-color: #e69500;
}
.res-popup-note-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.res-popup-note-cancel,
.res-popup-note-save {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-width: 78px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.res-popup-note-save {
  background: #e69500;
  border-color: #e69500;
  color: #fff;
}
.res-popup-note-save:disabled { opacity: 0.7; cursor: not-allowed; }
.res-popup-note-save.saved { background: var(--ok, #2ca770); border-color: var(--ok, #2ca770); }
.res-popup-note-save.error { background: var(--danger, #d64545); border-color: var(--danger, #d64545); }
.res-popup-note-save .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: resNoteSpin 0.7s linear infinite;
  display: inline-block;
}
@keyframes resNoteSpin { to { transform: rotate(360deg); } }

/* Note voyageur dans le popup réservation — très visible */
.res-popup-note-voyageur {
  background: linear-gradient(135deg, #fff3cd, #ffe69c);
  border: 1px solid #e69500;
  border-left: 5px solid #e69500;
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 2px 6px rgba(230, 149, 0, 0.25);
  animation: resNotePulse 2s ease-in-out infinite;
}
@keyframes resNotePulse {
  0%, 100% { box-shadow: 0 2px 6px rgba(230, 149, 0, 0.25); }
  50% { box-shadow: 0 2px 14px rgba(230, 149, 0, 0.55); }
}
.res-popup-note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.res-popup-note-icon { font-size: 18px; line-height: 1; }
.res-popup-note-title {
  font-size: 12px;
  font-weight: 800;
  color: #8a5100;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.res-popup-note-body {
  font-size: 14px;
  color: #4a2e00;
  line-height: 1.45;
  font-weight: 600;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (prefers-color-scheme: dark) {
  .res-popup-note-voyageur {
    background: linear-gradient(135deg, #3a2a05, #4a3608);
    border-color: #d69a3a;
    border-left-color: #f6b852;
  }
  .res-popup-note-title { color: #f6c35e; }
  .res-popup-note-body { color: #fde6b1; }
}

.res-popup-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s var(--ease);
  padding: 20px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.res-popup {
  background: var(--surface);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-4);
  max-width: 340px;
  width: 100%;
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.95) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.res-popup-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-1);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.res-popup-header-left { display: flex; flex-direction: column; gap: 3px; }
.res-popup-room {
  font-size: var(--t-15);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.res-popup-referrer {
  font-size: var(--t-11);
  font-weight: var(--w-medium);
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.res-popup-referrer-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: var(--t-10);
  font-weight: var(--w-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.referrer-airbnb  { background: color-mix(in srgb, var(--platform-airbnb)  14%, transparent); color: var(--platform-airbnb); }
.referrer-booking { background: color-mix(in srgb, var(--platform-booking) 14%, transparent); color: var(--platform-booking); }
.referrer-direct  { background: color-mix(in srgb, var(--platform-direct)  16%, transparent); color: var(--platform-direct); }
.referrer-default { background: var(--surface-sunken); color: var(--ink-3); }

.res-popup-close {
  background: var(--surface);
  border: 1px solid var(--line-2);
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: var(--w-medium);
  line-height: 1;
  transition: background var(--dur-fast) var(--ease);
  padding: 0;
}
.res-popup-close:hover  { background: var(--surface-2); }
.res-popup-close:active { background: var(--surface-sunken); }

.res-popup-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.res-popup-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.res-popup-row-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--line-1);
}
.res-popup-row-info { display: flex; flex-direction: column; min-width: 0; }
.res-popup-row-label {
  font-size: var(--t-10);
  font-weight: var(--w-semibold);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}
.res-popup-row-value {
  font-size: var(--t-14);
  font-weight: var(--w-medium);
  color: var(--ink-1);
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}
.res-popup-phone-link {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--t-14);
  font-weight: var(--w-medium);
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.res-popup-phone-link:hover  { color: var(--accent-hover); }
.res-popup-phone-link:active { opacity: 0.8; }

/* ===== MESSAGERIE BUTTONS ===== */
.res-popup-btns-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.res-popup-btn-msg, .res-popup-btn-wa {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: #fff;
  font-family: inherit;
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  box-shadow: var(--sh-1);
}
.res-popup-btn-msg { background: var(--accent); border-color: var(--accent); }
.res-popup-btn-msg:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.res-popup-btn-wa  { background: #128C7E; border-color: #128C7E; }
.res-popup-btn-wa:hover  { background: #0f736a; border-color: #0f736a; }

.res-popup-btn-msg:active:not(:disabled),
.res-popup-btn-wa:active:not(:disabled) { transform: scale(0.975); }

.res-popup-btn-msg:disabled,
.res-popup-btn-wa:disabled { opacity: 0.6; cursor: not-allowed; }
.res-popup-btn-msg .spinner,
.res-popup-btn-wa .spinner { width: 16px; height: 16px; border-width: 2px; display: inline-block; }
.res-popup-btn-wa svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== MESSAGING OVERLAY ===== */
.msg-overlay {
  position: fixed;
  inset: 0;
  z-index: 30000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.22s var(--ease);
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-1);
  flex-shrink: 0;
}

.msg-header-back {
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease);
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: var(--w-medium);
  padding: 0;
  line-height: 1;
}
.msg-header-back:hover  { background: var(--surface-2); }
.msg-header-back:active { background: var(--surface-sunken); }

.msg-header-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.msg-header-title {
  font-size: var(--t-15);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-header-sub {
  font-size: var(--t-10);
  color: var(--ink-3);
  font-weight: var(--w-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-top: 2px;
}

.msg-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.msg-body::-webkit-scrollbar { width: 4px; }
.msg-body::-webkit-scrollbar-track { background: transparent; }
.msg-body::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 4px; }

.msg-date-separator { text-align: center; padding: 12px 0 6px; }
.msg-date-separator span {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line-1);
  color: var(--ink-3);
  font-size: var(--t-10);
  font-weight: var(--w-semibold);
  padding: 3px 10px;
  border-radius: var(--r-sm);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
}

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgIn 0.18s var(--ease);
}
.msg-bubble-wrap.msg-host  { align-self: flex-end; }
.msg-bubble-wrap.msg-guest { align-self: flex-start; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bubble {
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: var(--t-13);
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-host .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}
.msg-guest .msg-bubble {
  background: var(--surface);
  color: var(--ink-1);
  border: 1px solid var(--line-1);
  border-bottom-left-radius: 2px;
}

.msg-bubble a { color: inherit; text-decoration: underline; word-break: break-all; }
.msg-host .msg-bubble a { color: rgba(255,255,255,0.92); }
.msg-guest .msg-bubble a { color: var(--accent); }

.msg-time {
  font-size: 10px;
  color: var(--ink-4);
  margin-top: 2px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.msg-host .msg-time  { text-align: right; }
.msg-guest .msg-time { text-align: left; }

.msg-author-label {
  font-size: 9px;
  font-weight: var(--w-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-bottom: 2px;
  padding: 0 4px;
}
.msg-host .msg-author-label  { color: var(--accent); text-align: right; }
.msg-guest .msg-author-label { color: var(--ink-4); text-align: left; }

.msg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 10px;
  color: var(--ink-3);
  font-size: var(--t-13);
  font-weight: var(--w-medium);
}
.msg-loading .spinner {
  border-color: var(--line-2);
  border-top-color: var(--accent);
}

.msg-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--ink-3);
  font-size: var(--t-13);
  font-weight: var(--w-medium);
  text-align: center;
  padding: 20px;
}

.msg-error {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--danger);
  font-size: var(--t-13);
  font-weight: var(--w-medium);
  text-align: center;
  padding: 20px;
}

.msg-readonly-bar {
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line-1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: var(--t-12);
  font-weight: var(--w-medium);
}

.cal-block-name {
  font-size: 8px;
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.1;
}

/* Legend */
.cal-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-1);
  flex-wrap: wrap;
  background: var(--surface-2);
}
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-10);
  font-weight: var(--w-semibold);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}
.cal-legend-dot {
  width: 12px;
  height: 8px;
  border-radius: var(--r-xs);
  flex-shrink: 0;
}
.cal-legend-dot-arrivee  { background: var(--ok-soft); border-left: 2px solid var(--ok); }
.cal-legend-dot-depart   { background: var(--warn-soft); border-right: 2px solid var(--warn); }
.cal-legend-dot-sejour   { background: var(--accent-soft); }
.cal-legend-dot-now      { background: var(--danger); width: 2px; height: 10px; border-radius: 1px; }
.cal-legend-dot-airbnb   { background: color-mix(in srgb, var(--platform-airbnb) 22%, transparent);  border-left: 2px solid var(--platform-airbnb); }
.cal-legend-dot-booking  { background: color-mix(in srgb, var(--platform-booking) 22%, transparent); border-left: 2px solid var(--platform-booking); }
.cal-legend-dot-direct   { background: color-mix(in srgb, var(--platform-direct) 22%, transparent);  border-left: 2px solid var(--platform-direct); }

/* Empty */
.cal-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--ink-3);
  font-size: var(--t-12);
  font-weight: var(--w-medium);
}
