/* Refined Cozy Book Library Layout - Goodreads-Inspired Yellowish Scheme */
.cozy-page-container {
    display: flex;
    gap: 20px;
    padding: 12px;
    min-height: 100vh;
    align-items: flex-start;
}

.cozy-filters-sidebar {
    width: 320px;
    box-sizing: border-box;
    background: linear-gradient(145deg, #f4f1e8 0%, #e9e5cd 100%);
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(117, 66, 14, 0.08),
                0 1px 3px rgba(117, 66, 14, 0.12);
    border: 1px solid #ddd6c1;
    color: #553b08;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 12px;
    height: max-content;
    align-self: flex-start;
    z-index: 0;
}

.cozy-filters-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #553b08;
    margin-bottom: 20px;
    text-shadow: none;
    border-bottom: 2px solid #c9c2a8;
    padding-bottom: 12px;
    position: relative;
}

.cozy-filters-title::before {
    content: "📚";
    margin-right: 8px;
    font-size: 1.2rem;
}

.cozy-main-content {
    flex: 1;
    background: linear-gradient(145deg, #fffef8 0%, #faf8f0 100%);
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(117, 66, 14, 0.06),
                0 1px 3px rgba(117, 66, 14, 0.08);
    position: relative;
    overflow: hidden; /* This will clip the corners of child elements like the header */
}

.cozy-header {
    background: linear-gradient(135deg, #75420e 0%, #553b08 100%);
    color: #ffffff;
    padding: 8px 24px;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(117, 66, 14, 0.25);
    z-index: 2;
}
.cozy-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    text-shadow: none;
    letter-spacing: -0.5px;
}

.cozy-search-section {
    padding: 10px 24px;
    background: rgba(249, 247, 240, 0.8);
    border-bottom: 1px solid #e9e5cd;
    position: relative;
    z-index: 2;
}

.cozy-search-container {
    display: flex;
    gap: 8px;
    max-width: 500px;
    margin: 0 auto;
}

/* New wrapper for input and scan button */
.cozy-search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    border: 1px solid #c9c2a8;
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(117, 66, 14, 0.08);
    padding-right: 6px; /* Space for the button */
}

.cozy-search-input-wrapper:focus-within {
    border-color: #75420e;
    box-shadow: 0 0 0 3px rgba(117, 66, 14, 0.15);
}

.cozy-search-input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    font-size: 0.90rem;
    background: transparent;
    outline: none;
    color: #553b08;
}

.cozy-search-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #75420e 0%, #553b08 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(117, 66, 14, 0.25);
    flex-shrink: 0;
    text-shadow: none;
}

/* Adjust scan button to sit inside the wrapper */
.cozy-search-input-wrapper .scan-btn {
    height: 30px;
    width: 30px;
    padding: 6px;
    margin: 0;
}


.cozy-search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(117, 66, 14, 0.35);
    background: linear-gradient(135deg, #8a4e10 0%, #633f09 100%);
}

.cozy-controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(244, 241, 232, 0.8);
    border-bottom: 1px solid #e9e5cd;
    position: relative;
    z-index: 2;
}

.cozy-view-controls {
    display: flex;
    gap: 6px;
}

.cozy-view-toggle-btn {
    background: #ffffff;
    border: 1px solid #c9c2a8;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #553b08;
    font-size: 0.9rem;
    box-shadow: 0 1px 3px rgba(117, 66, 14, 0.1);
}

.cozy-view-toggle-btn:hover {
    border-color: #a89572;
    transform: translateY(-1px);
    background: #fefdf9;
}

.cozy-view-toggle-btn.active {
    background: linear-gradient(135deg, #75420e 0%, #553b08 100%);
    color: #ffffff;
    border-color: #75420e;
    box-shadow: 0 2px 8px rgba(117, 66, 14, 0.25);
}

.cozy-sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #553b08;
}

.cozy-sort-select {
    padding: 8px 12px;
    border: 1px solid #c9c2a8;
    border-radius: 8px;
    background: #ffffff;
    font-size: 0.9rem;
    color: #553b08;
}

.cozy-sort-select:focus {
    outline: none;
    border-color: #75420e;
    box-shadow: 0 0 0 3px rgba(117, 66, 14, 0.15);
}

.cozy-filter-group,
.cozy-range-group {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(201, 194, 168, 0.4);
    box-sizing: border-box; /* Ensures consistent width calculation for all groups */
}

.cozy-filter-label,
.cozy-range-label {
    display: block;
    font-weight: 600;
    color: #553b08;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cozy-filter-label {
    margin-bottom: 8px;
}

.cozy-filter-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #c9c2a8;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #ffffff;
    transition: all 0.3s ease;
    color: #553b08;
    box-shadow: inset 0 1px 2px rgba(117, 66, 14, 0.06);
}

.cozy-filter-input:focus {
    outline: none;
    border-color: #75420e;
    box-shadow: 0 0 0 3px rgba(117, 66, 14, 0.15);
}

.cozy-range-label {
    margin-bottom: 12px;
}

.cozy-slider-container {
    position: relative;
    height: 30px;
    margin-bottom: 12px;
}

.cozy-slider-track {
    position: absolute;
    width: 100%;
    height: 4px;
    background: #c9c2a8;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.cozy-values-container {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #75420e;
}

.cozy-mobile-filter-toggle {
    display: none;
    box-sizing: border-box;
    width: calc(100% - 24px);
    margin: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #8a4e10 0%, #75420e 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    box-shadow: 0 3px 12px rgba(117, 66, 14, 0.3);
    text-shadow: none;
}

.cozy-mobile-filter-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(117, 66, 14, 0.4);
    background: linear-gradient(135deg, #9a5512 0%, #85481a 100%);
}

.cozy-content-container {
    padding: 0;
    position: relative;
    z-index: 2;
}

/* Adjustments for moved filter buttons */
.cozy-controls-bar .all-filters {
    margin-bottom: 0;
}



@media (max-width: 1024px) {
    /* --- New styles for mobile layout re-ordering --- */
    .cozy-controls-bar .cozy-view-controls {
        order: 1;
    }
    .cozy-controls-bar .cozy-sort-control {
        order: 2;
    }
    .cozy-controls-bar .all-filters {
        order: 3; /* This moves the filters to the end on mobile */
        width: 100%; /* Make it take the full width to force a new line */
        margin-top: 12px; /* Add some space above */
    }

    .cozy-page-container {
        flex-direction: column;
        padding: 8px;
        gap: 0;
    }

    .cozy-filters-sidebar {
        width: 100%;
        position: static;
        margin: 0;
        padding: 16px;
        display: none;
        border-radius: 0 0 16px 16px;
        border-top: none;
        /* Enhanced mobile visibility with yellowish contrast */
        background: linear-gradient(145deg, #f0ecdf 0%, #e4dfc6 100%);
        border: 1px solid #c9c2a8;
        box-shadow: 0 4px 20px rgba(117, 66, 14, 0.15);
    }

    .cozy-filters-sidebar.mobile-expanded {
        display: block;
    }

    .cozy-mobile-filter-toggle {       
        display: block;
        border-radius: 16px 16px 0 0;
        margin: 0;
        width: 100%;
    }

    .cozy-main-content {
        border-radius: 0 0 16px 16px;
        width: 99.4%;
    }

    .cozy-search-container {
        max-width: none;
        padding: 5px;
    }

    .cozy-controls-bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 12px;
        align-items: center;
    }
    /* --- Mobile layout adjustments for sort control --- */
    .cozy-sort-control {
        justify-content: space-between; /* Pushes label and select apart */
    }

    .cozy-sort-select {
        min-width: 160px; /* Ensures enough space for long text */
    }
}

@media (max-width: 768px) {
    .cozy-page-container {
        padding: 0;
    }

    .cozy-header h1 {
        font-size: 1.4rem;
    }

    .cozy-search-section  {
        padding: 12px;
    }
    .cozy-controls-bar, .cozy-content-container {
        padding: 0;
    }
}

/* Hide original headers and duplicate elements */
.header-row h1 {
    display: none;
}

.view-toggle-buttons {
    display: none;
}