/* ============================================================
   styles-additions-v11.css — App v0.4.3
   Adds:
     1. 3-option segmented control for the touch-modal "When" picker
     2. Hint banner under the When picker (used in backdate mode)
     3. Clickable contact-name button in panel touch rows
     4. "+✉" missing-email flag chip
     5. Contact edit modal (.cem-*) — mirrors .aem-* modal
   ============================================================ */

/* ---------- 1. 3-option segmented control ---------- */

/* The default .tm-segmented assumes 2 options on one line. Three options
   wrap awkwardly on narrow screens. Allow wrap and shrink padding slightly. */
.tm-segmented.tm-segmented-3 {
  flex-wrap: wrap;
  gap: 2px;
}
.tm-segmented.tm-segmented-3 .tm-seg-opt span {
  padding: 6px 11px;
  font-size: 12.5px;
}

@media (max-width: 480px) {
  .tm-segmented.tm-segmented-3 {
    display: flex;
    width: 100%;
  }
  .tm-segmented.tm-segmented-3 .tm-seg-opt {
    flex: 1;
    text-align: center;
  }
  .tm-segmented.tm-segmented-3 .tm-seg-opt span {
    display: block;
    padding: 6px 4px;
    font-size: 12px;
  }
}

/* ---------- 2. When-hint banner (used in backdate mode) ---------- */

.tm-when-hint {
  margin-top: 8px;
  padding: 8px 11px;
  background: #f7f5f1;
  border-left: 3px solid #b8a983;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #6b6960;
  line-height: 1.4;
}

/* ---------- 3. Clickable contact name in panel touch rows ---------- */

.tcpr-contact-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.18);
  text-decoration-thickness: 0.5px;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.12s, color 0.12s;
}
.tcpr-contact-link:hover {
  text-decoration-color: currentColor;
  color: #1a1a1a;
}
.tcpr-contact-link:focus-visible {
  outline: 2px solid #b8a983;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- 4. Missing-email flag on contact name ---------- */

.tcpr-contact-flag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  background: #fff5e0;
  border: 0.5px solid #d4b264;
  border-radius: 3px;
  font-size: 10px;
  color: #8a6a17;
  font-weight: 500;
  letter-spacing: 0.2px;
  vertical-align: 1px;
  cursor: pointer;
  white-space: nowrap;
}
.tcpr-contact-link:hover .tcpr-contact-flag {
  background: #ffeec2;
  border-color: #b8902c;
}

/* ---------- 5. Contact edit modal (.cem-*) ---------- */

.cem-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 32px;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  overflow-y: auto;
}
.cem-overlay.cem-open {
  opacity: 1;
  pointer-events: auto;
}

.cem-modal {
  width: 100%;
  max-width: 540px;
  background: #fbfaf6;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
  font-family: inherit;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 92px);
}

.cem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}
.cem-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.cem-close {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #888780;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}
.cem-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1a1a1a;
}

.cem-form {
  padding: 16px 22px 22px;
  overflow-y: auto;
}

.cem-banner {
  background: #fff7e3;
  border: 0.5px solid #d4b264;
  border-left: 3px solid #b8902c;
  border-radius: 4px;
  padding: 9px 12px;
  font-size: 12.5px;
  color: #6e5511;
  line-height: 1.45;
  margin-bottom: 14px;
}

.cem-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}
.cem-row label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #888780;
  margin-bottom: 4px;
  font-weight: 500;
}
.cem-label-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: #b3b0a6;
  margin-left: 6px;
}
.cem-row input,
.cem-row textarea {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #d8d6d0;
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
  width: 100%;
}
.cem-row input:focus,
.cem-row textarea:focus {
  outline: none;
  border-color: #888780;
  box-shadow: 0 0 0 2px rgba(136, 135, 128, 0.18);
}

.cem-row-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.cem-section-divider {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b3b0a6;
  margin: 16px 0 10px;
  padding-top: 10px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
  font-weight: 500;
}
.cem-section-divider:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.cem-error {
  background: #fde8e0;
  border: 0.5px solid #c96b3f;
  border-radius: 4px;
  padding: 8px 11px;
  font-size: 13px;
  color: #6e2913;
  margin: 6px 0 4px;
}

.cem-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
}
.cem-spacer {
  flex: 1;
}
.cem-cancel,
.cem-save,
.cem-delete {
  font: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cem-cancel {
  background: transparent;
  color: #6b6960;
  border: 1px solid #d8d6d0;
}
.cem-cancel:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #1a1a1a;
}
.cem-save {
  background: #1a1a1a;
  color: #fff;
}
.cem-save:hover { background: #2a2a2a; }
.cem-save:disabled {
  background: #b3b0a6;
  cursor: not-allowed;
}
.cem-delete {
  background: transparent;
  color: #993C1D;
  border: 1px solid #e6c9bd;
}
.cem-delete:hover {
  background: #fde8e0;
  color: #6e2913;
}

@media (max-width: 480px) {
  .cem-overlay {
    padding: 32px 8px 16px;
  }
  .cem-modal {
    max-height: calc(100vh - 48px);
  }
  .cem-form {
    padding: 14px 16px 18px;
  }
  .cem-actions {
    flex-wrap: wrap;
  }
  .cem-delete {
    order: 3;
    width: 100%;
    margin-top: 8px;
  }
}

@media (prefers-color-scheme: dark) {
  /* Match existing app behavior: app uses light theme, no dark variants needed yet */
}
