/* ============================================================
   DashboardEmailTab — Outlook-Postfach im Dashboard
   ============================================================ */

.root {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Status / Leer-Zustände ── */

.status {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  padding: 1rem 0;
}

.errorText {
  color: #ef4444;
  font-size: 0.9375rem;
  padding: 1rem 0;
}

/* ── Nicht verbunden ── */

.notConnected {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 0.5rem;
}

.notConnectedIcon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.notConnectedTitle {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.notConnectedSub {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin: 0;
}

.notConnectedLink {
  color: var(--color-primary);
  text-decoration: none;
}

.notConnectedLink:hover {
  text-decoration: underline;
}

/* ── Filter-Leiste ── */

.filterBar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.25rem;
}

.filterLabel {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

.filterBtn {
  padding: 0.3125rem 0.875rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filterBtn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filterBtnActive {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.filterBtnActive:hover {
  color: #fff;
  opacity: 0.9;
}

/* ── Erfolgs-Banner ── */

.successBanner {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: #16a34a;
}

/* ── Hauptlayout ── */

.layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  min-height: 300px;
  max-width: 70%;
}

/* ── Ordner-Baum (Sidebar) ── */

.folderTree {
  width: 200px;
  flex-shrink: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0;
}

.folderList {
  list-style: none;
  margin: 0;
  padding: 0;
}

.folderItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.875rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  gap: 0.375rem;
}

.folderItem:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.folderItemActive {
  color: var(--color-primary);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.07);
}

.folderItemActive:hover {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}

.folderName {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folderBadge {
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--color-primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.0625rem 0.375rem;
  min-width: 1.125rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── E-Mail-Liste ── */

.emailList {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

/* ── E-Mail-Karte ── */

.emailCard {
  position: relative;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  cursor: pointer;
}

.emailCard:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.emailCardUnread {
  border-left: 3px solid var(--color-primary);
}

.emailCardInner {
  display: block;
  padding: 0.75rem 1rem;
  color: inherit;
}

.emailHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}

.emailSubject {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--color-text);
  flex: 1;
  word-break: break-word;
}

.emailCardUnread .emailSubject {
  font-weight: 600;
}

.unreadDot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
}

.emailDate {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.emailMeta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.emailFrom {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  word-break: break-word;
}

.crmBadge {
  font-size: 0.6875rem;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 999px;
  padding: 0.0625rem 0.375rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.attachBadge {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.emailPreview {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.45;
  word-break: break-word;
}

/* ── Detail-Modal (E-Mail Lesefenster) ── */

.detailModal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.detailHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.detailSubject {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  line-height: 1.35;
}

.closeBtn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
  margin-top: -0.125rem;
}

.closeBtn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.detailMeta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.875rem 1.5rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.detailMetaRow {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.detailMetaLabel {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 48px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detailMetaValue {
  font-size: 0.875rem;
  color: var(--color-text);
}

.detailSenderEmail {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.detailBody {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100px;
  max-height: 280px;
  background: var(--color-bg-card);
}

.detailBodyEmpty {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ── CRM-Bereich im Detail-Modal ── */

.detailCrm {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.detailCrmTitle {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.detailCrmLoading {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.detailCrmFound {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.detailCrmInfo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detailCrmAvatar {
  font-size: 1.125rem;
}

.detailCrmName {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.detailCrmCompany {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.detailCrmActions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.detailCrmOpenBtn {
  padding: 0.375rem 0.875rem;
  background: none;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.detailCrmOpenBtn:hover {
  background: var(--color-primary);
  color: #fff;
}

.detailCrmMissing {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-wrap: wrap;
}

.detailCrmMissingText {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.detailCrmCreateBtn {
  padding: 0.375rem 0.875rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.detailCrmCreateBtn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Detail-Footer ── */

.detailFooter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-card);
  flex-shrink: 0;
}

.outlookBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4375rem 1rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.outlookBtn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Aktivität-Modal ── */

.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modalTitle {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: var(--color-text);
}

.modalInfo {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 0.875rem;
  margin-bottom: 1.25rem;
}

.modalInfoRow {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.modalLabel {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 64px;
  flex-shrink: 0;
}

.modalValue {
  font-size: 0.875rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modalField {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.modalField .modalLabel {
  min-width: unset;
}

.modalTextarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.875rem;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}

.modalTextarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.modalError {
  font-size: 0.875rem;
  color: #ef4444;
  margin: 0 0 1rem;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.cancelBtn {
  padding: 0.5rem 1.125rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
}

.cancelBtn:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.saveBtn {
  padding: 0.5rem 1.25rem;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.saveBtn:hover:not(:disabled) {
  opacity: 0.9;
}

.saveBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
