/* ==========================================================================
   Page-Specific: ItemEdit.aspx — Product Edit Page
   Goal: KEEP the original (native) alignment/float layout intact.
   Only apply clean visual styling (colors, fonts, borders, spacing).
   Presentation-only changes; all fields, controls, data, and behavior remain intact.
   ========================================================================== */

/* --- Remove the empty first spacer card --- */
#form1 > div.formPlaceHolder:empty,
#form1 > div.formPlaceHolder:first-child {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

/* The server form is the common parent of the left details column and the
   right cover column. It owns the single white surface for the whole section.
   Scoped by the stable class (AutoID prefixes the rendered form id, so #form1
   does not match). */
.item-edit-form {
    display: flow-root;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

/* The inner formPlaceHolder cards are now inside one panel — flatten them */
#form1 div.formPlaceHolder {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 0 12px 0 !important;
}

/* Full-width dividers and wide blocks must not exceed the content area
   (these were the 790px offenders causing the page-level horizontal scroll) */
#form1 div[style*="width: 790px"],
#form1 div[style*="width: 780px"],
#form1 div[style*="width: 770px"],
#form1 div[style*="width: 700px"],
#form1 div[style*="width: 600px"] {
    max-width: 100% !important;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Page title ("Add/Edit ... ID: 246109")
   -------------------------------------------------------------------------- */
#form1 div.formPlaceHolder > b {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

#form1 div.formPlaceHolder > b a,
#form1 .formPlaceHolder a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

#form1 .formPlaceHolder a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Product info rows (Title / Isbn / Author / Display)
   Keep the floated cells exactly where they are — just style the text.
   -------------------------------------------------------------------------- */
#form1 div.formPlaceHolder .formElement {
    line-height: 1.6;
}

/* Narrow fixed-width label cells → muted bold, values → primary text */
#form1 .formElement > div[style*="float: left"][style*="width: 100px"],
#form1 .formElement > div[style*="float: left"][style*="width: 75px"],
#form1 .formElement > div[style*="float: left"][style*="width: 85px"],
#form1 .formElement > div[style*="float: left"][style*="width: 55px"],
#form1 .formElement > div[style*="float: left"][style*="width: 50px"] {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
}

#form1 .formElement > div[style*="width: 250px"] b {
    font-size: 16px;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Product-info rows (Title / Isbn·BookID·Price / Author·Discount / Display·
   Sync·Keytype): the native fixed-pixel floated cells align unevenly. Reflow
   each such row as a flex row with consistent gaps and aligned label:value
   pairs. Styling only — no markup/control changes; every value stays put.
   Target: rows whose first child is the 100px label cell.
   -------------------------------------------------------------------------- */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
    margin-bottom: 14px !important;
}

/* Neutralize the inline fixed widths/floats on the cells so they sit in a
   tidy flow; labels get a small consistent min-width, values grow as needed. */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div {
    float: none !important;
    width: auto !important;
    margin: 0 !important;
    min-height: 0 !important;
}

/* Hide the inline clear:both spacer divs inside these rows (flex handles wrap) */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="clear: both"] {
    display: none !important;
    flex-basis: 100%;
    height: 0 !important;
}

/* Label cells (the fixed 100/75/85/55/50px floats) → consistent muted labels */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 100px"] {
    flex: 0 0 90px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
}
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 75px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 85px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 55px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 50px"] {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    margin-left: 14px !important;
}

/* Value cells → primary text, room to breathe before the next label pair */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 250px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 140px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 168px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 145px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 95px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 105px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 100px"] + div,
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 80px"] {
    color: var(--text-primary);
    font-size: 13px;
    margin-right: 8px !important;
}

/* Fix the first value column width (Isbn value + Author value) to 140px so the
   secondary label pairs (Elan BookID / Discount Price) line up in a column. */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 140px"],
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) > div[style*="width: 168px"] {
    flex: 0 0 140px !important;
    width: 140px !important;
}

/* Form field labels */
#form1 div.formElementLabel {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Dashed blue dividers → clean solid neutral rules (same width as original)
   -------------------------------------------------------------------------- */
#form1 div[style*="border-bottom: dashed"] {
    border-bottom: 1px solid var(--border) !important;
    height: 0 !important;
    min-height: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    margin: 14px 0 !important;
}

/* --------------------------------------------------------------------------
   Book cover image — light framed card
   -------------------------------------------------------------------------- */
#form1 img[id*="imgBookCover"] {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    background: #fff;
    height: auto;
}

/* --------------------------------------------------------------------------
   Content textarea / TinyMCE — style only, keep native width
   -------------------------------------------------------------------------- */
#form1 #TextContent textarea,
#form1 textarea {
    border: 1px solid var(--border-input) !important;
    border-radius: var(--radius-md) !important;
    padding: 10px 12px;
    line-height: 1.5;
    box-sizing: border-box;
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   FILES repeater blocks — clean look, keep the original inline field layout
   -------------------------------------------------------------------------- */
div#ArtPageFilesBlock > div[style*="background-color: #eeeeee"],
div#ArtPageFilesBlock > div[style*="background-color: #cccccc"] {
    padding: 14px 16px !important;
    margin-bottom: 10px !important;
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    max-width: 100%;
    box-sizing: border-box;
}

div#ArtPageFilesBlock > div[style*="background-color: #cccccc"] {
    background-color: var(--body-bg) !important;
}

div#ArtPageFilesBlock a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
    word-break: break-all;
}

div#ArtPageFilesBlock a:hover {
    text-decoration: underline;
}

div#ArtPageFilesBlock textarea {
    max-width: 100%;
    box-sizing: border-box;
    background-color: #fff !important;
}

/* --------------------------------------------------------------------------
   Sample list GridView — modern table look (keep native width)
   -------------------------------------------------------------------------- */
#form1 table[id*="gvDigFileList"] {
    max-width: 100%;
    box-sizing: border-box;
}

/* Product Fields ListView (#lvProductFields): left at its native/original
   rendering (no custom styling) per request. */

/* --------------------------------------------------------------------------
   Page-scoped override (ItemEdit only): the global cards.css dual-listbox rule
   forces `float: none` and adds `margin-bottom` on these floated cells. On
   ItemEdit, restore the native float and remove the bottom margin so the cells
   keep their original inline layout. Scoped to .item-edit-form (AutoID-safe)
   so other pages keep the global behavior.
   -------------------------------------------------------------------------- */
.item-edit-form div.formElement > div[style*="float: left"] {
    float: left !important;
    margin-bottom: 0 !important;
}

/* --------------------------------------------------------------------------
   Spacer images
   -------------------------------------------------------------------------- */
#form1 img[src*="spacer1x1"] {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Full-width white panel fix
   The white panel background is on #form1 (which is full width). The gray gap
   on the right appeared because the top-level LEFT column is `float: left`, so
   it shrinks to its content and the global overrides.css rule
   `div[style*="float: left"] > div.formPlaceHolder { width: 100% }` sized the
   inner blocks to that shrunk column — making the panel look narrow.

   Fix (no content/markup change, nothing exceeds 100%):
   1) Let the top-level LEFT content column be a normal full-width block.
   2) Keep the book-cover column floated to the right, inside the panel.
   3) Stop the global rule from constraining inner blocks to the float width.
   -------------------------------------------------------------------------- */

/* Keep the two top-level columns in their NATIVE side-by-side float layout
   (left = form fields, right = book cover). Do not re-float them — that pushed
   the cover out of the panel. Just make sure neither is constrained oddly. */
#form1 > div[style*="float: left"] {
    box-sizing: border-box;
}

/* Neutralize the global "float child → 100%" so the inner blocks size to
   #form1's real width instead of the shrunk float width. */
#form1 div[style*="float: left"] > div.formPlaceHolder {
    width: auto !important;
    max-width: 100% !important;
}

/* The ItemEdit content genuinely needs more than the global 960px cap (790px
   text/editor block + 125px book-cover column + gaps). Lift the cap ONLY on
   the ItemEdit page (identified by the book-cover image) so #form1 fills the
   full available width and the white panel spans edge-to-edge — without any
   element exceeding 100%. Scoped so no other page is affected. */
.admin-content:has(#form1 img[id*="imgBookCover"]) {
    max-width: none !important;
}

/* ==========================================================================
   Product header/info panel redesign (top section of ItemEdit)
   Tightens the sparse layout: compact title row, aligned info rows, and a
   framed book-cover card. Styling only — no markup/control/color changes.
   ========================================================================== */

/* Title row: "Add/Edit ID: NNN" + "Back to list" link on one tidy line */
#form1 > div[style*="float: left"] > div.formPlaceHolder:has(> b) {
    display: flex !important;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0 0 12px 0 !important;
}
#form1 > div[style*="float: left"] > div.formPlaceHolder:has(> b) > b {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
#form1 > div[style*="float: left"] > div.formPlaceHolder:has(> b) a {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
}

/* Remove the empty first spacer placeholder above the title */
#form1 > div.formPlaceHolder:first-child:not(:has(*)),
#form1 > div.formPlaceHolder:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Tighten the dashed divider right under the header so there's no big void */
#form1 > div[style*="float: left"] > div[style*="border-bottom: dashed"]:first-of-type {
    margin: 0 0 14px 0 !important;
}

/* Compact the product-info rows (less vertical gap between rows) */
#form1 .formElement:has(> div[style*="float: left"][style*="width: 100px"]) {
    margin-bottom: 10px !important;
    padding: 4px 0 !important;
}

/* --- Book-cover column → a neat framed card, top-aligned with the info --- */
#form1 > div[style*="float: left"]:has(img[id*="imgBookCover"]) {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    margin-left: 20px;
    text-align: center;
}
#form1 > div[style*="float: left"]:has(img[id*="imgBookCover"]) img[id*="imgBookCover"] {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    display: block;
    margin: 0 auto 10px auto;
    max-width: 100%;
    height: auto;
}
#form1 > div[style*="float: left"]:has(img[id*="imgBookCover"]) input[type="submit"],
#form1 > div[style*="float: left"]:has(img[id*="imgBookCover"]) input[type="button"] {
    width: 100% !important;
    min-width: 0 !important;
}

/* ==========================================================================
   "Upload a Sample" section — tidy, aligned layout
   The native markup uses fixed-width floated label/field cells that overlap
   under the modern reflow (label collides with the friendly-name input, the
   "Ordering" pair sits cramped). Reflow this one section into clean rows.
   Styling only — all controls, IDs, validation groups, and data unchanged.
   Scoped to the row that contains the sample friendly-name textbox.
   ========================================================================== */

/* NOTE: WebForms AutoID prefixes rendered IDs, so target by ID *suffix*.
   Keep this SIMPLE: do not restructure with grid/flex (the native markup has
   nested floated cells that break under aggressive reflow). Just give the
   inputs sensible sizes and let the native float layout flow. */

#form1 input[type="text"][id$="tbSampleFriendlyName"] {
    width: 220px !important;
    max-width: 100%;
}
#form1 input[type="text"][id$="TextBoxSampleIndex"] {
    width: 48px !important;
    text-align: center;
}
#form1 input[type="file"][id$="ContentFileUploadSample"] {
    min-width: 260px;
}

/* Keep the "Upload a Sample:" label on ONE line and vertically aligned with
   its input (it was wrapping to two lines and sitting low). Widen the label
   column enough to fit the text and stop it wrapping. */
#form1 .formElement:has([id$="tbSampleFriendlyName"]) > div.formElementLabel {
    width: auto !important;
    min-width: 0 !important;
    white-space: nowrap;
    padding-top: 8px !important;
    line-height: 1.35;
    margin-bottom: 33px !important;
}

/* Nudge the "Ordering:" cell down to align with the input row */
#form1 .formElement:has([id$="tbSampleFriendlyName"]) div[style*="width: 75px"] {
    margin-top: 5px !important;
}

/* Sample List grid: keep it within the panel and tidy */
#form1 table[id$="gvDigFileList"] {
    max-width: 100%;
    box-sizing: border-box;
}
