/* Parish Website Assistant - Widget Styles */
/* Colors are set as CSS variables by widget.js from detected theme styles */

:root {
  --pwa-primary:    #1a3a2a;
  --pwa-dark:       #0f2218;
  --pwa-accent:     #c8a84b;
  --pwa-text:       #2c1f0e;
  --pwa-bg:         #faf8f4;
  --pwa-font:       system-ui, sans-serif;
  --pwa-radius:     12px;
  --pwa-radius-sm:  8px;
  --pwa-shadow:     0 4px 20px rgba(0,0,0,0.18);
}

/* ── Trigger Bubble ── */
#pwa-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: linear-gradient(145deg, var(--pwa-primary), var(--pwa-dark));
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 0 rgba(0,0,0,0.15);
  z-index: 999998;
  border: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: pwa-pulse 3s ease-out infinite;
}
#pwa-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.38);
}
#pwa-trigger svg {
  width: 28px; height: 28px;
  fill: none; stroke: #fff;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pwa-badge {
  position: absolute;
  top: -3px; right: -3px;
  width: 18px; height: 18px;
  background: var(--pwa-accent);
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 9px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
@keyframes pwa-pulse {
  0%   { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 0 rgba(0,0,0,0.2); }
  60%  { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 14px rgba(0,0,0,0); }
  100% { box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 0 rgba(0,0,0,0); }
}

/* ── Tooltip ── */
#pwa-tooltip {
  position: fixed;
  bottom: 38px; right: 100px;
  background: var(--pwa-primary);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: var(--pwa-radius-sm);
  font-size: 0.82rem;
  font-family: var(--pwa-font);
  white-space: nowrap;
  pointer-events: none;
  z-index: 999997;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.25s, transform 0.25s;
}
#pwa-tooltip::after {
  content: '';
  position: absolute;
  right: -7px; top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--pwa-primary);
  border-right: 0;
}
#pwa-trigger:hover + #pwa-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* ── Panel ── */
#pwa-panel {
  position: fixed;
  bottom: 0; right: 0;
  width: 400px;
  height: 100vh;
  max-height: 100vh;
  background: var(--pwa-bg);
  box-shadow: -6px 0 40px rgba(0,0,0,0.18);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  transform: translateX(110%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  font-family: var(--pwa-font);
}
#pwa-panel.pwa-open { transform: translateX(0); }

/* ── Header ── */
.pwa-header {
  background: linear-gradient(135deg, var(--pwa-primary) 0%, color-mix(in srgb, var(--pwa-primary) 70%, #fff) 100%);
  padding: 1rem 1.1rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.pwa-avatar {
  width: 42px; height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
  color: var(--pwa-accent);
}
.pwa-header-text { flex: 1; }
.pwa-header-text h2 {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}
.pwa-header-text p {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  margin: 2px 0 0;
}
.pwa-status { display: flex; align-items: center; gap: 5px; }
.pwa-status-dot {
  width: 7px; height: 7px;
  background: #5dd68a;
  border-radius: 50%;
  animation: pwa-blink 2s ease-in-out infinite;
}
@keyframes pwa-blink { 0%,100%{opacity:1} 50%{opacity:0.4} }
.pwa-close {
  background: rgba(255,255,255,0.1);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s;
  flex-shrink: 0;
}
.pwa-close:hover { background: rgba(255,255,255,0.2); }

/* ── Tabs ── */
.pwa-tabs {
  display: flex;
  background: var(--pwa-dark);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.pwa-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.2s;
  font-family: var(--pwa-font);
}
.pwa-tab.active {
  color: var(--pwa-accent);
  border-bottom: 2px solid var(--pwa-accent);
}
.pwa-tab:hover:not(.active) { color: rgba(255,255,255,0.85); }

/* ── Messages ── */
#pwa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}
#pwa-messages::-webkit-scrollbar { width: 4px; }
#pwa-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
#pwa-messages.active { display: flex; }
#pwa-messages:not(.active) { display: none; }

/* ── Parish Info Panel ── */
#pwa-info-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#pwa-info-panel.active { display: flex; }
#pwa-info-panel:not(.active) { display: none; }

.pwa-info-card {
  background: #fff;
  border-radius: var(--pwa-radius-sm);
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  border-left: 3px solid var(--pwa-primary);
}
.pwa-info-card h4 {
  font-size: 0.95rem;
  color: var(--pwa-primary);
  margin: 0 0 0.5rem;
}
.pwa-info-card p,
.pwa-info-card li {
  font-size: 0.85rem;
  color: var(--pwa-text);
  line-height: 1.6;
  margin: 0;
}
.pwa-info-card ul { padding-left: 1rem; }

/* ── Transparency Notice Panel ── */
#pwa-notice-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#pwa-notice-panel.active { display: flex; }
#pwa-notice-panel:not(.active) { display: none; }

.pwa-notice-back {
  background: #f0ebe0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.pwa-notice-back:hover { background: #e8dfd0; }
.pwa-notice-back svg {
  width: 16px; height: 16px;
  fill: none; stroke: var(--pwa-primary);
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.pwa-notice-back span {
  font-size: 0.8rem;
  color: var(--pwa-primary);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pwa-notice-body { padding: 1.2rem 1.1rem; flex: 1; }
.pwa-notice-body h1 {
  font-size: 1.15rem;
  color: var(--pwa-primary);
  margin: 0 0 0.2rem;
}
.pwa-notice-subtitle {
  font-size: 0.75rem;
  color: #7a6a58;
  font-style: italic;
  margin: 0 0 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.pwa-notice-body h2 {
  font-size: 0.95rem;
  color: var(--pwa-primary);
  margin: 1.1rem 0 0.4rem;
}
.pwa-notice-body p,
.pwa-notice-body li {
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--pwa-text);
  margin: 0 0 0.4rem;
}
.pwa-notice-body ul,
.pwa-notice-body ol { padding-left: 1.2rem; margin-bottom: 0.5rem; }
.pwa-notice-italic { font-style: italic; color: #5a4a38; }
.pwa-notice-footer {
  margin-top: 1.2rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  font-size: 0.75rem;
  color: #7a6a58;
  font-style: italic;
}

/* ── Message Bubbles ── */
.pwa-msg {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  animation: pwa-fadeup 0.25s ease;
}
@keyframes pwa-fadeup {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.pwa-msg.user { flex-direction: row-reverse; }
.pwa-msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.pwa-msg.assistant .pwa-msg-avatar {
  background: linear-gradient(135deg, var(--pwa-primary), color-mix(in srgb, var(--pwa-primary) 70%, #fff));
  color: var(--pwa-accent);
}
.pwa-msg.user .pwa-msg-avatar {
  background: rgba(0,0,0,0.08);
  color: var(--pwa-text);
}
.pwa-bubble {
  max-width: 78%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--pwa-radius);
  font-size: 0.88rem;
  line-height: 1.6;
}
.pwa-msg.assistant .pwa-bubble {
  background: #fff;
  color: var(--pwa-text);
  border-radius: 4px var(--pwa-radius) var(--pwa-radius) var(--pwa-radius);
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.pwa-msg.user .pwa-bubble {
  background: var(--pwa-primary);
  color: #fff;
  border-radius: var(--pwa-radius) 4px var(--pwa-radius) var(--pwa-radius);
}
.pwa-source {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  font-size: 0.72rem;
  color: #7a6a58;
}

/* ── Typing indicator ── */
.pwa-typing .pwa-bubble {
  padding: 0.8rem 1rem;
  display: flex;
  gap: 4px;
  align-items: center;
}
.pwa-typing .dot {
  width: 7px; height: 7px;
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  animation: pwa-bounce 1.2s ease-in-out infinite;
}
.pwa-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.pwa-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pwa-bounce {
  0%,60%,100% { transform:translateY(0); }
  30%          { transform:translateY(-6px); }
}

/* ── Suggestions ── */
.pwa-suggestions {
  padding: 0 1.1rem 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}
.pwa-suggest-btn {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 50px;
  padding: 0.35rem 0.8rem;
  font-size: 0.76rem;
  color: var(--pwa-primary);
  cursor: pointer;
  font-family: var(--pwa-font);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.pwa-suggest-btn:hover {
  background: rgba(0,0,0,0.04);
  border-color: var(--pwa-primary);
}

/* ── Input Area ── */
.pwa-input-area {
  padding: 0.8rem 1rem;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-shrink: 0;
}
#pwa-input {
  flex: 1;
  border: 1.5px solid rgba(0,0,0,0.15);
  border-radius: 20px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-family: var(--pwa-font);
  color: var(--pwa-text);
  background: var(--pwa-bg);
  resize: none;
  outline: none;
  overflow-y: hidden;
  transition: border-color 0.2s;
}
#pwa-input:focus { border-color: var(--pwa-primary); }
#pwa-input::placeholder { color: rgba(0,0,0,0.35); }
#pwa-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--pwa-primary);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
#pwa-send:hover {
  background: color-mix(in srgb, var(--pwa-primary) 80%, #fff);
  transform: scale(1.05);
}
#pwa-send:disabled { background: rgba(0,0,0,0.2); cursor: not-allowed; transform: none; }
#pwa-send svg {
  width: 16px; height: 16px;
  fill: #fff;
}

/* ── Disclosure ── */
.pwa-disclosure {
  padding: 0.45rem 1rem;
  background: rgba(0,0,0,0.03);
  border-top: 1px solid rgba(0,0,0,0.07);
  font-size: 0.68rem;
  color: rgba(0,0,0,0.45);
  text-align: center;
  flex-shrink: 0;
  line-height: 1.4;
  font-family: var(--pwa-font);
}
.pwa-disclosure a {
  color: var(--pwa-primary);
  text-decoration: none;
  cursor: pointer;
}
.pwa-disclosure a:hover { text-decoration: underline; }

@media (max-width: 440px) {
  #pwa-panel { width: 100vw; }
}
