/**
 * editor.css — MyTravelsai Itinerary Editor
 * Estilos para el modo edición inline del itinerario
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --ed-gold:        #C9A84C;
  --ed-gold-light:  #e8c96a;
  --ed-dark:        #0A1628;
  --ed-surface:     rgba(10, 22, 40, 0.85);
  --ed-border:      rgba(201, 168, 76, 0.3);
  --ed-border-act:  rgba(201, 168, 76, 0.8);
  --ed-radius:      10px;
  --ed-transition:  0.2s ease;
}

/* ── Edit Mode Toggle Button ───────────────────────────────────────────────── */
.editor-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1.5px solid var(--ed-border);
  background: transparent;
  color: var(--ed-gold);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ed-transition);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.editor-toggle-btn:hover {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--ed-gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.18);
}
.editor-toggle-btn.edit-active {
  background: var(--ed-gold);
  color: #0A1628;
  border-color: var(--ed-gold);
  box-shadow: 0 4px 18px rgba(201, 168, 76, 0.35);
}
.editor-toggle-btn i {
  font-size: 0.9em;
}

/* ── Save Status Badge ─────────────────────────────────────────────────────── */
.editor-save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  transition: all 0.3s ease;
  min-width: 100px;
  opacity: 0;
  transform: translateY(2px);
}
.editor-save-status.visible {
  opacity: 1;
  transform: translateY(0);
}
.editor-save-status.saving {
  color: rgba(201, 168, 76, 0.7);
}
.editor-save-status.saved {
  color: #4ade80;
}
.editor-save-status.error {
  color: #f87171;
}
.editor-save-status .save-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Editor Toolbar ────────────────────────────────────────────────────────── */
.editor-toolbar {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: rgba(10, 22, 40, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  margin-bottom: 16px;
  flex-wrap: wrap;
  animation: toolbar-appear 0.25s ease;
}
@keyframes toolbar-appear {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.editor-toolbar.visible {
  display: flex;
}
.ed-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--ed-transition);
  font-family: inherit;
  font-weight: 700;
}
.ed-tool-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  color: var(--ed-gold);
}
.ed-tool-btn.active {
  background: rgba(201, 168, 76, 0.2);
  color: var(--ed-gold);
}
.ed-tool-separator {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.12);
  margin: 0 4px;
}
.ed-tool-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  padding: 0 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Day Panel Edit Mode ───────────────────────────────────────────────────── */
.editor-mode .day-panel {
  position: relative;
  border: 1.5px solid transparent;
  border-radius: var(--ed-radius);
  transition: border-color var(--ed-transition), background var(--ed-transition);
}
.editor-mode .day-panel:hover {
  border-color: rgba(201, 168, 76, 0.25);
  background: rgba(201, 168, 76, 0.03);
}

/* Drag handle */
.day-drag-handle {
  display: none;
  position: absolute;
  left: -26px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(201, 168, 76, 0.4);
  font-size: 1.2rem;
  cursor: grab;
  padding: 4px;
  line-height: 1;
  transition: color var(--ed-transition);
  user-select: none;
}
.day-drag-handle:hover { color: var(--ed-gold); }
.day-drag-handle:active { cursor: grabbing; }
.editor-mode .day-panel { padding-left: 6px; }
.editor-mode .day-drag-handle { display: block; }

/* SortableJS dragging ghost */
.sortable-ghost {
  opacity: 0.35;
  border: 2px dashed var(--ed-gold) !important;
  background: rgba(201, 168, 76, 0.06) !important;
}
.sortable-drag {
  box-shadow: 0 12px 40px rgba(0,0,0,0.45) !important;
  transform: rotate(1deg) !important;
}

/* ContentEditable areas ──────────────────────────────────────────────────── */
.editor-mode [contenteditable="true"] {
  outline: none;
  cursor: text;
  border-radius: 6px;
  transition: background var(--ed-transition), box-shadow var(--ed-transition);
  min-height: 1.4em;
}
.editor-mode [contenteditable="true"]:focus {
  background: rgba(201, 168, 76, 0.06);
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.25);
}
.editor-mode [contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,0.25);
  font-style: italic;
  pointer-events: none;
}

/* Day title editable */
.editor-mode .day-panel h3[contenteditable] {
  padding: 4px 8px;
  border-radius: 6px;
}

/* Editable paragraph / li */
.editor-mode .day-panel p[contenteditable],
.editor-mode .day-panel li[contenteditable] {
  padding: 2px 6px;
  border-radius: 4px;
  margin: 1px 0;
}

/* ── Inline action buttons ─────────────────────────────────────────────────── */
.ed-item-actions {
  display: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
}
.editor-mode p:hover .ed-item-actions,
.editor-mode li:hover .ed-item-actions {
  display: flex;
}
.ed-del-btn, .ed-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--ed-transition);
  flex-shrink: 0;
}
.ed-del-btn {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}
.ed-del-btn:hover {
  background: rgba(239, 68, 68, 0.28);
  color: #fff;
}
.ed-add-btn {
  background: rgba(201, 168, 76, 0.12);
  color: var(--ed-gold);
}
.ed-add-btn:hover {
  background: rgba(201, 168, 76, 0.28);
  color: #fff;
}

/* ── Add Day / Add Activity buttons ────────────────────────────────────────── */
.ed-add-day-btn {
  display: none;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: 2px dashed rgba(201, 168, 76, 0.3);
  border-radius: var(--ed-radius);
  background: transparent;
  color: rgba(201, 168, 76, 0.6);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ed-transition);
  gap: 8px;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.03em;
}
.ed-add-day-btn:hover {
  border-color: var(--ed-gold);
  color: var(--ed-gold);
  background: rgba(201, 168, 76, 0.05);
}
.editor-mode .ed-add-day-btn {
  display: flex;
}

.ed-add-activity-btn {
  display: none;
  width: 100%;
  margin-top: 8px;
  padding: 7px 12px;
  border: 1.5px dashed rgba(201, 168, 76, 0.25);
  border-radius: 7px;
  background: transparent;
  color: rgba(201, 168, 76, 0.5);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--ed-transition);
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.ed-add-activity-btn:hover {
  border-color: var(--ed-gold);
  color: var(--ed-gold);
  background: rgba(201, 168, 76, 0.06);
}
.editor-mode .ed-add-activity-btn {
  display: flex;
}

/* ── Delete Day Button ─────────────────────────────────────────────────────── */
.ed-delete-day-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--ed-transition);
  align-items: center;
  justify-content: center;
}
.ed-delete-day-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
}
.editor-mode .day-panel { position: relative; }
.editor-mode .ed-delete-day-btn { display: flex; }

/* ── Unsaved changes indicator ─────────────────────────────────────────────── */
.ed-unsaved-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ed-gold);
  margin-left: 6px;
  animation: pulse-dot 1.5s infinite;
  vertical-align: middle;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

/* ── Tab header row with edit button ──────────────────────────────────────── */
.daybydy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.daybydy-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.daybydy-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .editor-toolbar { padding: 6px 10px; gap: 2px; }
  .ed-tool-label  { display: none; }
  .daybydy-header { flex-direction: column; align-items: flex-start; }
}

/* ── AI Agent Panel ────────────────────────────────────────────────────────── */
.agent-panel {
  display: none;
  margin-bottom: 20px;
  border: 1.5px solid var(--ed-border-act);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(10, 22, 40, 0.95), rgba(15, 32, 60, 0.95));
  backdrop-filter: blur(16px);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(201, 168, 76, 0.08);
  animation: toolbar-appear 0.3s ease;
}

.agent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.12);
  gap: 12px;
}

.agent-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ed-gold), rgba(201, 168, 76, 0.6));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ed-dark);
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.3);
}

.agent-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.agent-subtitle {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

.agent-cost-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(201, 168, 76, 0.7);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.agent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.agent-chip {
  background: rgba(201, 168, 76, 0.06);
  border: 1px solid rgba(201, 168, 76, 0.18);
  color: rgba(255,255,255,0.7);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.agent-chip:hover {
  background: rgba(201, 168, 76, 0.18);
  color: var(--ed-gold);
  border-color: var(--ed-gold);
  transform: translateY(-1px);
}

.agent-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 18px;
}

.agent-textarea {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  min-height: 50px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.agent-textarea:focus {
  outline: none;
  border-color: var(--ed-gold);
}
.agent-textarea::placeholder {
  color: rgba(255,255,255,0.28);
  font-style: italic;
}

.agent-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--ed-gold);
  color: var(--ed-dark);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.agent-send-btn:hover:not(:disabled) {
  background: var(--ed-gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(201, 168, 76, 0.35);
}
.agent-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.82rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  min-height: 40px;
}
.agent-status.thinking {
  color: rgba(201, 168, 76, 0.8);
}
.agent-status.success {
  color: #4ade80;
}
.agent-status.error {
  color: #f87171;
}

/* Flash animation on the patched panel or budget */
@keyframes agent-flash {
  0%   { box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.6); background: rgba(201, 168, 76, 0.08); }
  50%  { box-shadow: 0 0 0 6px rgba(201, 168, 76, 0.2); background: rgba(201, 168, 76, 0.12); }
  100% { box-shadow: none; background: transparent; }
}
.agent-patch-flash {
  animation: agent-flash 1.8s ease-out forwards;
  border-radius: var(--ed-radius);
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .editor-toolbar { padding: 6px 10px; gap: 2px; }
  .ed-tool-label  { display: none; }
  .daybydy-header { flex-direction: column; align-items: flex-start; }
  .agent-chips { gap: 4px; }
  .agent-chip  { font-size: 0.72rem; padding: 4px 9px; }
  .agent-panel-header { flex-direction: column; align-items: flex-start; }
}

/* ── Budget Editor ─────────────────────────────────────────────────────────── */

/* Make the budget-breakdown-header flex so the edit button aligns right */
.budget-breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* The edit button inside budget header (reuses .editor-toggle-btn styles) */
.budget-edit-toggle {
  margin-left: auto;
  flex-shrink: 0;
}

/* Add Category button below the budget content */
.budget-add-category-btn {
  margin-top: 14px !important;
}

/* Inline delete button on budget items (p, li) */
.ed-del-item-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: none;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  transition: all 0.15s ease;
}
/* Show delete button on hover of the editable parent */
[contenteditable]:hover > .ed-del-item-btn,
[contenteditable]:focus-within > .ed-del-item-btn {
  display: flex;
}
.ed-del-item-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

