﻿/* ============ Base layout ============ */
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica, Arial, sans-serif; margin: 0; padding: 16px; background: #fafafa; color: #111 }
h1 { margin: 0 0 6px 0 }
.banner { background: #eaf2ff; color: #0f172a; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; font-weight: 600; text-align: center; border: 1px solid #cfe0ff }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px }
.meta { color: #555; font-size: 14px }

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 16px }
.controls .search { flex: 1; min-width: 220px }
.search input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 10px }
.select { padding: 10px 12px; border: 1px solid #ddd; border-radius: 10px; background: #fff }

.chipbar { display: flex; gap: 8px; align-items: center }
.chip { padding: 8px 12px; border: 1px solid #ddd; border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600 }
.chip.active { background: #eaf2ff; border-color: #cfe0ff }

.primary { padding: 10px 14px; border-radius: 12px; border: none; background: #1866ff; color: #fff; font-weight: 700; cursor: pointer }
.ghost { padding: 10px 14px; border-radius: 12px; border: 1px solid #ddd; background: #fff; color: #111; font-weight: 700; cursor: pointer }
.btn { display: inline-flex; align-items: center; gap: 6px }
.btn-signout { background: #ef4444; color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px rgba(239,68,68,.18) }
.btn-signout:hover { filter: brightness(0.95) }

.cols { display: grid; grid-template-columns: 1fr; gap: 16px }
@media (min-width: 900px){ .cols { grid-template-columns: 1fr 1fr } }

/* ============ Cards & lists ============ */
.card { background: #fff; border: 1px solid #eee; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.06); padding: 14px; }
.card h2 { margin: 0 0 10px 0; font-size: 18px; }

ul { list-style: none; margin: 0; padding: 0 }
.meta-sm { font-size: 12px; color: #666 }
.title { font-weight: 600; color: #0f172a }

/* ============ Event rows (date on left; child/class under title) ============ */
.event-item { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  padding: 12px; 
  border-radius: 10px; 
  border: 1px solid #f0f0f0; 
  margin: 6px 0; 
  cursor: pointer; 
  background: #fff; 
  transition: background .15s ease, border-color .15s ease; 
}
.event-item:hover { background: #f9fbff; border-color: #e5efff; }

/* compact date pill on the left */
.event-item__date { 
  flex: 0 0 56px; 
  width: 56px; 
  text-align: center; 
  border: 1px solid #e8edf7; 
  background: #f5f8ff; 
  border-radius: 12px; 
  line-height: 1; 
  padding: 6px 4px; 
}
.event-date-day { font-weight: 800; font-size: 18px; color: #0f172a; }
.event-date-mon { font-size: 11px; letter-spacing: .04em; color: #4b5563; }

/* main text block */
.event-item__main { 
  flex: 1; 
  min-width: 0;         /* critical for text to shrink instead of overflowing */
  display: flex; 
  flex-direction: column; 
  gap: 4px; 
}
.event-item__main .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Child/class line (reserve height so rows don't jump when empty) */
.childline {
  color: #475569;
  font-size: 13px;
  margin-top: 2px;
  min-height: 1.2em;
}

/* Status pill - renamed to avoid collisions with global .badge */
.status-pill {
  flex: 0 0 auto;           /* never grow */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid #cfe7d6;
  background: #e9f8ef;
  color: #0a5a2b;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;      /* no wrap, stays compact */
}

/* Mobile niceties */
@media (max-width: 600px) {
  .pa-modal {
    padding: 12px;
  }
  .pa-modal__content {
    width: 100%;
    margin: 0 auto;
    height: calc(100vh - 24px);
    max-height: none;
    border-radius: 20px;
    padding: 20px 20px 16px;
  }
  .pa-modal__body {
    margin-top: 14px;
    padding-right: 0;
  }
  .pa-modal__header .email-open-gmail {
    justify-self: stretch;
  }
  .email-open-gmail {
    width: 100%;
  }
}


/* ============ Email Preview Modal (hidden by default) ============ */
.pa-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  z-index: 10050;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.pa-modal.open { display: block; }

.pa-modal__content {
  box-sizing: border-box;
  width: min(760px, calc(100% - 16px));
  margin: clamp(16px, 4vh, 40px) auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15,23,42,.16);
  padding: 24px 24px 20px;
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 920px);
  overflow: hidden;
}

.pa-modal__header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "subject close"
    "gmail gmail";
  gap: 12px;
  align-items: flex-start;
}


.pa-modal__header .email-subject {
  grid-area: subject;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  min-width: 0;
}


.pa-modal__close {
  grid-area: close;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  color: #1f2937;
  font-size: 1.6rem;
  line-height: 1;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}

.pa-modal__close:hover {
  background: #e2e8f0;
  color: #111827;
}

.pa-modal__body {
  margin-top: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
  min-height: 0;
}

.pa-modal__header .email-open-gmail {
  grid-area: gmail;
  justify-self: stretch;
  text-align: center;
}

.email-open-gmail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #e0ecff;
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
  white-space: nowrap;
}
.email-open-gmail:hover {
  background: #d1e3ff;
  color: #1e40af;
  box-shadow: 0 6px 16px rgba(29,78,216,.18);
}
.email-open-gmail.is-disabled {
  pointer-events: none;
  color: #9ca3af;
  cursor: not-allowed;
  background: #e5e7eb;
  box-shadow: none;
}

@media (min-width: 700px) {
  .pa-modal__header {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "subject gmail close";
    align-items: center;
  }
  .pa-modal__header .email-open-gmail {
    justify-self: end;
    width: auto;
  }
}

.email-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 14px 16px;
}

.email-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.95rem;
  color: #1f2937;
  line-height: 1.4;
}

.email-field-label {
  flex: 0 0 72px;
  font-weight: 600;
  color: #475569;
}

.email-field-value {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.email-body-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-body-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.pa-modal .email-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.pa-modal .email-body__frame {
  width: 100%;
  max-width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 22px 44px rgba(15,23,42,.14);
  overflow: hidden;
}

.pa-modal .email-body mark.pa-date {
  background: #ede2a5;
  color: inherit;
  padding: 0 .15em;
  border-radius: .2em;
}



.pa-modal .email-body__fallback {
  font-size: 0.95rem;
  color: #1f2937;
  line-height: 1.6;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f9fafb;
  padding: 14px 16px;
}

.pa-modal .email-body__fallback summary::-webkit-details-marker {
  display: none;
}

.pa-modal .email-body__fallback summary {
  list-style: none;
  position: relative;

  cursor: pointer;
  font-weight: 600;
  color: #2563eb;
  margin: -14px -16px 12px;
  padding: 12px 16px 13px;
  border-bottom: 1px solid #dbe3f2;
  background: #eef2ff;
  border-radius: 12px 12px 0 0;

}

.pa-modal .email-body__fallback[open] {
  background: #fff;
}

.pa-modal .email-body__fallback-content {
  margin-top: 8px;
}

.pa-modal .email-body__fallback--plain {
  border: 1px solid #e2e8f0;
  background: #fff;
  padding: 16px 18px;
  max-height: min(62vh, 640px);
  overflow-y: auto;
  padding-right: 12px;
  white-space: pre-wrap;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.pa-modal .email-body__fallback--plain > *:first-child {
  margin-top: 0;
}

.pa-modal .email-body__fallback--plain > *:last-child {
  margin-bottom: 0;
}



/* ============ Recent Emails Modal (hidden by default) ============ */
.recent-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: none;
  z-index: 10000;
  padding: 16px;
}
.recent-modal.open { display: block; }

.recent-dialog {
  max-width: 940px;
  margin: 36px auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.2);
  padding: 18px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #eee;
}
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px }
.recent-head .search { flex: 1; min-width: 200px }
.recent-body { display: grid; gap: 8px }
.recent-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid #eee; background: #f8fafc; border-radius: 12px; padding: 12px }
.recent-main { flex: 1 }

/* ============ Footer panel ============ */
.footer-panel { text-align: center; margin-top: 30px; padding: 20px; border-top: 1px solid #ddd; }
.update-link { color: #2563eb; font-weight: 600; text-decoration: none; font-size: 16px }
.update-link:hover { text-decoration: underline }

/* ===== Spinner / Loading Overlay ===== */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;               /* visible by default; JS hides after load */
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 6px solid #e5e7eb;
  border-top: 6px solid #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


.pa-modal .email-body__fallback summary::after {
  content: "\25BE";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s ease;
  font-size: 0.85rem;
  opacity: 0.7;
}
.pa-modal .email-body__fallback[open] summary::after {
  transform: translateY(-50%) rotate(180deg);
}










