/**
 * Interactive Component Styles — Additional styles for Agent Echo components.
 * Supplements base.css with dropdown, inline-edit, invoice, appointment, etc.
 */

/* ─── ContactPicker ───────────────────────────────────── */
.cp-wrapper { position: relative; }
.cp-input-wrap {
  position: relative; display: flex; align-items: center;
}
.cp-search-icon {
  position: absolute; left: 8px; font-size: 12px; pointer-events: none; z-index: 1;
}
.cp-input { padding-left: 28px !important; }
.cp-spinner {
  position: absolute; right: 28px; width: 14px; height: 14px;
  border: 2px solid #e5e7eb; border-top-color: #4f46e5;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.cp-clear {
  position: absolute; right: 8px; background: none; border: none;
  font-size: 16px; color: #9ca3af; cursor: pointer; padding: 0 4px;
  line-height: 1;
}
.cp-clear:hover { color: #374151; }

.cp-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: white; border: 1px solid #e5e7eb; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); max-height: 200px;
  overflow-y: auto; margin-top: 4px;
}
.cp-dropdown-item {
  padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column;
  gap: 1px; transition: background 0.1s;
}
.cp-dropdown-item:hover { background: #f0f4ff; }
.cp-item-name { font-size: 12px; font-weight: 500; color: #111827; }
.cp-item-detail { font-size: 10px; color: #6b7280; }
.cp-dropdown-empty {
  padding: 12px; text-align: center; font-size: 11px; color: #9ca3af;
}

/* ─── EditableField ───────────────────────────────────── */
.ef-wrap { margin-bottom: 6px; }
.ef-display {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 4px; cursor: pointer;
  font-size: 12px; color: #111827; transition: background 0.1s;
  border: 1px solid transparent;
}
.ef-display:hover {
  background: #f3f4f6; border-color: #e5e7eb;
}
.ef-edit-icon { font-size: 10px; opacity: 0; transition: opacity 0.15s; }
.ef-display:hover .ef-edit-icon { opacity: 0.6; }
.ef-empty { color: #9ca3af; font-style: italic; }
.ef-edit-row { display: flex; align-items: center; gap: 6px; }
.ef-input { font-size: 12px; }

/* ─── SelectDropdown ──────────────────────────────────── */
.sd-wrap { margin-bottom: 6px; }
.sd-select-wrap { position: relative; }
.sd-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 28px !important; cursor: pointer;
}
.sd-chevron {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #9ca3af; pointer-events: none;
}

/* ─── FormGroup ───────────────────────────────────────── */
.fg-form { display: flex; flex-direction: column; gap: 0; }
.fg-textarea {
  resize: vertical; min-height: 60px; font-family: inherit;
}
.fg-required { color: #dc2626; margin-left: 2px; }
.fg-actions { margin-top: 8px; }

/* ─── OpportunityEditor ──────────────────────────────── */
.oe-wrap { display: flex; flex-direction: column; gap: 2px; }
.oe-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.oe-dirty {
  font-size: 10px; color: #d97706; font-weight: 500;
}

/* ─── InvoiceBuilder ──────────────────────────────────── */
.ib-wrap { display: flex; flex-direction: column; gap: 12px; }
.ib-section { display: flex; flex-direction: column; gap: 6px; }

.ib-table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
.ib-table th {
  text-align: left; padding: 6px 8px; background: #f9fafb; color: #6b7280;
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.3px; border-bottom: 1px solid #e5e7eb;
}
.ib-table td {
  padding: 4px 6px; border-bottom: 1px solid #f3f4f6; vertical-align: middle;
}
.ib-th-desc { width: 40%; }
.ib-th-num { width: 18%; text-align: right; }
.ib-th-act { width: 30px; }
.ib-num-input { text-align: right; width: 80px; }
.ib-total-cell {
  text-align: right; font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 500; font-size: 11px; color: #111827; padding-right: 8px;
}
.ib-remove-btn {
  padding: 2px 6px !important; font-size: 14px !important; color: #dc2626;
}
.ib-add-btn { align-self: flex-start; margin-top: 4px; color: #4f46e5; }

.ib-totals {
  border-top: 1px solid #e5e7eb; padding-top: 8px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.ib-total-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 12px; color: #374151; min-width: 200px; justify-content: space-between;
}
.ib-total-final {
  font-weight: 700; font-size: 13px; color: #111827;
  border-top: 1px solid #e5e7eb; padding-top: 6px; margin-top: 2px;
}
.ib-total-val {
  font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 600;
}
.ib-tax-input {
  display: inline-block; width: 50px; padding: 2px 4px !important;
  font-size: 11px; text-align: right; margin: 0 4px;
}
.ib-actions { margin-top: 4px; }

/* ─── AppointmentBooker ──────────────────────────────── */
.ab-wrap { display: flex; flex-direction: column; gap: 12px; }

.ab-calendar {
  background: white; border: 1px solid #e5e7eb; border-radius: 8px;
  overflow: hidden;
}
.ab-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.ab-cal-month { font-size: 13px; font-weight: 600; color: #111827; }

.ab-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0;
}
.ab-cal-weekday {
  padding: 6px 2px; text-align: center; font-size: 10px;
  font-weight: 600; color: #6b7280; text-transform: uppercase;
  border-bottom: 1px solid #f3f4f6;
}
.ab-cal-cell {
  padding: 6px 2px; text-align: center; font-size: 11px;
  cursor: pointer; transition: background 0.1s; border-radius: 0;
  min-height: 32px; display: flex; align-items: center; justify-content: center;
}
.ab-cal-cell:hover:not(.ab-cal-empty):not(.ab-cal-past) {
  background: #eef2ff;
}
.ab-cal-empty { cursor: default; }
.ab-cal-past { color: #d1d5db; cursor: not-allowed; }
.ab-cal-today { font-weight: 700; color: #4f46e5; }
.ab-cal-selected {
  background: #4f46e5 !important; color: white !important;
  font-weight: 600; border-radius: 4px;
}

.ab-time-section { display: flex; flex-direction: column; gap: 6px; }
.ab-time-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ab-time-btn {
  padding: 4px 10px; border: 1px solid #e5e7eb; border-radius: 6px;
  background: white; font-size: 11px; color: #374151; cursor: pointer;
  transition: all 0.1s;
}
.ab-time-btn:hover:not(:disabled) { border-color: #4f46e5; color: #4f46e5; }
.ab-time-selected {
  background: #4f46e5 !important; color: white !important;
  border-color: #4f46e5 !important;
}
.ab-time-unavailable {
  background: #f3f4f6; color: #d1d5db; cursor: not-allowed;
  border-color: #f3f4f6;
}

.ab-contact { margin-top: 4px; }
.ab-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
}
.ab-summary { font-size: 11px; color: #6b7280; }

/* ─── AmountInput ─────────────────────────────────────── */
.amount-input-wrap { margin-bottom: 6px; }
.amount-input {
  text-align: right; font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 500;
}

/* ─── InvoiceBuilder Split Layout ─────────────────────── */
.ib-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.ib-left, .ib-right { min-width: 0; }
.ib-section-title { font-size: 13px; font-weight: 600; color: #111827; margin-bottom: 8px; }
.ib-contact-card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; margin-top: 8px; }
.ib-contact-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 11px; border-bottom: 1px solid #f3f4f6; }
.ib-contact-row:last-child { border-bottom: none; }
.ib-contact-label { color: #6b7280; }
.ib-contact-value { color: #111827; font-weight: 500; }
.ib-invoice-header { margin-bottom: 8px; }
.ib-invoice-meta { background: #f9fafb; border-radius: 8px; padding: 8px; }
.ib-meta-row { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; }
.ib-meta-row span:first-child { color: #6b7280; }
.ib-meta-row span:last-child { color: #111827; font-weight: 500; }
.ib-bill-to { background: #f9fafb; border-radius: 8px; padding: 10px; margin-top: 8px; }
.ib-bill-to-label { font-size: 9px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.ib-bill-to-name { font-size: 13px; font-weight: 600; color: #111827; }
.ib-bill-to-detail { font-size: 11px; color: #6b7280; }
.ib-bill-to-empty { font-size: 11px; color: #9ca3af; font-style: italic; }

/* ─── SaveIndicator ───────────────────────────────────── */
.save-indicator {
  position: fixed;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}
.save-indicator--saved {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.2);
}
.save-indicator--pending {
  background: rgba(217, 119, 6, 0.1);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.2);
}
.save-indicator--saving {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.save-indicator--error {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
}
.save-indicator__icon {
  font-size: 12px;
}
.save-indicator__spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
