@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-bg: #f8f7f4;
    --sidebar-width: 85px;
    --main-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --accent: #2d3748;
    --border: #e5e7eb;
    --hover: #f3f4f6;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--main-bg);
    overflow-x: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 3rem;
}

.logo {
    font-size: 1.8rem;
    color: var(--accent);
}

.logo-text {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    max-width: 70px;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

.nav-item {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.nav-item:hover {
    background: var(--hover);
    color: var(--accent);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    overflow-y: auto;
    background: linear-gradient(135deg, #fdfbf7 0%, #f9f7f4 50%, #faf8f5 100%);
}

/* ===== SEARCH HEADER ===== */
.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 3rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-box {
    flex: 1;
    max-width: 600px;
    position: relative;
    display: flex;
    align-items: center;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45, 55, 72, 0.1);
}

.search-box i {
    color: var(--text-secondary);
    margin-right: 0.75rem;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar:hover {
    transform: scale(1.05);
}

.user-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    min-width: 280px;
    z-index: 999;
    animation: fadeIn 0.2s ease;
}

.user-menu-header {
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.avatar-large {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.menu-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.menu-user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
}

.logout-btn {
    width: 100%;
    background: none;
    border: none;
    padding: 1rem 1.25rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ef4444;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s;
    border-radius: 0 0 16px 16px;
}

.logout-btn:hover {
    background: #fef2f2;
}

.logout-btn i {
    font-size: 1.1rem;
}

.fa-bell {
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ===== BOOK DISPLAY (DETAILED VIEW) ===== */
.book-display {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 3rem;
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease;
}

.book-display.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-preview {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.preview-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.control-btn:hover {
    background: var(--hover);
    border-color: var(--accent);
    color: var(--accent);
}

.book-cover-container {
    flex: 1;
}

.book-cover {
    width: 100%;
    max-width: 320px;
    height: auto;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s;
}

.book-cover:hover {
    transform: scale(1.02);
}

.book-details {
    padding-top: 1rem;
}

.book-title {
    font-family: 'Crimson Text', serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.book-author {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.book-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    align-items: center;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1a202c;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--hover);
    border-color: var(--accent);
    color: var(--accent);
}

.info-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
}

.info-section h3,
.metadata-group h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.description-text {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.review-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--hover);
    border-radius: 12px;
}

.review-section.hidden {
    display: none;
}

.reviewer-info {
    display: flex;
    gap: 1rem;
}

.reviewer-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.reviewer-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.review-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    font-style: italic;
}

.metadata-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.metadata-text {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* ===== SEARCH RESULTS GRID ===== */
.search-results {
    padding: 2rem 3rem;
}

.message-box {
    text-align: center;
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.book-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.book-card-cover {
    width: 140px;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin: 0 auto 1rem;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.book-card-title {
    font-family: 'Crimson Text', serif;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-author {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.book-card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: auto;
}

/* ===== WELCOME STATE ===== */
.welcome-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    padding: 3rem;
}

.welcome-state.hidden {
    display: none;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-icon {
    font-size: 5rem;
    color: var(--text-secondary);
    opacity: 0.3;
    margin-bottom: 1.5rem;
}

.welcome-content h2 {
    font-family: 'Crimson Text', serif;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .book-display {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .search-header {
        padding: 1rem 1.5rem;
    }

    .user-name {
        display: none;
    }
}

/* ===== ANIMATED BOOK LOADER ===== */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loader-container.active {
    opacity: 1;
    pointer-events: all;
}

.loader-text {
    margin-top: 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Crimson Text', serif;
}

.book,
.book__pg-shadow,
.book__pg {
    animation: cover 5s ease-in-out infinite;
}

.book {
    background-color: hsl(268, 90%, 65%);
    border-radius: 0.25em;
    box-shadow:
        0 0.25em 0.5em hsla(0, 0%, 0%, 0.3),
        0 0 0 0.25em hsl(278, 100%, 57%) inset;
    padding: 0.25em;
    perspective: 37.5em;
    position: relative;
    width: 8em;
    height: 6em;
    transform: translate3d(0, 0, 0);
    transform-style: preserve-3d;
}

.book__pg-shadow,
.book__pg {
    position: absolute;
    left: 0.25em;
    width: calc(50% - 0.25em);
}

.book__pg-shadow {
    animation-name: shadow;
    background-image: linear-gradient(
        -45deg,
        hsla(0, 0%, 0%, 0) 50%,
        hsla(0, 0%, 0%, 0.3) 50%
    );
    filter: blur(0.25em);
    top: calc(100% - 0.25em);
    height: 3.75em;
    transform: scaleY(0);
    transform-origin: 100% 0%;
}

.book__pg {
    animation-name: pg1;
    background-color: hsl(223, 10%, 100%);
    background-image: linear-gradient(
        90deg,
        hsla(223, 10%, 90%, 0) 87.5%,
        hsl(223, 10%, 90%)
    );
    height: calc(100% - 0.5em);
    transform-origin: 100% 50%;
}

.book__pg--2,
.book__pg--3,
.book__pg--4 {
    background-image: repeating-linear-gradient(
            hsl(223, 10%, 10%) 0 0.125em,
            hsla(223, 10%, 10%, 0) 0.125em 0.5em
        ),
        linear-gradient(90deg, hsla(223, 10%, 90%, 0) 87.5%, hsl(223, 10%, 90%));
    background-repeat: no-repeat;
    background-position: center;
    background-size:
        2.5em 4.125em,
        100% 100%;
}

.book__pg--2 {
    animation-name: pg2;
}

.book__pg--3 {
    animation-name: pg3;
}

.book__pg--4 {
    animation-name: pg4;
}

.book__pg--5 {
    animation-name: pg5;
}

/* Book Loader Animations */
@keyframes cover {
    from,
    5%,
    45%,
    55%,
    95%,
    to {
        animation-timing-function: ease-out;
        background-color: hsl(278, 84%, 67%);
    }
    10%,
    40%,
    60%,
    90% {
        animation-timing-function: ease-in;
        background-color: hsl(271, 90%, 45%);
    }
}

@keyframes shadow {
    from,
    10.01%,
    20.01%,
    30.01%,
    40.01% {
        animation-timing-function: ease-in;
        transform: translate3d(0, 0, 1px) scaleY(0) rotateY(0);
    }
    5%,
    15%,
    25%,
    35%,
    45%,
    55%,
    65%,
    75%,
    85%,
    95% {
        animation-timing-function: ease-out;
        transform: translate3d(0, 0, 1px) scaleY(0.2) rotateY(90deg);
    }
    10%,
    20%,
    30%,
    40%,
    50%,
    to {
        animation-timing-function: ease-out;
        transform: translate3d(0, 0, 1px) scaleY(0) rotateY(180deg);
    }
    50.01%,
    60.01%,
    70.01%,
    80.01%,
    90.01% {
        animation-timing-function: ease-in;
        transform: translate3d(0, 0, 1px) scaleY(0) rotateY(180deg);
    }
    60%,
    70%,
    80%,
    90%,
    to {
        animation-timing-function: ease-out;
        transform: translate3d(0, 0, 1px) scaleY(0) rotateY(0);
    }
}

@keyframes pg1 {
    from,
    to {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.4deg);
    }
    10%,
    15% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(180deg);
    }
    20%,
    80% {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(180deg);
    }
    85%,
    90% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(180deg);
    }
}

@keyframes pg2 {
    from,
    to {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(0.3deg);
    }
    5%,
    10% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.3deg);
    }
    20%,
    25% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.9deg);
    }
    30%,
    70% {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(179.9deg);
    }
    75%,
    80% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.9deg);
    }
    90%,
    95% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.3deg);
    }
}

@keyframes pg3 {
    from,
    10%,
    90%,
    to {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(0.2deg);
    }
    15%,
    20% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.2deg);
    }
    30%,
    35% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.8deg);
    }
    40%,
    60% {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(179.8deg);
    }
    65%,
    70% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.8deg);
    }
    80%,
    85% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.2deg);
    }
}

@keyframes pg4 {
    from,
    20%,
    80%,
    to {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(0.1deg);
    }
    25%,
    30% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.1deg);
    }
    40%,
    45% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.7deg);
    }
    50% {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(179.7deg);
    }
    55%,
    60% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.7deg);
    }
    70%,
    75% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0.1deg);
    }
}

@keyframes pg5 {
    from,
    30%,
    70%,
    to {
        animation-timing-function: ease-in;
        background-color: hsl(223, 10%, 45%);
        transform: translate3d(0, 0, 1px) rotateY(0);
    }
    35%,
    40% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0deg);
    }
    50% {
        animation-timing-function: ease-in-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(179.6deg);
    }
    60%,
    65% {
        animation-timing-function: ease-out;
        background-color: hsl(223, 10%, 100%);
        transform: translate3d(0, 0, 1px) rotateY(0);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .main-content {
        margin-left: 60px;
    }

    .nav-item {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .search-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .search-box {
        max-width: 100%;
    }

    .book-display,
    .search-results {
        padding: 1.5rem;
    }

    .book-title {
        font-size: 2rem;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
    }
}