/* ==========================================================================
   COZY LIBRARY STYLES
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px 24px 60px;
    min-height: 100vh;
    font-family: 'Quicksand', sans-serif;
    color: #4A2800;
    background-color: #fde9d1;
}

/* Navigation */
.nook-nav { margin-bottom: 20px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background-color: #FFFEE0;
    border: 1.5px solid rgba(74, 40, 0, 0.12);
    border-radius: 14px;
    color: #4A2800;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 2px 0 rgba(74, 40, 0, 0.08);
    transition: transform 0.15s ease;
}

.back-link:hover { transform: translateY(-1px); }

/* Main Container */
.library-container {
    max-width: 1100px;
    margin: 0 auto;
}

/* Header */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.library-header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
}

.subtitle {
    margin: 4px 0 0 0;
    font-size: 0.95rem;
    opacity: 0.7;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.add-btn {
    background: #6A4B62;
    color: #FFFDF0;
    border: none;
    padding: 10px 18px;
    border-radius: 14px;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #462F41;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #462F41;
}

/* Mascot Banner */
.cat-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.75);
    border: 1.5px solid rgba(74, 40, 0, 0.12);
    border-radius: 20px;
    padding: 12px 18px;
    margin-bottom: 8px;
}

.cat-avatar {
    background: #FFFEE0;
    border: 1.5px solid rgba(74, 40, 0, 0.15);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cat-avatar:hover { transform: scale(1.15) rotate(5deg); }

.cat-label { font-size: 0.72rem; text-transform: uppercase; font-weight: 800; opacity: 0.5; }
.cat-message { margin: 2px 0 0 0; font-size: 0.95rem; font-weight: 700; }

/* ==========================================================================
   3D WOODEN BOOKCASE WALL
   ========================================================================== */

#bookcases-wall {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.bookcase-card {
    background: #5c3014; /* Deep rich mahogany wood backing */
    background-image: 
        radial-gradient(ellipse at 50% 0%, rgba(255, 220, 180, 0.08) 0%, rgba(0, 0, 0, 0.25) 100%),
        repeating-linear-gradient(
            0deg, 
            transparent, 
            transparent 2px, 
            rgba(0, 0, 0, 0.04) 2px, 
            rgba(0, 0, 0, 0.04) 4px
        );
    border: 12px solid #3d1c08; /* Thick Outer Wooden Frame */
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 
        0 12px 28px rgba(35, 15, 5, 0.4),
        inset 0 0 40px rgba(0, 0, 0, 0.5); /* Inner frame shadow for depth */
    position: relative;
}

/* Header bar containing title and remove button */
.bookcase-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

/* Optional Bookcase Header Title styling if you have one */
.bookcase-title {
    font-family: 'Lora', serif;
    color: #fcebd9;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
}

.delete-bookcase-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    color: #C48B9F;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
}

.delete-bookcase-btn:hover { background: rgba(196, 139, 159, 0.15); }

/* Internal Shelf Rows */
.bookcase-shelves-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.shelf-row {
    position: relative;
    margin-bottom: 28px;
}

.shelf-row:last-child {
    margin-bottom: 8px;
}

/* The Grid holding the 20 slots */
.shelf-slots-grid {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 4px;
    align-items: end;
    min-height: 140px;
    padding: 0 8px;
}

/* 🌟 The 3D Wooden Shelf Plank sitting underneath the books */
.shelf-plank {
    height: 16px;
    background: linear-gradient(180deg, #b0703c 0%, #7d4419 60%, #4a2206 100%);
    border-radius: 2px;
    border-top: 2px solid #d49359; /* Highlight edge on top of shelf */
    border-bottom: 2px solid #2e1202; /* Dark bottom shadow edge */
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.45), /* Deep cast shadow below shelf */
        inset 0 2px 2px rgba(255, 255, 255, 0.25);
    margin-top: 2px;
    position: relative;
    z-index: 2;
}

/* Decorative side brackets holding the shelf plank */
.shelf-plank::before,
.shelf-plank::after {
    content: '';
    position: absolute;
    top: 0;
    width: 10px;
    height: 100%;
    background: #3d1c08;
}

.shelf-plank::before { left: -8px; border-radius: 2px 0 0 2px; }
.shelf-plank::after { right: -8px; border-radius: 0 2px 2px 0; }

/* Individual Slot */
.shelf-slot {
    height: 135px;
    border: 1.5px dashed rgba(74, 40, 0, 0.1);
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.shelf-slot.drag-over {
    background: rgba(123, 154, 136, 0.25);
    border-color: #7B9A88;
}

/* ==========================================================================
   SLIM BOOK SPINES
   ========================================================================== */

.book-spine {
    width: 100%;
    height: 125px;
    border-radius: 4px 4px 2px 2px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 0 2px;
    user-select: none;
    
    /* Crisp dark outline to make each book pop off the shelf */
    border: 1.5px solid #3D2314;
    border-top: 3px solid #FFF8DC;
    
    /* Soft shadow for depth */
    box-shadow: 
        inset 3px 0 4px rgba(255, 255, 255, 0.45), /* Highlight on left ridge */
        inset -3px 0 4px rgba(61, 35, 20, 0.18),    /* Shadow on right ridge */
        2px 3px 6px rgba(61, 35, 20, 0.15);         /* Soft shelf drop shadow */
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-spine:hover {
    transform: translateY(-5px); /* Lift */
    box-shadow: 
        inset 3px 0 4px rgba(255, 255, 255, 0.5),
        inset -3px 0 4px rgba(61, 35, 20, 0.18),
        3px 8px 14px rgba(61, 35, 20, 0.22); /* Shadow deepens as book lifts */
}

.book-spine:active {
    cursor: grabbing;
}

.book-title-text {
    /* 🌟 Switch to a clean, ultra-legible modern font */
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    
    font-size: 0.65rem; /* Sized perfectly for vertical slim spines */
    font-weight: 800;   /* Bold weight makes it pop instantly */
    color: #2E1A0E;
    
    text-transform: uppercase; 
    letter-spacing: 0.2px; /* Spreads the letters slightly for maximum clarity */
    
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 110px;
}

/* Spine Colors */
.book-spine.color-sage { background: #c5f3a8; }
.book-spine.color-rose { background: #ffa8b6; }
.book-spine.color-amber { background: #ffad7a; }
.book-spine.color-denim { background: #9ad7ff; }
.book-spine.color-plum { background: #b6a9ff; }
.book-spine.color-espresso { background: #c4a382; }
.book-spine.color-lavender { background: #f0b6fa; }
.book-spine.color-butter { background: #fdf28b; }

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(74, 40, 0, 0.35);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden { display: none; }

.modal-card {
    background: #FAF5E8;
    border: 2px solid rgba(74, 40, 0, 0.15);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    padding: 24px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed rgba(74, 40, 0, 0.12);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-header h2 { margin: 0; font-size: 1.3rem; }

.close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #4A2800;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.75;
}

.form-group input, .form-group textarea, .form-select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid rgba(74, 40, 0, 0.15);
    font-family: inherit;
    font-size: 0.95rem;
    background: #FFFDF9;
    outline: none;
}

.form-group input:focus, .form-group textarea:focus, .form-select:focus {
    border-color: #6A4B62;
}

/* Color Swatches */
.color-picker {
    display: flex;
    gap: 10px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: #4A2800; transform: scale(1.15); }

/* Modal Buttons */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.save-btn, .edit-btn {
    background: #6A4B62;
    color: #FFFDF0;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.delete-btn {
    background: #C48B9F;
    color: #FFFDF0;
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* View Card */
.view-card { text-align: center; }
.view-author { font-style: italic; opacity: 0.75; margin-top: -8px; }
.view-divider { height: 1px; background: rgba(74, 40, 0, 0.12); margin: 16px 0; }
.view-notes { font-family: 'Lora', serif; font-size: 1.05rem; line-height: 1.6; text-align: left; }


.library-data-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.secondary-btn {
    background-color: #e8dff4; /* Soft lavender pastel */
    color: #2e1a0e;
    border: 1.5px solid #3d2314;
    border-radius: 6px;
    padding: 2px 5px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.secondary-btn:hover {
    background-color: #d8c8ed;
    transform: translateY(-1px);
}