/* Custom styles */
html, body { height: 100%; }
body {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Align content to the center by default */
    min-height: 100%; /* Ensure body takes at least full viewport height for centering */
    /* Add space at the very bottom of the page to ensure the
       fixed-position selected cards bar doesn't overlap content. */
    padding-bottom: 55px;
    box-sizing: border-box; /* Include padding in height calculation */
    font-family: 'Inter', sans-serif;
    overflow-x: hidden; /* Prevent horizontal scroll */
    background-color: #EDEDED; /* Moved from index.html */
}

/* New styles for smooth binder loading */
#binderViewArea {
    /* This transition will be used when we remove the 'content-preloading' class */
    transition: opacity 0.2s ease-in-out;
}
#binderViewArea.content-preloading {
    /* This class keeps the element in the layout (so it's sized correctly) but fully invisible */
    visibility: hidden;
    opacity: 0;
}


/* When the binder is loaded (i.e., bookPagesContainer is not empty),
   revert to aligning content to the top. */
body:has(#bookPagesContainer:not(:empty)) {
    justify-content: flex-start;
}

/* Input Container */
#inputContainer {
    transition: opacity 0.5s ease-out;
    margin-top: 1rem;
    margin-bottom: 1rem;
    }
.input-wrapper { position: relative; }
#urlCheckmark { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #22c55e; /* green-500 */ opacity: 0; transition: opacity 0.3s ease-in-out; }
#urlCheckmark.visible { opacity: 1; }

/* Recent Binders Section */
#recentBindersContainer {
    display: none; /* Hidden by default, shown by JS when there are recent binders */
    max-width: 600px;
    margin: 2rem auto 1rem;
    padding: 0 1rem;
}

#recentBindersContainer h2 {
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    color: #4b5563; /* gray-600 */
    margin-bottom: 1rem;
    text-align: center;
}

#recentBindersList {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}

#recentBindersList li a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 120px;
    aspect-ratio: 5 / 7;
    padding: 0.75rem;
    border-top-left-radius: 2px;
    border-bottom-left-radius: 2px;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
    text-decoration: none;
    transition: filter 0.2s, transform 0.15s ease-out, box-shadow 0.2s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    position: relative;
    
    /* Use CSS variables set by script.js for binder-specific colors */
    background-color: var(--binder-bg-color, #fff);
    border: 1px solid var(--binder-border-color, #d1d5db);
    color: var(--binder-text-color, #1f2937);
    border-left-width: 8px;
}

#recentBindersList li a::after {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    right: 2px;
    border-radius: 2px; /* Slight radius for the stitching path */
    border: 1px dashed var(--binder-border-color, #9ca3af);
    opacity: 0.7;
    pointer-events: none;
}

.binder-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    /* Allow text to wrap if needed */
}

.binder-owner {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
    color: var(--binder-text-color, #374151);
}

#recentBindersList li a:hover {
    filter: brightness(1.15);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Remove Binder Button */
.remove-binder-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444; /* red-500 */
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.15s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    z-index: 10;
}

#recentBindersList li a:hover .remove-binder-btn {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.remove-binder-btn:hover {
    background-color: #f87171; /* red-400 */
    color: white;
    border-color: #ef4444; /* red-500 */
    transform: scale(1.1);
}


@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.animate-fadeIn { animation: fadeIn 0.3s ease-in forwards; opacity: 0; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
.animate-fadeOut { animation: fadeOut 0.3s ease-out forwards; opacity: 0; } /* Ensure opacity is 0 at end */

.value-display { font-weight: 600; min-width: 50px; text-align: left; font-size: 0.875rem; color: #4b5563; }

/* Selected Cards Bar/Panel, Loading, Pagination, Sort Controls, Collapsible Controls Styling */
#selectedCardsContainer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background-color: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    height: 55px; /* Initial collapsed height */
    max-width: 100%;
    margin: 0 auto;
    /* For sliding animation */
    transform: translateY(100%); /* Initially off-screen */
    visibility: hidden;
    transition: transform 0.3s ease-in-out,
                height 0.3s ease-in-out,
                visibility 0s linear 0.3s; /* Default: delay visibility for hiding */
}
#selectedCardsContainer.is-visible {
    transform: translateY(0); /* On-screen */
    visibility: visible;
    transition-delay: 0s, 0s, 0s; /* Override delay for visibility when showing */
}
#selectedCardsContainer.expanded { height: 50vh; }
#selectedCardsHeader { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.5rem; cursor: pointer; border-bottom: 1px solid #e5e7eb; height: 55px; }
#selectedCardsHeader h2 { margin: 0; font-size: 1rem; }
#selectedCardsHeader div { font-size: 0.9rem; }
#selectedCardsContent { padding: 0 1rem 1rem 1rem; height: calc(100% - 55px); overflow-y: auto; display: flex; flex-direction: column; }
#selectedCardsList { flex-grow: 1; margin-bottom: 1rem; }
#selectedCardsList li { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0; border-bottom: 1px solid #e5e7eb; font-size: 0.8rem; gap: 0.25rem; }
#selectedCardsList li:last-child { border-bottom: none; }
.card-details { display: flex; align-items: center; flex-grow: 1; margin-right: 0.25rem; overflow: hidden; }
.list-quantity-controls { display: flex; align-items: center; margin-right: 0.25rem; min-width: auto; justify-content: center; }
.list-adjust-btn { width: 20px; height: 20px; font-size: 14px; line-height: 20px; margin: 0 2px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; border: none; cursor: pointer; transition: background-color 0.2s; }
.list-adjust-btn.minus-btn { background-color: #f87171; } .list-adjust-btn.minus-btn:hover { background-color: #ef4444; }
.list-adjust-btn.plus-btn { background-color: #4ade80; } .list-adjust-btn.plus-btn:hover { background-color: #22c55e; }
.list-adjust-btn:disabled { opacity: 0.5; cursor: not-allowed; background-color: #9ca3af; }
.list-selected-qty { font-weight: 500; min-width: 16px; text-align: center; margin: 0 1px; font-size: 0.8rem; }
.remove-button { font-size: 1rem; padding: 0 0.25rem 0 0; margin-right: 0.25rem; color: #ef4444; opacity: 0.7; transition: opacity 0.2s; border: none; background: none; cursor: pointer; }
.remove-button:hover { color: #dc2626; opacity: 1; }
.card-name { flex-grow: 1; margin-right: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-price { font-weight: 500; min-width: 45px; text-align: right; }
#priceTally { margin-top: auto; font-weight: 600; font-size: 1rem; text-align: right; border-top: 2px solid #d1d5db; padding-top: 0.5rem; }
.list-action-button { display: none; } #selectedCardsContainer.expanded .list-action-button { display: inline-block; }
.loader { border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.pagination-button {
    background-color: #f9fafb; /* gray-50, very light gray */
    color: #374151; /* gray-700, for arrow */
    padding: 0; /* Remove padding, size controlled by width/height */
    border-radius: 0.25rem; /* 4px */
    border: 1px solid #d1d5db; /* gray-300 */
    box-shadow: 0 2px 0px 0px #d1d5db; /* Simulates the bottom edge of a key */
    cursor: pointer;
    transition: background-color 0.15s ease-in-out,
                border-color 0.15s ease-in-out,
                box-shadow 0.15s ease-in-out,
                transform 0.1s ease-in-out;
    margin: 0 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; /* Fixed width */
    height: 40px; /* Fixed height */
}
.pagination-button svg {
    width: 20px; /* SVG size */
    height: 20px; /* SVG size */
    stroke-width: 2.5; /* SVG stroke thickness */
}
.pagination-button:hover {
    background-color: #f3f4f6; /* gray-100 */
    border-color: #adb5bd; /* gray-500 */
    box-shadow: 0 2px 0px 0px #adb5bd;
}
.pagination-button:active {
    background-color: #e5e7eb; /* gray-200 */
    transform: translateY(1px); /* Press down effect */
    box-shadow: 0 1px 0px 0px #adb5bd; /* Shadow moves with button */
}
.pagination-button:disabled {
    background-color: #f3f4f6; /* gray-100 */
    border-color: #e5e7eb; /* gray-200 */
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: 0 2px 0px 0px #e5e7eb; /* Lighter shadow when disabled */
    transform: translateY(0); /* Reset transform */
}
.pagination-button:disabled svg {
    stroke: #9ca3af; /* gray-400, arrow color for disabled */
}
.pagination-button.keyboard-active { /* Style for keyboard-triggered press */
    background-color: #e5e7eb; /* gray-200 */
    transform: translateY(1px); /* Press down effect */
    box-shadow: 0 1px 0px 0px #adb5bd; /* Shadow moves with button */
}
#sortControls {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    justify-content: space-between;
    align-items: center;
    display: flex;
    width: 100%;
}
.sort-group-center {
    display: flex;
    gap: 1rem;
}
.sort-group-left, .sort-group-right {
    width: 36px;
    height: 36px;
}
.sort-button {
    background-color: #e5e7eb;
    border: 2px solid transparent;
    border-radius: 50%;
    padding: 0.5rem;
    margin: 0;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}
.sort-button:hover { background-color: #d1d5db; } .sort-button.active { background-color: #bfdbfe; border-color: #60a5fa; }
#priceSortIcon { font-size: 1.1rem; font-weight: 600; color: #4b5563; line-height: 1; }
#paginationControls {
    /* Old styles removed: margin-top: 0.5rem; text-align: center; margin-bottom: 0; */
    display: flex;
    justify-content: center; /* Groups items in the center */
    align-items: center; /* Vertically aligns buttons and page info */
    margin: 1rem 0; /* Space above and below */
    padding: 0 0.75rem; /* Horizontal padding for content */
    box-sizing: border-box; /* Include padding in width calculation */
    position: relative; /* Allow z-index to apply */
    z-index: 1;         /* Ensure it's below binderContainer */
}
.sort-button.active #priceSortIcon { color: #1d4ed8; } .sort-button svg { width: 20px; height: 20px; }
#controlsWrapper { max-width: 100%; margin-left: auto; margin-right: auto; margin-top: 1rem; display: none; }
@media (min-width: 768px) {
    /* On desktop, vertical spacing is handled by the parent's 'gap' property. */
    #controlsWrapper { max-width: 100rem; margin-top: 0; }
    #paginationControls { margin-top: 0; margin-bottom: 0; }
}
#toggleControlsBtn { display: block; width: 100%; background-color: #fff; border: 1px solid #d1d5db; border-radius: 0.5rem; padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: #374151; cursor: pointer; transition: background-color 0.2s; display: flex; justify-content: space-between; align-items: center; }
#toggleControlsBtn:hover { background-color: #f9fafb; }
#toggleControlsBtn .arrow { width: 1rem; height: 1rem; transition: transform 0.3s ease-out; }
#toggleControlsBtn.active .arrow { transform: rotate(180deg); }
#tempControlsContent { background-color: #f9fafb; border: 1px solid #d1d5db; border-top: none; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem; padding: 1.5rem; display: grid; gap: 0.75rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); align-items: center; max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out, padding 0.4s ease-out, border-width 0.4s ease-out; padding-top: 0; padding-bottom: 0; border-width: 0; }
#tempControlsContent.controls-expanded { max-height: 600px; padding: 1.5rem; border-width: 1px; border-top: none; }
#tempControlsContent h3 { grid-column: 1 / -1; font-size: 1rem; font-weight: 600; color: #111827; margin-bottom: 0.25rem; margin-top: 0.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid #e5e7eb; }
#tempControlsContent h3:first-of-type { margin-top: 0; }
.control-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
#tempControlsContent label { font-size: 0.875rem; font-weight: 500; color: #374151; flex-shrink: 0; width: 100px; text-align: right; }
#tempControlsContent input[type="range"] { cursor: pointer; flex-grow: 1; min-width: 100px; }
#tempControlsContent input[type="color"] { width: 30px; height: 30px; border: 1px solid #ccc; padding: 0; border-radius: 0.25rem; cursor: pointer; overflow: hidden; background-color: transparent; }
#tempControlsContent input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
#tempControlsContent input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0.25rem; }
#tempControlsContent input[type="color"]::-moz-color-swatch { border: none; border-radius: 0.25rem; }
.value-display { font-weight: 600; min-width: 50px; text-align: left; font-size: 0.875rem; color: #4b5563; }

/* CSS-only toggle for styling controls */
#toggleControlsCheckbox { display: none; }
#toggleControlsCheckbox:checked + label#toggleControlsBtn .arrow {
    transform: rotate(180deg);
}
#toggleControlsCheckbox:checked + label#toggleControlsBtn + #tempControlsContent {
    max-height: 600px; padding: 1.5rem; border-width: 1px; border-top: none;
}

/* Overlay for expanded selected cards panel */
#selectedCardsOverlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6); z-index: 49; /* Below selectedCardsContainer (50) */
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s; /* Delay visibility for fade-out */
    pointer-events: none;
}
#selectedCardsOverlay.is-visible {
    opacity: 1; visibility: visible;
    pointer-events: auto; /* Allow click to close */
    transition-delay: 0s, 0s; /* Override delay for fade-in */
}

/* Moved from index.html - Landing Page Styles */
#landingPageStylingControls {
    display: none; /* Initially hidden, controlled by JS */
}

/* Moved from index.html - Zoom Overlay */
#zoomBackgroundOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    cursor: pointer;
}

/* Moved from index.html - Zoomed Card Wrapper Base Styles */
#zoomedCardWrapper {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1001;
    transform-origin: center center;
    cursor: default;
}
#zoomedCardWrapper #zoomedCardImage {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Moved from index.html - Title Style */
#inputContainer h1 {
    font-size: 3.1rem;
    font-family: 'Georgia', serif;
}