/**
 * File Path: assets/css/admin/mbs-book-editor.css
 *
 * Book Editor Shell Styles
 *
 * Tab bar, section sub-nav, and content panel layout for the WooCommerce-style
 * Book Editor shell. Depends on wp-admin for nav-tab and subsubsub base styles.
 *
 * Handle: mbs-book-editor-styles
 * Dependency: wp-admin
 *
 * @package    My_Book_Showroom
 * @since      1.2.0
 */

/* MBS Admin Design Tokens — scoped here because the Book Editor metabox
 * renders on the post-edit screen outside #mbs-settings-wrap.
 * Mirrors the token block in mbs-admin.css exactly. Added Phase 1, Session 196.
 */
#mbs-editor-shell-wrap {
    --mbs-navy:          #2C3E6B;
    --mbs-navy-light:    #4A5F8A;
    --mbs-navy-dark:     #1A2B50;
    --mbs-teal:          #4AABB8;
    --mbs-teal-dark:     #2E8A96;
    --mbs-teal-pale:     #D4EEF1;
    --mbs-lavender:      #C8B4D4;
    --mbs-lavender-pale: #EDE8F4;
    --mbs-beige:         #F4F0E8;
    --mbs-beige-dark:    #E0D8C8;
    --mbs-slate:         #5A6472;
    --mbs-mist:          #9AABBA;
    --mbs-serif:         Georgia, "Times New Roman", serif;
    --mbs-sans:          Arial, "Helvetica Neue", Helvetica, sans-serif;
    /* Semantic status tokens */
    --mbs-status-ok:     #00a32a;
    --mbs-status-err:    #d63638;
    --mbs-status-warn:   #f0c33c;
    --mbs-status-info:   #2271b1;
    --mbs-status-info-dark: #135e96;
}

/* ── Outer wrapper ────────────────────────────────────────────────────────── */

.mbs-editor-wrap {
	padding: 12px 0 0;
	background: transparent;
}

/* ── Domain tab bar ───────────────────────────────────────────────────────── */

.mbs-editor-tab-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	border-bottom: 1px solid #c3c4c7;
	margin-bottom: 0;
	padding-bottom: 0;
}

.mbs-editor-tab-bar .nav-tab-active {
	border-bottom-color: #f0f0f1;
	background: #f0f0f1;
}

.mbs-editor-tab-bar .nav-tab:focus-visible {
	outline: 2px solid var(--mbs-status-info);
	outline-offset: 2px;
}

/* ── Section sub-nav ──────────────────────────────────────────────────────── */

/* Pill-strip container — mirrors .mbs-catalog-subnav in mbs-admin-settings.css.
 * display:block is set inline by JS activate(); overflow:hidden clears the
 * WP .subsubsub li { float:left } so the <ul> expands around its pill children. */
.mbs-editor-subnav {
	margin: 8px 0 12px;
	padding: 8px 10px;
	background: var(--mbs-teal-pale);
	border: 1px solid #dcdcde;
	border-radius: 4px;
	overflow: hidden;
	clear: both;
	line-height: 1;
}

/* Hide all domain sub-navs when JS is active; activate() reveals the active one */
.mbs-editor-wrap.mbs-js .mbs-editor-subnav {
	display: none;
}

/* Pill items: reset WP .subsubsub li { float: left } */
.mbs-editor-subnav li {
	float: none;
	display: inline-block;
	margin: 0 2px 0 0;
	padding: 0;
}

/* Hide pipe separators */
.mbs-editor-subnav li .sep {
	display: none;
}

/* Inactive pill link */
.mbs-editor-subnav li a {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 14px;
	border-radius: 3px;
	border: 1px solid var(--mbs-teal);
	color: var(--mbs-teal);
	text-decoration: none;
	font-size: 13px;
	line-height: 1.5;
	font-weight: 500;
	transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.mbs-editor-subnav li a:hover,
.mbs-editor-subnav li a:focus {
	background: var(--mbs-teal);
	color: #fff;
	border-color: var(--mbs-teal-dark);
	outline: none;
}

/* Active pill link */
.mbs-editor-subnav li.current a {
	background: var(--mbs-navy);
	color: #fff;
	border-color: var(--mbs-navy);
	cursor: default;
	pointer-events: none;
}

.mbs-editor-subnav li.current a:hover,
.mbs-editor-subnav li.current a:focus {
	background: var(--mbs-navy);
	color: #fff;
}

/* ── Content panels ───────────────────────────────────────────────────────── */

.mbs-editor-panel {
	padding: 12px 0 0;
	min-height: 120px;
}

/* Hide all panels when JS is active; activate() reveals the target via display:block */
.mbs-editor-wrap.mbs-js .mbs-editor-panel {
	display: none;
}

.mbs-editor-panel:focus-visible {
	outline: 2px solid var(--mbs-status-info);
	outline-offset: 2px;
}

/* ── Format row: two-column layout ───────────────────────────────────────── */

/*
 * .mbs-format-cols   — CSS Grid wrapper: left (core+format) / right (price+media+buy).
 * .mbs-format-full-width — Supply Chain and POS fields always span full width.
 * .mbs-field-pair    — Flex row for fields that sit side-by-side (Edition # / Type).
 *
 * Collapse to single column below 900 px so narrow metabox panels stay usable.
 */

.mbs-format-cols {
	display: grid;
	grid-template-columns: 60fr 40fr;
	gap: 0 24px;
	align-items: start;
}

.mbs-format-col--left,
.mbs-format-col--right {
	min-width: 0; /* prevent grid blowout on narrow viewports */
}

.mbs-format-full-width {
	grid-column: 1 / -1; /* not inside .mbs-format-cols, but present as sibling */
}

@media (max-width: 900px) {
	.mbs-format-cols {
		grid-template-columns: 1fr;
	}
}

/* ── Paired fields (Edition # / Edition Type inline) ─────────────────────── */

.mbs-field-pair {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	align-items: flex-start;
}

.mbs-field-pair .mbs-field {
	flex: 1 1 140px; /* shrink gracefully; min ~140 px before wrapping */
}

/* ── Edition # field: fixed narrow width inside pair ─────────────────────── */

/*
 * Edition # is a 1-3 digit number; it should stay narrow so Edition Type
 * (which has long option strings) gets the remaining flex space.
 */

.mbs-field-pair .mbs-field:first-child {
	flex: 0 0 90px;
	min-width: 0;
}

/* ── Format row section heading (Buy Links, etc.) ────────────────────────── */

.mbs-format-section-heading {
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	margin: 12px 0 6px;
	padding: 0;
	border-bottom: 1px solid #dcdcde;
	padding-bottom: 4px;
}

/* ── Format repeater: toolbar (Expand All / Collapse All) ────────────────── */

.mbs-format-repeater-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
	font-size: 13px;
}

.mbs-format-repeater-toolbar .button-link {
	color: var(--mbs-status-info);
	text-decoration: none;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
	font-size: 13px;
}

.mbs-format-repeater-toolbar .button-link:hover {
	color: var(--mbs-status-info-dark);
	text-decoration: underline;
}

.mbs-toolbar-sep {
	color: #c3c4c7;
	user-select: none;
}

/* ── Format row header: drag handle + reorder controls ──────────────────── */

/*
 * Base rules for .mbs-drag-handle, .mbs-reorder-controls, .mbs-reorder-move-up/down,
 * and .mbs-sortable-placeholder are in mbs-sortable.css.
 * Format-row-specific overrides below.
 */

.mbs-format-row-header .mbs-drag-handle {
	margin-right: 4px;
}

.mbs-format-row-header .mbs-reorder-controls {
	margin-left: auto; /* push to right side of header, before Remove */
	margin-right: 6px;
}

/* Height matches collapsed format row so the drop zone is visible. */
#mbs-formats-rows .mbs-sortable-placeholder {
	height: 48px;
}

/* Phase 1-B (UX-EDIT-002): hide pill subnav for single-section domains. */
.mbs-editor-subnav[data-mbs-single="true"] { display: none !important; }

/* Phase 2-A (UX-EDIT-002): PRO lock visual treatment in section order UI. */
.mbs-sortable-item.mbs-pro-locked {
	opacity: 0.55;
	cursor: default;
}
.mbs-sortable-item.mbs-pro-locked .mbs-drag-handle {
	visibility: hidden;
}
.mbs-pro-lock-icon {
	color: #999;
	margin-right: 4px;
	vertical-align: middle;
}
tr.mbs-pro-locked {
	opacity: 0.55;
	cursor: default;
}
tr.mbs-pro-locked .mbs-drag-handle {
	visibility: hidden;
}
/* =============================================================================
   Section Order metabox — draggable item layout (UX-NAV-001 Phase G)
   Provides the base flex layout for #mbs-section-sortable <li> items.
   The shared mbs-sortable.css only covers the drag handle and placeholder;
   this block handles the full row layout specific to the book editor context.
   ============================================================================= */

#mbs-section-sortable {
	list-style: none;
	padding: 0;
	margin: 4px 0 0;
	border: 1px solid #c3c4c7;
	background: #fff;
	border-radius: 4px;
	min-height: 40px;
}

#mbs-section-sortable .mbs-sortable-item {
	display: flex;
	align-items: center;
	padding: 10px 14px;
	border-bottom: 1px solid #f0f0f1;
	background: #fff;
	cursor: grab;
	user-select: none;
}

#mbs-section-sortable .mbs-sortable-item:last-child {
	border-bottom: none;
}

#mbs-section-sortable .mbs-sortable-item:hover {
	background: #f6f7f7;
}

#mbs-section-sortable .mbs-sortable-item:active {
	cursor: grabbing;
}

#mbs-section-sortable .mbs-drag-handle {
	flex-shrink: 0;
	margin-right: 10px;
	color: #a7aaad;
	font-size: 18px;
	line-height: 1;
}

#mbs-section-sortable .mbs-pro-lock-icon {
	flex-shrink: 0;
	margin-right: 4px;
}

#mbs-section-sortable .mbs-sortable-label {
	flex: 1;
	font-size: 13px;
	color: #1d2327;
	min-width: 0;
}

#mbs-section-sortable .mbs-section-visibility {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 13px;
	color: #50575e;
	white-space: nowrap;
	padding-left: 20px;
	cursor: pointer;
}

#mbs-section-sortable .mbs-section-visibility input[type="checkbox"] {
	margin: 0;
	flex-shrink: 0;
}

/* -------------------------------------------------------------------------
 * UX-NAV-002-002: Dim sortable label when section hidden by default — Book Editor
 * Added Session 195.
 * ------------------------------------------------------------------------- */

/* Dim the section label when its visibility checkbox is unchecked */
#mbs-section-sortable .mbs-sortable-item:has(.mbs-section-visibility input:not(:checked)) .mbs-sortable-label,
#mbs-section-sortable .mbs-sortable-item.mbs-section-dimmed .mbs-sortable-label {
	opacity: 0.45;
	font-style: italic;
}

/* ── Format sort hint: inline notice shown when 2+ formats exist ───────────────── */

.mbs-format-sort-hint {
	margin: 0 0 8px !important;
	padding: 8px 12px !important;
	font-size: 13px;
}

.mbs-format-sort-hint p {
	margin: 0;
	font-size: 13px;
	line-height: 1.5;
}
