/*
 * Eastgate Client Portal — styles
 * Scoped entirely under .eastgate-portal so this never leaks into or
 * fights the host theme's global styles. Tokens per
 * .planning/phases/01-access-accounts/01-UI-SPEC.md.
 */

.eastgate-portal {
	--eastgate-accent: #2563EB;
	--eastgate-accent-hover: #1D4FD1;
	--eastgate-accent-tint: #EEF3FF;
	--eastgate-error: #B91C1C;
	--eastgate-error-tint: #FDECEC;
	--eastgate-ink: #1A1D23;
	--eastgate-ink-soft: #6B7280;
	--eastgate-line: #E4E7EC;
	--eastgate-surface: #FFFFFF;
	--eastgate-surface-2: #F7F8FA;
	--eastgate-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.07);
	--eastgate-radius: 14px;
	--eastgate-radius-sm: 10px;

	font-family: inherit;
	max-width: 640px;
	margin: 48px auto;
	padding: 0 20px;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	color: var(--eastgate-ink);
}

/* Fallback stack — only applies when no ancestor sets a font-family. */
:where(.eastgate-portal) {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.eastgate-portal-panel {
	background: var(--eastgate-surface);
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius);
	box-shadow: var(--eastgate-shadow);
	padding: 32px;
}

/* Deliberately no card/padding on .eastgate-portal-dashboard — the chat
   thread and compose bar inside it already have their own card
   treatment (background/border/shadow), so wrapping them in a second
   outer card just adds a redundant 32px of padding on every side. */

.eastgate-portal-panel + .eastgate-portal-panel {
	margin-top: 24px;
}

.eastgate-portal h2,
.eastgate-heading {
	font-size: 22px;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.eastgate-portal label,
.eastgate-label {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin-bottom: 6px;
	color: var(--eastgate-ink);
}

.eastgate-portal-field {
	margin-bottom: 18px;
}

.eastgate-portal-field:last-of-type {
	margin-bottom: 0;
}

.eastgate-portal input[type="text"],
.eastgate-portal input[type="email"],
.eastgate-portal input[type="password"],
.eastgate-portal button,
.eastgate-portal input[type="submit"] {
	min-height: 46px;
}

.eastgate-portal input[type="text"],
.eastgate-portal input[type="email"],
.eastgate-portal input[type="password"] {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius-sm);
	padding: 0 14px;
	font-family: inherit;
	font-size: 16px;
	background: var(--eastgate-surface-2);
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.eastgate-portal input[type="text"]:focus,
.eastgate-portal input[type="email"]:focus,
.eastgate-portal input[type="password"]:focus {
	outline: none;
	border-color: var(--eastgate-accent);
	background: var(--eastgate-surface);
	box-shadow: 0 0 0 3px var(--eastgate-accent-tint);
}

.eastgate-portal button,
.eastgate-portal input[type="submit"] {
	background: var(--eastgate-accent);
	color: #FFFFFF;
	border: none;
	border-radius: var(--eastgate-radius-sm);
	padding: 0 22px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
	transition: background 0.15s ease, transform 0.05s ease;
}

.eastgate-portal button:hover,
.eastgate-portal input[type="submit"]:hover {
	background: var(--eastgate-accent-hover);
}

.eastgate-portal button:active,
.eastgate-portal input[type="submit"]:active {
	transform: translateY(1px);
}

.eastgate-portal a {
	color: var(--eastgate-accent);
	font-weight: 500;
	text-decoration: none;
}

.eastgate-portal a:hover {
	text-decoration: underline;
}

.eastgate-error {
	color: var(--eastgate-error);
	background: var(--eastgate-error-tint);
	border-radius: var(--eastgate-radius-sm);
	padding: 10px 14px;
	margin-bottom: 16px;
	font-size: 14px;
}

.eastgate-portal input.eastgate-input--invalid {
	border-color: var(--eastgate-error);
}

.eastgate-portal-dashboard h2 {
	margin-top: 0;
}

.eastgate-portal-dashboard p {
	margin-bottom: 4px;
	color: var(--eastgate-ink-soft);
}

.eastgate-document-list {
	list-style: none;
	margin: 0 0 24px;
	padding: 0;
}

.eastgate-document-row {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	padding: 8px 0;
	border-bottom: 1px solid var(--eastgate-line);
}

.eastgate-document-row:last-child {
	border-bottom: none;
}

.eastgate-document-row__title {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.5;
}

.eastgate-document-row__meta {
	font-size: 14px;
	font-weight: 400;
	line-height: 1.4;
	margin-top: 8px;
}

.eastgate-portal-dashboard form + form {
	margin-top: 32px;
}

.eastgate-comment-thread {
	/* .eastgate-document-row is display:flex; force this onto its own
	   line below the title/meta/action-link flex items. */
	flex-basis: 100%;
	width: 100%;
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid #D9D9D9;
}

.eastgate-comment {
	margin-bottom: 16px;
}

.eastgate-comment:last-of-type {
	margin-bottom: 0;
}

.eastgate-comment__meta {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin-bottom: 4px;
}

.eastgate-comment__content {
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
}

.eastgate-comment-form {
	margin-top: 16px;
}

.eastgate-comment-form textarea {
	width: 100%;
	min-height: 80px;
	box-sizing: border-box;
	font-family: inherit;
	font-size: 14px;
	margin-bottom: 8px;
}

/* Phase 4 — chat widget: thread/compose/bubble styles. */

.eastgate-chat-thread {
	max-height: 720px;
	overflow-y: auto;
	background: var(--eastgate-surface-2);
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius);
	padding: 20px;
	scroll-behavior: smooth;
	/* Recessed "groove" — shading on both the top and bottom inner edges,
	   not just a faint all-around tint — is what actually reads as an
	   inset/sunken scroll area (the same trick Slack/Gmail scroll panes
	   use), vs. the compose bar below which is raised (drop shadow). */
	box-shadow:
		inset 0 10px 14px -12px rgba(16, 24, 40, 0.22),
		inset 0 -10px 14px -12px rgba(16, 24, 40, 0.16);
}

.eastgate-chat-empty {
	text-align: center;
	color: var(--eastgate-ink-soft);
	padding: 24px 0;
}

.eastgate-chat-compose {
	background: var(--eastgate-surface);
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius);
	margin-top: 12px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	box-shadow: var(--eastgate-shadow);
}

.eastgate-chat-compose-row {
	display: flex;
	align-items: flex-end;
	gap: 10px;
}

.eastgate-chat-compose-field {
	position: relative;
	flex: 1;
}

.eastgate-chat-compose textarea {
	width: 100%;
	min-height: 46px;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	box-sizing: border-box;
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius-sm);
	padding: 12px 76px 12px 14px;
	background: var(--eastgate-surface-2);
	resize: vertical;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.eastgate-chat-compose textarea::placeholder {
	color: var(--eastgate-ink-soft);
}

.eastgate-chat-compose textarea:focus {
	outline: none;
	border-color: var(--eastgate-accent);
	background: var(--eastgate-surface);
	box-shadow: 0 0 0 3px var(--eastgate-accent-tint);
}

.eastgate-chat-staged-attachment {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: var(--eastgate-accent-tint);
	border-radius: var(--eastgate-radius-sm);
	padding: 8px 12px;
}

/* The [hidden] boolean attribute relies on the browser's own
   "[hidden] { display: none }" UA rule — but that rule has the same
   specificity as the plain-class ".eastgate-chat-staged-attachment"
   rule above, and author CSS wins ties over the UA stylesheet, so
   "display: flex" above was silently overriding "hidden" and showing
   this row on every page load regardless of the attribute. Re-assert
   display:none here (class + attribute = higher specificity than the
   class alone) so hidden actually hides it again. */
.eastgate-chat-staged-attachment[hidden] {
	display: none;
}

.eastgate-chat-staged-attachment__name {
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	color: var(--eastgate-accent-hover);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.eastgate-chat-staged-attachment a,
.eastgate-chat-compose-link a {
	font-size: 13px;
	flex-shrink: 0;
}

.eastgate-chat-compose-link {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Same [hidden]-vs-"display:flex" specificity-tie issue as
   .eastgate-chat-staged-attachment[hidden] above. */
.eastgate-chat-compose-link[hidden] {
	display: none;
}

.eastgate-chat-compose-link input[type="url"] {
	flex: 1;
	min-height: 44px;
	box-sizing: border-box;
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius-sm);
	padding: 0 14px;
	background: var(--eastgate-surface-2);
}

.eastgate-chat-compose-link input[type="url"]:focus {
	outline: none;
	border-color: var(--eastgate-accent);
	background: var(--eastgate-surface);
	box-shadow: 0 0 0 3px var(--eastgate-accent-tint);
}

.eastgate-chat-compose-tools {
	position: absolute;
	right: 8px;
	bottom: 8px;
	display: flex;
	align-items: center;
	gap: 6px;
}

/* Qualified as .eastgate-portal button.eastgate-chat-tool-btn (not just
   .eastgate-chat-tool-btn alone) so this deliberately outweighs the
   generic ".eastgate-portal button" rule (same specificity family, one
   more class) instead of silently losing to it — a plain-class selector
   here would keep that rule's accent-blue fill/46px sizing and never
   actually apply this compact square icon-well look. Sits *inside* the
   textarea itself (see .eastgate-chat-compose-field's position:relative),
   background a shade darker than the textarea's own surface, icon tinted
   the same blue as the Send button so both read as "the same action
   family" at a glance. */
.eastgate-portal button.eastgate-chat-tool-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1;
	width: 30px;
	height: auto;
	min-height: 0;
	padding: 6px;
	background: var(--eastgate-line);
	color: var(--eastgate-accent);
	border: none;
	border-radius: var(--eastgate-radius-sm);
	box-shadow: none;
	cursor: pointer;
	transition: background 0.15s ease;
}

.eastgate-portal button.eastgate-chat-tool-btn:hover {
	background: #D6DAE2;
}

/* Same specificity reasoning as .eastgate-chat-tool-btn above — this
   keeps the generic rule's accent-blue fill (that part we want) but
   overrides its pill shape/padding into a circular icon-only FAB, the
   conventional "primary send action" shape in chat UIs. */
.eastgate-portal button.eastgate-chat-send-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1;
	width: 46px;
	height: 46px;
	min-height: 46px;
	padding: 0;
	border-radius: 999px;
	flex-shrink: 0;
}

.eastgate-portal button.eastgate-chat-send-btn svg {
	/* Optical centering — a paper-plane glyph's own visual weight sits
	   slightly left/up of its bounding box; nudge it to look centered
	   inside the circle rather than technically-centered. */
	transform: translate(1px, -1px);
}

/* Message bubbles — identical values to assets/css/crm-thread.css (Plan
   04-04); intentionally duplicated rather than @import'd, since the two
   files are enqueued on entirely different surfaces (front-end portal
   page vs. wp-admin Conversation screen) that must never share a
   stylesheet, per 04-UI-SPEC.md's Design System boundary. */
.eastgate-message {
	display: flex;
	flex-direction: column;
	margin-bottom: 12px;
}

.eastgate-message__sender {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	margin-bottom: 4px;
	color: var(--eastgate-ink-soft, #6B7280);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.eastgate-message__bubble {
	max-width: 75%;
	padding: 12px 16px;
	border: none;
	border-radius: 18px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.eastgate-message--own {
	align-items: flex-end;
}

.eastgate-message--own .eastgate-message__bubble {
	background: var(--eastgate-accent, #2563EB);
	color: #FFFFFF;
	border-bottom-right-radius: 4px;
}

.eastgate-message--own .eastgate-message__timestamp {
	color: var(--eastgate-ink-soft, #6B7280);
}

.eastgate-message--other {
	align-items: flex-start;
}

.eastgate-message--other .eastgate-message__bubble {
	background: #FFFFFF;
	border: 1px solid var(--eastgate-line, #E4E7EC);
	border-bottom-left-radius: 4px;
}

.eastgate-message__text {
	font-size: 15px;
	font-weight: 400;
	line-height: 1.5;
}

.eastgate-mention {
	cursor: pointer;
	font-weight: 700;
}

/* "other" bubbles are white — a bright accent blue reads clearly.
   "own" bubbles are already accent-blue-filled with white text, so the
   mention differentiates by underline instead of a color that would
   disappear against its own background. */
.eastgate-message--other .eastgate-mention {
	color: var(--eastgate-accent);
}

.eastgate-message--other .eastgate-mention:hover {
	text-decoration: underline;
}

.eastgate-message--own .eastgate-mention {
	text-decoration: underline;
}

/* Momentary highlight when a mention click scrolls this bubble into
   view — a 4x scale pulse over 3s (0.75s per pulse), removed by chat.js
   after it finishes so it can be re-triggered on a repeat click. */
@keyframes eastgate-message-highlight {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.1); }
}

.eastgate-message--jump-highlight .eastgate-message__bubble {
	animation: eastgate-message-highlight 0.75s ease-in-out 4;
	transform-origin: center;
}

.eastgate-message__timestamp {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.4;
	margin-top: 4px;
	color: var(--eastgate-ink-soft, #6B7280);
}

.eastgate-message__attachment {
	margin-top: 8px;
}

.eastgate-message__image {
	max-width: 100%;
	max-height: 240px;
	object-fit: contain;
	border-radius: 12px;
	display: block;
}

/* Compact file chip — replaces the old inline PDF.js canvas / SheetJS
   table preview entirely (client feedback: the big auto-rendered
   preview took over the bubble; a filename + View/Download is enough).
   Own surface/border so it reads clearly even inside the accent-filled
   "own" bubble, where the default bubble text is white. */
.eastgate-message__file-chip {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--eastgate-surface, #FFFFFF);
	border: 1px solid var(--eastgate-line, #E4E7EC);
	border-radius: 10px;
	padding: 8px 10px;
	max-width: 100%;
}

.eastgate-message__file-icon {
	display: inline-flex;
	flex-shrink: 0;
	color: var(--eastgate-ink-soft, #6B7280);
}

.eastgate-message__file-name {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	font-weight: 500;
	color: var(--eastgate-ink, #1A1D23);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.eastgate-message__file-action {
	flex-shrink: 0;
	font-size: 13px;
	font-weight: 600;
	color: var(--eastgate-accent, #2563EB);
	text-decoration: none;
}

.eastgate-message__file-action:hover {
	text-decoration: underline;
}

/* ---- Chat / Documents tabs ---- */

.eastgate-chat-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 12px;
	border-bottom: 1px solid var(--eastgate-line);
}

.eastgate-portal button.eastgate-chat-tab {
	background: transparent;
	color: var(--eastgate-ink-soft);
	border: none;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	box-shadow: none;
	min-height: 0;
	padding: 8px 4px;
	margin-bottom: -1px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.eastgate-portal button.eastgate-chat-tab.is-active {
	color: var(--eastgate-accent);
	border-bottom-color: var(--eastgate-accent);
}

.eastgate-chat-panel[hidden] {
	display: none;
}

/* ---- Documents tab ---- */

.eastgate-doc-search-wrap {
	margin-bottom: 12px;
}

.eastgate-portal input.eastgate-doc-search {
	width: 100%;
	min-height: 42px;
	box-sizing: border-box;
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius-sm);
	padding: 0 14px;
	font-family: inherit;
	font-size: 14px;
	background: var(--eastgate-surface-2);
}

.eastgate-doc-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 720px;
	overflow-y: auto;
}

.eastgate-doc-row {
	background: var(--eastgate-surface-2);
	border-radius: var(--eastgate-radius-sm);
	padding: 10px;
}

.eastgate-doc-row .eastgate-message__file-chip {
	border: none;
	padding: 0;
	background: transparent;
}

.eastgate-doc-row__meta {
	margin-top: 6px;
	padding-left: 28px;
	font-size: 12px;
	color: var(--eastgate-ink-soft);
}

.eastgate-portal button.eastgate-doc-row__jump {
	background: transparent;
	border: none;
	box-shadow: none;
	padding: 0;
	min-height: 0;
	font-size: 12px;
	color: var(--eastgate-accent);
}

/* ---- Scroll-to-latest floating button ---- */

.eastgate-chat-thread-wrap {
	position: relative;
}

.eastgate-portal button.eastgate-chat-scroll-bottom-btn {
	position: absolute;
	right: 12px;
	bottom: 12px;
	width: 36px;
	height: 36px;
	min-height: 36px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--eastgate-surface);
	color: var(--eastgate-accent);
	border: 1px solid var(--eastgate-line);
	border-radius: 999px;
	box-shadow: var(--eastgate-shadow);
}

/* Same [hidden]-vs-author-rule specificity tie as the other [hidden]
   overrides in this file — without this, the button above never
   actually disappears since its own `display: inline-flex` beats the
   browser's default `[hidden] { display: none }` at equal specificity. */
.eastgate-portal button.eastgate-chat-scroll-bottom-btn[hidden] {
	display: none;
}

/* ---- "@" document mention popup ---- */

.eastgate-chat-mention-popup {
	position: absolute;
	left: 0;
	right: 76px;
	bottom: calc(100% + 6px);
	background: var(--eastgate-surface);
	border: 1px solid var(--eastgate-line);
	border-radius: var(--eastgate-radius-sm);
	box-shadow: var(--eastgate-shadow);
	max-height: 200px;
	overflow-y: auto;
	z-index: 5;
}

.eastgate-chat-mention-popup[hidden] {
	display: none;
}

.eastgate-portal button.eastgate-mention-popup__item {
	display: block;
	width: 100%;
	text-align: left;
	background: transparent;
	border: none;
	box-shadow: none;
	border-radius: 0;
	min-height: 0;
	padding: 8px 12px;
	font-size: 14px;
	font-weight: 400;
	color: var(--eastgate-ink);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.eastgate-portal button.eastgate-mention-popup__item.is-active,
.eastgate-portal button.eastgate-mention-popup__item:hover {
	background: var(--eastgate-accent-tint);
	color: var(--eastgate-accent-hover);
}

.eastgate-mention-popup__empty {
	padding: 8px 12px;
	font-size: 13px;
	color: var(--eastgate-ink-soft);
}

/* ---- Staff preview mode (Eastgate_Shortcode::render()'s staff branch) ---- */

.eastgate-portal[data-eastgate-preview] {
	cursor: not-allowed;
}

.eastgate-preview-notice {
	position: fixed;
	left: 50%;
	bottom: 32px;
	transform: translateX(-50%);
	max-width: 90vw;
	background: var(--eastgate-ink);
	color: #FFFFFF;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	padding: 12px 20px;
	border-radius: 10px;
	box-shadow: var(--eastgate-shadow);
	z-index: 9999;
}

/* Same [hidden]-vs-author-rule specificity tie as every other [hidden]
   override in this file — without this, the notice above would stay
   visible even while [hidden], since its own unconditional properties
   (position, background, etc.) tie with the browser's default
   [hidden] { display: none } at equal specificity. */
.eastgate-preview-notice[hidden] {
	display: none;
}

@keyframes eastgate-preview-shake {
	10%, 90% { transform: translateX(calc(-50% - 1px)); }
	20%, 80% { transform: translateX(calc(-50% + 2px)); }
	30%, 50%, 70% { transform: translateX(calc(-50% - 4px)); }
	40%, 60% { transform: translateX(calc(-50% + 4px)); }
}

.eastgate-preview-notice.is-shaking {
	animation: eastgate-preview-shake 0.5s ease-in-out;
}
