/**
 * RuleFence -- help desk.
 *
 * Covers two surfaces the ticket plugin draws:
 *
 *   1. the form embedded in /support, inside `.wpam-ticket-form`
 *   2. the portal at /support/tickets/ and its routes, where the plugin owns
 *      the whole content area
 *
 * The plugin's own stylesheet loads after this one, so nothing here relies on
 * source order. Every rule is prefixed `body.wpam-site`, which is two classes
 * against the plugin's habitual one, and that is what wins.
 *
 * The controls deliberately match the ones on checkout -- 52px tall, one-pixel
 * --wpam-line border, --wpam-radius-sm corners, a 3px focus ring at 14% blue.
 * Somebody who has bought a licence and later files a ticket should not feel
 * they have wandered onto a different site, and matching the busiest form on
 * the site is cheaper than inventing a second style for this one.
 */

/* =============================================== 1. the embedded form */

body.wpam-site .wpam-ticket-form {
	margin-top: 28px;
	padding: 34px 32px 30px;
	border: 1px solid var(--wpam-line);
	border-radius: var(--wpam-radius);
	background: var(--wpam-surface);
	box-shadow: var(--wpam-shadow-sm);
}

/*
 * The plugin prints its own tab strip -- Dashboard, Submit Ticket, My Tickets,
 * Login -- at the top of every view. On the portal that strip is the
 * navigation and it stays. Inside /support it is a second, competing set of
 * links in the middle of a page that already has a header, a breadcrumb and a
 * table of contents, pointing at routes that now redirect elsewhere.
 */
body.wpam-site .wpam-ticket-form #jsst-header-main-wrapper {
	display: none;
}

/*
 * Cancel, in the embed, means "go to the plugin dashboard" -- a screen the
 * reader did not ask for and has no reason to see. There is nothing to cancel
 * back to from a page they arrived at directly.
 */
body.wpam-site .wpam-ticket-form .js-ticket-cancel-button {
	display: none;
}

/* ==================================================== 2. form layout */

body.wpam-site .js-ticket-add-form-wrapper,
body.wpam-site .js-ticket-form {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
}

/*
 * The plugin lays fields out as two floated halves. Grid does the same job
 * without the clearfix, and collapses to one column on its own at the width
 * where 412px halves stop being readable.
 */
body.wpam-site .js-ticket-form > .js-ticket-add-form-wrapper {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 0 22px;
}

body.wpam-site .js-ticket-from-field-wrp {
	width: auto;
	margin: 0 0 20px;
	padding: 0;
	float: none;
}

body.wpam-site .js-ticket-from-field-wrp-full-width {
	grid-column: 1 / -1;
}

body.wpam-site .js-ticket-from-field-title {
	margin: 0 0 7px;
	padding: 0;
	color: var(--wpam-ink-700);
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .01em;
	line-height: 1.4;
	text-align: left;
	text-transform: none;
}

/* The required marker is decoration around a word that already carries it. */
body.wpam-site .js-ticket-from-field-title span {
	color: var(--wpam-red-700);
	font-weight: 700;
}

body.wpam-site .js-ticket-from-field {
	width: 100%;
	margin: 0;
	padding: 0;
}

/* ======================================================= 3. controls */

body.wpam-site .js-ticket-form input[type="text"],
body.wpam-site .js-ticket-form input[type="email"],
body.wpam-site .js-ticket-form input[type="tel"],
body.wpam-site .js-ticket-form input[type="password"],
body.wpam-site .js-ticket-form input[type="number"],
body.wpam-site .js-ticket-form input[type="file"],
body.wpam-site .js-ticket-form select,
body.wpam-site .js-ticket-form textarea,
body.wpam-site .jsst-main-up-wrapper input.inputbox,
body.wpam-site .jsst-main-up-wrapper select.inputbox {
	width: 100%;
	min-height: 52px;
	margin: 0;
	padding: 13px 14px;
	border: 1px solid var(--wpam-line);
	border-radius: var(--wpam-radius-sm);
	color: var(--wpam-ink-900);
	background-color: var(--wpam-surface);
	box-shadow: none;
	font: inherit;
	font-size: 15px;
	line-height: 1.5;
}

body.wpam-site .js-ticket-form input[type="text"]:focus,
body.wpam-site .js-ticket-form input[type="email"]:focus,
body.wpam-site .js-ticket-form select:focus,
body.wpam-site .js-ticket-form textarea:focus,
body.wpam-site .jsst-main-up-wrapper input.inputbox:focus,
body.wpam-site .jsst-main-up-wrapper select.inputbox:focus {
	border-color: var(--wpam-blue-600);
	box-shadow: 0 0 0 3px rgba(56, 88, 233, .14);
	outline: 0;
}

/*
 * The plugin paints text inputs #fcfcfc from a four-deep descendant chain --
 * `div.js-ticket-add-form-wrapper div.js-ticket-from-field-wrp
 * div.js-ticket-from-field input` -- which outweighs the rule above on element
 * count, so the inputs came out a half-shade off white while the selects next
 * to them were white. Matching the chain is the honest way to win it; the
 * alternative is `!important` on a colour that is not worth an argument.
 */
body.wpam-site .jsst-main-up-wrapper .js-ticket-from-field-wrp .js-ticket-from-field input.js-ticket-form-field-input,
body.wpam-site .jsst-main-up-wrapper .js-ticket-from-field-wrp .js-ticket-from-field select.inputbox,
body.wpam-site .jsst-main-up-wrapper .js-ticket-from-field-wrp .js-ticket-from-field textarea.inputbox {
	background-color: var(--wpam-surface);
}

body.wpam-site .js-ticket-form ::placeholder {
	color: var(--wpam-ink-500);
	opacity: 1;
}

/* A native select keeps its own arrow; only the padding needs saying. */
body.wpam-site .js-ticket-form select {
	padding-right: 38px;
}

body.wpam-site .js-ticket-form input[type="file"] {
	padding: 12px 14px;
	color: var(--wpam-ink-700);
	font-size: 14px;
}

/* ================================================ 4. the message box */

/*
 * `wp_editor()` still wraps the textarea in its own containers even with both
 * editors switched off, and those carry WordPress admin styling. They are
 * flattened so the field is simply a textarea that matches every other control
 * on the form.
 */
body.wpam-site .wp-editor-wrap,
body.wpam-site .wp-editor-container {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
}

body.wpam-site textarea.wp-editor-area,
body.wpam-site textarea.wpam-ticket-message,
body.wpam-site .jsst-main-up-wrapper .js-ticket-from-field-wrp .js-ticket-from-field textarea.wp-editor-area {
	display: block;
	width: 100%;
	min-height: 260px;
	padding: 13px 14px;
	border: 1px solid var(--wpam-line);
	border-radius: var(--wpam-radius-sm);
	color: var(--wpam-ink-900);
	background-color: var(--wpam-surface);
	box-shadow: none;
	font: inherit;
	font-size: 15px;
	line-height: 1.6;
	resize: vertical;
}

body.wpam-site textarea.wp-editor-area:focus {
	border-color: var(--wpam-blue-600);
	box-shadow: 0 0 0 3px rgba(56, 88, 233, .14);
	outline: 0;
}

/* ================================================== 5. attachments */

body.wpam-site .js-ticket-reply-attachments {
	margin: 0 0 20px;
	padding: 18px 18px 14px;
	border: 1px dashed var(--wpam-line);
	border-radius: var(--wpam-radius-sm);
	background: var(--wpam-surface-alt);
}

body.wpam-site .js-attachment-field-title {
	margin: 0 0 10px;
	padding: 0;
	color: var(--wpam-ink-700);
	font-size: 13px;
	font-weight: 600;
	text-align: left;
}

body.wpam-site .js-attachment-field {
	padding: 0;
}

/*
 * The accepted-extension list is printed as one unbroken string of thirty-odd
 * file types. It is reference material, not instruction, so it is set small
 * and quiet rather than competing with the field it describes.
 */
body.wpam-site .tk_attachments_configform {
	display: block;
	margin: 8px 0 12px;
	color: var(--wpam-ink-500);
	font-size: 12.5px;
	line-height: 1.6;
	word-break: break-word;
}

body.wpam-site .tk_attachments_addform {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	padding: 0 16px;
	border: 1px solid var(--wpam-line);
	border-radius: var(--wpam-radius-sm);
	color: var(--wpam-ink-900);
	background: var(--wpam-surface);
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
}

body.wpam-site .tk_attachments_addform:hover {
	border-color: var(--wpam-blue-600);
	color: var(--wpam-blue-700);
}

/* ============================================ 6. terms and submit */

body.wpam-site .js-ticket-system-terms-and-condition-box {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin: 4px 0 24px;
}

body.wpam-site .js-ticket-system-terms-and-condition-box .js-ticket-from-field {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

body.wpam-site .js-ticket-system-terms-and-condition-box input[type="checkbox"] {
	width: 18px;
	min-height: 0;
	height: 18px;
	margin: 2px 0 0;
	padding: 0;
	flex: 0 0 auto;
	accent-color: var(--wpam-blue-600);
}

body.wpam-site .js-ticket-system-terms-and-condition-box label {
	margin: 0;
	color: var(--wpam-ink-700);
	font-size: 14.5px;
	line-height: 1.5;
}

body.wpam-site .termsandconditions_link_anchor {
	color: var(--wpam-blue-700);
	text-decoration: underline;
	text-underline-offset: 2px;
}

body.wpam-site .js-ticket-form-btn-wrp {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin: 0;
	padding: 22px 0 0;
	border-top: 1px solid var(--wpam-line-soft);
	text-align: left;
}

body.wpam-site .js-ticket-save-button,
body.wpam-site .js-ticket-form input[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	width: auto;
	padding: 0 26px;
	border: 0;
	border-radius: var(--wpam-radius-sm);
	color: #ffffff;
	background: var(--wpam-blue-600);
	box-shadow: none;
	cursor: pointer;
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
}

body.wpam-site .js-ticket-save-button:hover,
body.wpam-site .js-ticket-form input[type="submit"]:hover {
	background: var(--wpam-blue-700);
}

body.wpam-site .js-ticket-save-button:focus-visible,
body.wpam-site .js-ticket-form input[type="submit"]:focus-visible {
	outline: 2px solid var(--wpam-blue-800);
	outline-offset: 2px;
}

/* ================================================= 7. validation */

body.wpam-site .js-ticket-form .form-error,
body.wpam-site .jsst-main-up-wrapper .error,
body.wpam-site .help-block {
	margin: 6px 0 0;
	color: var(--wpam-red-700);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.5;
}

body.wpam-site .js-ticket-form .has-error input,
body.wpam-site .js-ticket-form .has-error select,
body.wpam-site .js-ticket-form input.error,
body.wpam-site .js-ticket-form select.error {
	border-color: var(--wpam-red-700);
}

/*
 * The honeypot is positioned at -9999px by the plugin and must stay reachable
 * to a bot and unreachable to everyone else. Nothing here may give it a
 * layout, so it is pinned out of the flow explicitly rather than trusted to
 * escape the rules above.
 */
body.wpam-site .jsst-verification-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ================================================== 8. the portal */

/*
 * Outside `.wpam-ticket-form` the plugin owns the page, and its tab strip is
 * the only navigation the customer has. It is restyled rather than hidden.
 */
body.wpam-site #jsst-header-main-wrapper {
	margin: 0 0 30px;
	padding: 0;
	border-bottom: 1px solid var(--wpam-line);
	background: none;
}

body.wpam-site #jsst-header {
	padding: 0;
	border: 0;
	background: none;
}

body.wpam-site #jsst-tabs-wrp {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	width: 100%;
	max-width: none;
}

body.wpam-site .jsst-header-tab {
	float: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

/*
 * The plugin styles these from `div#jsst-header span.jsst-header-tab
 * a.js-cp-menu-link` -- an id and three classes -- so the obvious
 * `body.wpam-site .jsst-header-tab a` loses and the tabs stayed as filled
 * pills. Carrying the same id is what it takes to win; the palette filter had
 * already made them the right colour, so this is about shape, not colour.
 */
body.wpam-site div#jsst-header span.jsst-header-tab a.js-cp-menu-link {
	display: block;
	padding: 11px 16px;
	border: 0;
	border-bottom: 2px solid transparent;
	border-radius: 0;
	color: var(--wpam-ink-600);
	background: none;
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 14.5px;
	font-weight: 600;
	text-decoration: none;
}

body.wpam-site div#jsst-header span.jsst-header-tab a.js-cp-menu-link:hover {
	color: var(--wpam-ink-900);
	background: none;
	border-bottom-color: var(--wpam-line);
}

body.wpam-site div#jsst-header span.jsst-header-tab a.js-cp-menu-link.wpam-tab-current,
body.wpam-site div#jsst-header span.jsst-header-tab.jsst-active a.js-cp-menu-link,
body.wpam-site div#jsst-header span.jsst-header-tab a.js-cp-menu-link.jsst-active,
body.wpam-site div#jsst-header span.jsst-header-tab a.js-cp-menu-link.active {
	color: var(--wpam-blue-700);
	background: none;
	border-bottom-color: var(--wpam-blue-600);
}

/* The header band itself is painted with the primary colour by the plugin. */
body.wpam-site div#jsst-header {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
}

/* ------------------------------------------------- 8b. portal tables */

body.wpam-site .jsst-main-up-wrapper table {
	width: 100%;
	margin: 0 0 22px;
	border-collapse: collapse;
	font-size: 14.5px;
}

body.wpam-site .jsst-main-up-wrapper th {
	padding: 12px 14px;
	border-bottom: 1px solid var(--wpam-line);
	color: var(--wpam-ink-700);
	background: var(--wpam-surface-alt);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .05em;
	text-align: left;
	text-transform: uppercase;
	white-space: nowrap;
}

body.wpam-site .jsst-main-up-wrapper td {
	padding: 14px;
	border-bottom: 1px solid var(--wpam-line-soft);
	color: var(--wpam-ink-800);
	vertical-align: top;
}

body.wpam-site .jsst-main-up-wrapper tr:hover td {
	background: var(--wpam-surface-alt);
}

/* A ticket list is wider than a phone; it scrolls rather than crushing. */
body.wpam-site .jsst-main-up-wrapper .js-ticket-table-wrapper,
body.wpam-site .jsst-main-up-wrapper .jsst-table-responsive {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------ 8c. portal panels */

body.wpam-site .jsst-main-up-wrapper .js-ticket-panel,
body.wpam-site .jsst-main-up-wrapper .jsst-panel,
body.wpam-site .jsst-main-up-wrapper .js-ticket-box {
	border: 1px solid var(--wpam-line);
	border-radius: var(--wpam-radius);
	background: var(--wpam-surface);
	box-shadow: var(--wpam-shadow-sm);
}

body.wpam-site .jsst-main-up-wrapper h1,
body.wpam-site .jsst-main-up-wrapper h2,
body.wpam-site .jsst-main-up-wrapper h3 {
	color: var(--wpam-ink-950);
	font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	letter-spacing: -.02em;
}

body.wpam-site .jsst-main-up-wrapper a {
	color: var(--wpam-blue-700);
}

/* ========================================== 9. narrow viewports */

@media (max-width: 781px) {
	body.wpam-site .wpam-ticket-form {
		padding: 24px 18px 22px;
	}

	body.wpam-site .js-ticket-form > .js-ticket-add-form-wrapper {
		grid-template-columns: 1fr;
		gap: 0;
	}

	body.wpam-site .js-ticket-save-button,
	body.wpam-site .js-ticket-form input[type="submit"] {
		width: 100%;
	}

	body.wpam-site textarea.wp-editor-area {
		min-height: 200px;
	}
}
