/**
 * File Path: assets/css/mbs-admin.css
 * Admin-scoped general styles for the My Book Showroom admin interface.
 * @package MyBookShowroom
 * @since   1.0.0
 */

/* MBS Admin Design Tokens
 * Single source of truth for brand palette in all admin surfaces.
 * Matches wizard.css tokens exactly. Added Phase 0, Session UX-GL.
 */
#mbs-settings-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 -- NOT brand colors */
    --mbs-status-ok:     #00a32a;
    --mbs-status-err:    #d63638;
    --mbs-status-warn:   #f0c33c;
    --mbs-status-info:   #2271b1;
    --mbs-status-info-dark: #135e96;
}

/* MBS Admin Design Tokens — Dashboard scope.
 * Dashboard uses <div class="wrap mbs-dashboard"> with no #mbs-settings-wrap,
 * so it needs its own token scope block. Added Phase 0-fix, Session 197.
 */
.mbs-dashboard {
    --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 -- NOT brand colors */
    --mbs-status-ok:     #00a32a;
    --mbs-status-err:    #d63638;
    --mbs-status-warn:   #f0c33c;
    --mbs-status-info:   #2271b1;
    --mbs-status-info-dark: #135e96;
}

#mbs-settings-wrap .nav-tab-wrapper {
    margin-bottom: 20px;
}

#mbs-settings-wrap textarea.code {
    font-family: monospace;
    width: 100%;
}

/* Repeater styles */
.mbs-repeater {
    margin-top: 20px;
}

.mbs-repeater-rows {
    margin-top: 10px;
    margin-bottom: 15px;
}

.mbs-format-row {
    border: 1px solid #c3c4c7;
    background: #fff;
    padding: 0;
    margin-bottom: 15px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.mbs-pro-locked {
    opacity: 0.6;
    pointer-events: none;
}

.mbs-pro-badge {
    background: var(--mbs-lavender);
    color: var(--mbs-navy);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
}

.mbs-no-formats {
    color: #646970;
    font-style: italic;
}

/* Additional repeater field styles */
.mbs-format-row .mbs-custom-label,
.mbs-format-row .mbs-audiobook-fields {
    display: none;
}

.mbs-drag-handle {
    cursor: grab;
    margin-right: 8px;
}

.mbs-drag-handle:active {
    cursor: grabbing;
}

/* Format row collapse ───────────────────────────────────────── */
.mbs-format-row-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #f6f7f7;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
}

.mbs-format-row--open .mbs-format-row-header {
    border-bottom-color: #c3c4c7;
}

.mbs-format-row-toggle {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    min-height: 0;
    height: auto;
    cursor: pointer;
    line-height: 1;
    color: #646970;
    flex-shrink: 0;
}

.mbs-format-row-chevron {
    display: inline-block;
    font-size: 18px;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.mbs-format-row--open .mbs-format-row-chevron {
    transform: rotate(180deg);
}

.mbs-format-row-badge {
    font-size: 12px;
    font-weight: 600;
    background: var(--mbs-lavender-pale);
    color: var(--mbs-navy);
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.mbs-format-row-meta {
    font-size: 12px;
    color: #646970;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mbs-format-row-body {
    display: none;
    padding: 15px;
}

.mbs-format-row--open .mbs-format-row-body {
    display: block;
}

.mbs-format-row-header .mbs-remove-format-row {
    margin-left: auto;
    flex-shrink: 0;
}

/* Subnav: clear the WordPress subsubsub float and add spacing so panel content
   always starts on a new line below the subnav on every tab. ──────────────── */
.mbs-editor-subnav {
    float: none;
    clear: both;
    margin-bottom: 10px;
}

.mbs-editor-panel {
    clear: both;
}

/* Hide single-item subnavs — one link with no alternatives is pointless UI. */
.mbs-editor-subnav:has(> li:only-child) {
    display: none;
}

/* Look Inside upload button row (below editor) ─────────────────────────── */
.mbs-look-inside-upload-row {
    padding-top: 8px;
}

.mbs-upload-btn-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
}

.mbs-upload-status {
    font-size: 12px;
    color: #646970;
}

.mbs-look-inside-upload-row .description {
    margin-top: 6px;
}

/* Book list hamburger handle (mbs-admin.js) */
.mbs-sort-handle {
    display: inline-block;
    cursor: grab;
    color: #8c8f94;
    font-size: 18px;
    line-height: 1.6;
    vertical-align: middle;
}

.mbs-sort-handle:active {
    cursor: grabbing;
}

/* Book list fallback ▲/▼ buttons (no-sortable path) */
.mbs-order-col-fallback {
    white-space: nowrap;
}

.mbs-order-up,
.mbs-order-down {
    display: inline-block;
    padding: 0 4px;
    min-width: 24px;
    line-height: 1.6;
    font-size: 11px;
    cursor: pointer;
}

.mbs-order-up:disabled,
.mbs-order-down:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Section Order styles */
.mbs-section-order ul {
    list-style: none;
    padding: 0;
}

.mbs-section-order li {
    border: 1px solid #c3c4c7;
    background: #fff;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    cursor: move;
}

/* Media Uploader styles */
.mbs-media-upload-field {
    margin-bottom: 15px;
}

.mbs-media-preview {
    margin: 8px 0;
}

.mbs-media-preview img {
    max-width: 120px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ============================================================ */
/* BOOK EDITOR FIELD VALIDATION (Context 2)                      */
/* ISBN-13, ASIN, Price fields — JS-toggled via child-admin-     */
/* validation.js. Moved from inline wp_add_inline_style() call  */
/* in class-mbs-admin.php::enqueue_admin_assets().              */
/* ============================================================ */

.mbs-error {
    border-color: var(--mbs-status-err) !important;
    background-color: #fff0f0 !important;
}

.mbs-valid {
    border-color: var(--mbs-status-ok) !important;
}

.mbs-isbn-field,
input[name^="mbs_asin"],
input[name^="mbs_price"] {
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.mbs-field-error-msg {
    color: var(--mbs-status-err);
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.mbs-error + .mbs-field-error-msg {
    display: block;
}

/* ============================================================ */
/* BOOK EDITOR METABOXES (Context 2)                             */
/* Publication (F8), Authors (F9), Cover (F10).                  */
/* Moved from mbs-admin-settings.css where they were misplaced. */
/* ============================================================ */

/* ----- Publication Metabox (F8 — class-mbs-child-header-publication) ----- */

.mbs-pub-coming-soon-wrap {
    margin-left: 30px;
    vertical-align: middle;
}

.mbs-pub-pro-description {
    color: var(--mbs-status-err);
    margin-top: 4px;
}

/* ----- Authors Metabox (F9 — class-mbs-child-header-authors) ----- */

.mbs-author-list {
    margin-top: 10px;
    min-height: 32px;
    line-height: 1.8;
}

/* ST-023: Moved from dynamic <style> injection in child-admin-authors.js */
.mbs-author-tag {
    display: inline-block;
    background: #0073aa;
    color: #fff;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 3px;
    cursor: default;
}

.mbs-author-tag a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    margin-left: 6px;
}

/* ----- Cover Metabox (F10 — class-mbs-child-header-cover) ----- */

.mbs-cover-preview {
    margin-bottom: 10px;
}

.mbs-cover-remove {
    margin-left: 8px;
}

/* ============================================================ */
/* CATEGORIZATION METABOX (B-003)                                */
/* Extracted from inline <style> in                              */
/* includes/metaboxes/class-mbs-metabox-categorization.php.     */
/* ============================================================ */

/* ----- Categorization Metabox (B-003 — class-mbs-metabox-categorization) ----- */

.mbs-cat-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 8px;
}

.mbs-cat-tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    margin-bottom: -1px;
}

.mbs-cat-tab-btn--active {
    color: #1d2327;
    border-bottom-color: var(--mbs-status-info);
    font-weight: 600;
}

.mbs-cat-panel {
    display: none;
    max-height: 180px;
    overflow-y: auto;
}

.mbs-cat-panel--active {
    display: block;
}

.mbs-cat-checklist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.mbs-cat-checklist li {
    padding: 3px 0;
}

.mbs-cat-checklist label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.mbs-cat-empty {
    color: #888;
    font-size: 12px;
    font-style: italic;
    margin: 8px 0;
}

/* ── Collapsible field toggles (Illustration Types, Collections) ─────────── */
.mbs-ill-toggle,
.mbs-col-toggle {
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    text-align: left;
    line-height: 1.4;
}

.mbs-ill-toggle:focus,
.mbs-col-toggle:focus {
    outline: 2px solid var(--mbs-status-info);
    outline-offset: 2px;
}

.mbs-ill-chevron,
.mbs-col-chevron {
    display: inline-block;
    margin-right: 5px;
    font-size: 10px;
}

.mbs-ill-count,
.mbs-col-count {
    font-weight: 400;
    color: #646970;
    margin-left: 6px;
    font-size: 12px;
}


/* ============================================================ */
/* CLASSIFICATION METABOX                                        */
/* Genre picker, BISAC/Thema suggestion panels, code chips.     */
/* ============================================================ */

/* ----- Section structure ----- */
.mbs-classification-metabox .mbs-class-section {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f1;
}

.mbs-classification-metabox .mbs-class-section:last-child {
    border-bottom: none;
}

.mbs-classification-metabox .mbs-class-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #646970;
    margin: 0 0 8px;
}

/* ----- Genre picker step labels ----- */
.mbs-genre-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #3c434a;
    margin-bottom: 6px;
}

.mbs-genre-step {
    margin-bottom: 10px;
}

/* ----- Category and Subcategory buttons (Layers 0 and 1) ----- */
.mbs-group-buttons,
.mbs-l1-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.mbs-group-btn,
.mbs-l1-btn {
    font-size: 12px;
    padding: 4px 10px;
    height: auto;
    line-height: 1.5;
}

.mbs-group-btn--active,
.mbs-l1-btn--active {
    background: var(--mbs-status-info) !important;
    border-color: var(--mbs-status-info) !important;
    color: #fff !important;
}

/* ----- Genre checkbox labels (Layer 2) -- 3-column text flow ----- */
.mbs-genre-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px 20px;
    margin-bottom: 8px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    padding: 10px 12px;
    background: #fafafa;
}

.mbs-genre-item {
    font-size: 13px;
    padding: 2px 0;
    cursor: pointer;
    word-break: break-word;
    min-width: 0;
}

.mbs-genre-item input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle;
    cursor: pointer;
}

/* ----- BISAC and Thema suggestion panels -- single-column block flow ----- */
.mbs-genre-suggestions {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.mbs-suggestion-item {
    display: block !important;
    font-size: 13px;
    padding: 2px 0;
    cursor: pointer;
    word-break: break-word;
}

.mbs-suggestion-item input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle;
    cursor: pointer;
}

.mbs-suggestions-group {
    margin-bottom: 10px;
}

/* ----- Saved code chips (BISAC and Thema) ----- */
.mbs-class-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    min-height: 28px;
}

.mbs-class-chip {
    display: inline-flex;
    align-items: center;
    background: var(--mbs-status-info);
    color: #fff;
    border-radius: 3px;
    padding: 3px 4px 3px 8px;
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
}

.mbs-class-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 360px;
}

.mbs-class-chip-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px 0 6px;
    margin: 0;
    min-width: 0;
    box-shadow: none;
}

.mbs-class-chip-remove:hover {
    color: #fff;
    background: none;
    box-shadow: none;
}

.mbs-chip--flash {
    outline: 2px solid var(--mbs-status-warn);
    outline-offset: 1px;
    transition: outline 1.4s ease;
}

/* ----- Typeahead ----- */
.mbs-class-typeahead-wrap {
    position: relative;
    max-width: 360px;
    margin-bottom: 4px;
}

.mbs-class-results {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.mbs-class-result {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mbs-class-result:hover {
    background: #f0f6fc;
}

/* ----- Tier and overflow notices ----- */
.mbs-class-tier-note {
    color: var(--mbs-status-err);
    font-size: 12px;
    margin: 4px 0 0;
}

.mbs-class-overflow-notice {
    color: #646970;
    font-size: 12px;
    font-style: italic;
    margin: 0 0 6px;
}

/* ----- Buy link row sortable placeholder ----- */
.mbs-sortable-placeholder {
    background: #f0f6fc;
    border: 2px dashed var(--mbs-status-info);
    border-radius: 3px;
    visibility: visible !important;
}
/* ----- Buy-link / platform row: icon column ----- */
.mbs-buy-link-icon-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 48px;
}

.mbs-buy-link-icon-preview {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 2px;
}

.mbs-buy-link-icon-placeholder {
    display: inline-block;
    width: 24px;
    height: 24px;
    background: #f0f0f0;
    border: 1px dashed #c3c4c7;
    border-radius: 2px;
    vertical-align: middle;
}

.mbs-change-icon-btn {
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 6px;
    white-space: nowrap;
}

/* ----- Buy-link row: label input ----- */
.mbs-buy-link-label {
    max-width: 160px;
}

/* ==========================================================================
   Help Tip — mbs_help_tip() tooltip component (UI-HELP-001)
   CSS-only; no JS required. Available on every plugin admin page.
   ========================================================================== */

.mbs-help-tip {
    display: inline-block;
    position: relative;
    vertical-align: middle;
    margin-left: 4px;
    line-height: 1;
    cursor: default;
}

.mbs-help-tip .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: #a7aaad;
    transition: color .15s;
    vertical-align: middle;
}

.mbs-help-tip:hover .dashicons,
.mbs-help-tip:focus-within .dashicons {
    color: var(--mbs-status-info);
}

.mbs-help-tip__btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.mbs-help-tip__btn:focus {
    outline: 2px solid var(--mbs-status-info);
    outline-offset: 2px;
    border-radius: 2px;
}

.mbs-help-tip__content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: 300px;
    background: #1d2327;
    color: #f0f0f1;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    padding: 9px 12px;
    border-radius: 4px;
    z-index: 9999;
    white-space: normal;
    text-align: left;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

/* Arrow pointing down */
.mbs-help-tip__content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1d2327;
}

.mbs-help-tip:hover .mbs-help-tip__content,
.mbs-help-tip:focus-within .mbs-help-tip__content,
.mbs-help-tip__btn[aria-expanded="true"] + .mbs-help-tip__content {
    display: block !important;
}

/* Wide variant — for longer tooltip bodies (3+ sentences). */
.mbs-help-tip--wide .mbs-help-tip__content {
    max-width: 420px;
}

/* Label + help-tip inline pairing.
 * Wrapping a <label> and <span class="mbs-help-tip"> in this span prevents the
 * tip from dropping to its own line in flex-column and table-cell containers. */
.mbs-label-tip-pair {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ARC-018: Plugin action links — bold CTA anchors (e.g. Register, Activate, Upgrade). */
.mbs-link-bold {
    font-weight: 600;
}
