/* ==========================================================================
   UPP CURATOR - Cathedral Architecture
   ========================================================================== */

/* ==========================================================================
   0. UTILITIES & HEADER
   ========================================================================== */
.upp-curator-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--bb-content-border-color);
}

.upp-privacy-label {
    color: var(--bb-body-text-color);
    display: flex;
    align-items: center;
    gap: 5px;
}

.upp-change-link {
    color: var(--bb-primary-color);
    text-decoration: none;
    font-weight: 500;
}
.upp-change-link:hover { text-decoration: underline; }

/* ==========================================================================
   1. BLOCK CREATION (Cathedral Add Box)
   ========================================================================== */
.upp-add-box.upp-compact-form {
    background-color: var(--bb-content-background-color);
    border: 1px solid var(--bb-content-border-color);
    border-radius: 4px;
    padding: 20px !important;
    margin-bottom: 30px;
}

/* Remove form default margin */
.upp-add-box.upp-compact-form form {
    margin-bottom: 0;
}

.upp-add-block-row {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: center;
}

/* Ensure the input takes space but leaves room for button */
.upp-add-block-input {
    flex-grow: 1;
    /* Common CSS handles the Gold Border styles now */
}

.upp-add-block-row button {
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0;      /* Prevent button from shrinking */
    min-width: 140px;    /* Force enough space for "Create Block" */
    height: 38px;        /* Match input height */
    padding: 0 20px;
}

/* ==========================================================================
   2. CURATOR BLOCKS
   ========================================================================== */
.upp-curator-block-wrapper { 
    background: transparent;
    margin-bottom: 30px; 
}

.upp-block-header { 
    background: transparent;
    border-bottom: 1px solid var(--bb-content-border-color); 
    padding: 10px 0; 
    margin-bottom: 15px;
    display: flex; 
    justify-content: space-between; 
    align-items: baseline; 
}

.upp-block-title {
    margin: 0 !important;
    font-family: var(--bb-headings-font-family);
    font-size: 18px;
    font-weight: 700;
    color: var(--bb-headings-color);
    text-transform: uppercase;
}

.upp-delete-link {
    font-size: 13px;
    color: var(--bb-alternate-text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.upp-delete-link:hover {
    color: var(--bb-danger-color);
    text-decoration: underline;
}

.upp-curator-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==========================================================================
   3. CURATOR ITEMS (Cathedral Card Style)
   ========================================================================== */
.upp-curator-item { 
    background-color: var(--bb-content-background-color);
    border: 1px solid var(--bb-content-border-color);
    
    /* Green Left Border (Cathedral Signature) */
    border-left: 4px solid var(--bb-primary-button-background-regular);
    
    border-radius: 4px;
    padding: 15px 20px;
    display: flex; 
    align-items: center; 
    gap: 15px; 
    transition: all 0.2s;
    position: relative;
}

.upp-curator-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Sortable Placeholder */
.ui-state-highlight {
    background: rgba(0,0,0,0.02);
    border: 2px dashed var(--bb-primary-button-background-regular);
    height: 70px; 
    margin-bottom: 15px;
    border-radius: 4px;
    visibility: visible !important;
}

/* Drag Handle */
.upp-drag-handle {
    flex-shrink: 0;
    color: var(--bb-alternate-text-color);
    cursor: grab;
    display: flex;
    align-items: center;
}
.upp-drag-handle:hover { color: var(--bb-primary-color); }

/* Item Number Badge */
.upp-item-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background-color: var(--bb-primary-button-background-regular) !important;
    color: var(--bb-primary-button-text-regular) !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    border: none !important;
    padding: 0 !important;
    text-align: center;
    margin-right: 5px;
    
    /* Reset Input Styling */
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

/* Hide Spin Buttons */
.upp-item-number::-webkit-outer-spin-button,
.upp-item-number::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Thumbnails */
.upp-item-thumb-wrapper { flex-shrink: 0; }
.upp-item-thumb { 
    width: 50px; height: 50px; 
    object-fit: cover; 
    border-radius: 4px; 
    border: 1px solid var(--bb-content-border-color); 
    display: block;
}

/* Details */
.upp-item-details { flex-grow: 1; }

.upp-item-link { 
    font-weight: 600; 
    font-size: 15px; 
    text-decoration: none; 
    color: var(--bb-body-text-color); 
    transition: color 0.2s;
}
.upp-item-link:hover { color: var(--bb-primary-color); }

.upp-item-type {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--bb-alternate-text-color);
    margin-top: 2px;
    font-weight: 600;
}

.upp-item-desc {
    margin: 4px 0 0 0 !important; 
    color: var(--bb-body-text-color);
    font-size: 13px;
    opacity: 0.8;
}

/* Actions (Edit/Delete) */
.upp-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s;
}
.upp-curator-item:hover .upp-item-actions { opacity: 1; }

.upp-edit-item-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--bb-alternate-text-color);
    font-size: 16px;
}
.upp-edit-item-btn:hover { color: var(--bb-primary-color); }

.upp-item-remove {
    color: var(--bb-alternate-text-color);
    text-decoration: none;
    font-size: 20px;
    line-height: 1;
    border: none;
    background: none;
}
.upp-item-remove:hover { color: var(--bb-danger-color); }

/* ==========================================================================
   4. ADD ITEM PROXY FORM
   ========================================================================== */
.upp-add-item-row { 
    padding: 15px 0 0 0;
}

.upp-proxy-container {
    display: none;
    margin-top: 15px;
    background: var(--bb-content-background-color);
    padding: 20px;
    border-radius: 4px;
    border: 1px solid var(--bb-content-border-color);
    /* Gold Border Accent */
    border-top: 1px solid var(--bb-primary-color);
}

.upp-form-grid { display: grid; gap: 15px; }

.upp-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--bb-body-text-color);
    font-size: 13px;
}

/* Book Search */
.upp-book-search-group {
    display: none;
    padding: 15px;
    background: var(--bb-body-background-color); 
    border: 1px dashed var(--bb-content-border-color);
    border-radius: 4px;
    margin-bottom: 10px;
}

.upp-book-search-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Ensure lookup button doesn't shrink */
.upp-book-lookup-btn { flex-shrink: 0; }

.upp-proxy-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

/* Desktop: hide mobile reorder arrows */
.upp-reorder-arrows {
    display: none;
}

/* ==========================================================================
   MOBILE OVERRIDES
   ========================================================================== */
@media screen and (max-width: 768px) {

    /* ------------------------------------------------------------------
       SECTION HEADER — Vertical stack, compact spacing
       ------------------------------------------------------------------ */
    .upp-curator-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding-bottom: 0;
        margin-bottom: 10px;
        border-bottom: none;
    }

    .upp-curator-section-header .upp-section-title {
        padding-left: 0;
        margin-left: 0;
    }

    .upp-curator-section-header .upp-header-actions {
        width: 100%;
        border-top: 1px solid var(--bb-content-border-color);
        border-bottom: 1px solid var(--bb-content-border-color);
        padding: 2px 0;
    }

    .upp-privacy-label {
        min-height: 36px;
    }

    /* ------------------------------------------------------------------
       ADD BOX — Tighter padding, stacked layout
       ------------------------------------------------------------------ */
    .upp-add-box.upp-compact-form {
        padding: 12px 15px 10px 15px !important;
    }

    .upp-add-block-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .upp-add-block-row button {
        min-width: auto;
        width: 100%;
    }

    /* ------------------------------------------------------------------
       BLOCK HEADER — Stack on mobile
       ------------------------------------------------------------------ */
    .upp-block-header {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* ------------------------------------------------------------------
       CARD LIST — Hide drag handle, show reorder arrows
       ------------------------------------------------------------------ */
    .upp-drag-handle {
        display: none !important;
    }

    /* Card layout: CSS Grid — number + arrows left, content right */
    .upp-curator-item {
        display: grid;
        grid-template-columns: 32px 1fr;
        grid-template-rows: auto auto;
        gap: 4px 12px;
        align-items: start;
    }

    /* Number badge: top-left cell */
    .upp-curator-item > .upp-item-number {
        grid-column: 1;
        grid-row: 1;
        justify-self: center;
    }

    /* Arrows: below number in left column */
    .upp-reorder-arrows {
        display: flex;
        flex-direction: column;
        gap: 4px;
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
        margin-top: 8px;
    }

    /* Thumbnail: hidden on mobile for consistent card layout */
    .upp-curator-item > .upp-item-thumb-wrapper {
        display: none;
    }

    /* Item details: right column, spans all rows */
    .upp-curator-item > .upp-item-details {
        grid-column: 2;
        grid-row: 1 / -1;
    }

    /* Item actions: keep hover-to-reveal (same as Life Principles) */
    .upp-item-actions {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    /* Arrow buttons: round, same size as number circle (32px) */
    .upp-move-up,
    .upp-move-down {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
        background: transparent !important;
        border: 1px solid rgba(218, 165, 32, 0.3) !important;
        border-radius: 50% !important;
        color: #DAA520 !important;
        cursor: pointer;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        line-height: 0 !important;
        font-size: 0 !important;
        -webkit-tap-highlight-color: transparent;
        -webkit-appearance: none;
        appearance: none;
    }

    .upp-move-up svg,
    .upp-move-down svg {
        display: block !important;
        width: 16px !important;
        height: 16px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .upp-move-up:active,
    .upp-move-down:active {
        background: rgba(218, 165, 32, 0.1) !important;
    }

    .upp-move-up:disabled,
    .upp-move-down:disabled {
        opacity: 0.25;
        pointer-events: none;
    }
}