/* ===========================================================
   modal.css — modals, slide-overs, forms
   =========================================================== */

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-in 0.12s ease-out;
}
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-content.modal-sm { width: 420px; }
.modal-content.modal-lg { width: 720px; }

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-alt);
}

@keyframes modal-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-content {
  animation: modal-content-in 0.18s ease-out;
}
@keyframes modal-content-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Slide-over (right drawer) ===== */
.slide-over {
  position: fixed;
  inset: 0;
  z-index: var(--z-slide);
}
.slide-over[hidden] { display: none !important; }
/* Backdrop más presente + blur: la ficha abierta debe leerse como una capa
   claramente separada del CRM que queda debajo. */
.slide-over-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 15, 28, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: modal-in 0.15s ease-out;
}
.slide-over-content {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 560px;
  max-width: calc(100vw - 60px);
  background: var(--bg-elev);
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(8, 15, 28, 0.28), -2px 0 8px rgba(8, 15, 28, 0.12);
  animation: slide-over-in 0.22s ease-out;
}
[data-theme="dark"] .slide-over-backdrop {
  background: rgba(2, 6, 14, 0.62);
}
[data-theme="dark"] .slide-over-content {
  box-shadow: -24px 0 72px rgba(0, 0, 0, 0.65), -2px 0 10px rgba(0, 0, 0, 0.4);
}
.slide-over.slide-over-sm .slide-over-content {
  width: 420px;
}
@keyframes slide-over-in {
  from { transform: translateX(40px); opacity: 0.6; }
  to   { transform: translateX(0); opacity: 1; }
}
.slide-over-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-shrink: 0;
}
.slide-over-titles { flex: 1; min-width: 0; }
.slide-over-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slide-over-sub {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 2px;
}
.slide-over-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.slide-over-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ===== Lead detail fields ===== */
.lead-detail-section {
  margin-bottom: 20px;
}
.lead-detail-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.lead-detail-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.lead-detail-row .label {
  color: var(--fg-muted);
  font-size: 12px;
}
.lead-detail-row .value {
  color: var(--fg);
  word-break: break-word;
}
.lead-detail-row .value.empty {
  color: var(--fg-subtle);
}
.lead-detail-row .value a { color: var(--accent-hover); text-decoration: underline; }

/* ===== Form ===== */
.form-section {
  margin-bottom: 18px;
}
.form-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid .col-full { grid-column: 1 / -1; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
}
.form-row label .req { color: var(--danger); margin-left: 2px; }
.form-row input,
.form-row select,
.form-row textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.form-row textarea { min-height: 64px; resize: vertical; line-height: 1.4; }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 0, 255, 0.14);
}
.form-row.has-error input,
.form-row.has-error select,
.form-row.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.form-row .hint {
  font-size: 11px;
  color: var(--fg-subtle);
}
.form-row .error-text {
  font-size: 11px;
  color: var(--danger);
  display: none;
}
.form-row.has-error .error-text { display: block; }

.form-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger-fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 12px;
}

/* Activity timeline */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.activity-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.activity-when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}
.activity-body { color: var(--fg); }
.activity-empty {
  color: var(--fg-subtle);
  font-size: 12px;
  padding: 12px 0;
  text-align: center;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .lead-detail-row { grid-template-columns: 1fr; gap: 2px; }
}
