﻿/* =====================================================
   RESET
===================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f6f6f6;
    color: #222;
}


/* =====================================================
   LOGIN
===================================================== */

#login {
    width: min(420px, calc(100% - 32px));
    margin: 80px auto;
    padding: 35px 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
    text-align: center;
}

#login h1 {
    margin-top: 0;
    margin-bottom: 28px;
}

#login input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d7d7d7;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}

#login input:focus {
    border-color: #888;
}

#login button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: #222;
    color: white;
    font-size: 15px;
    cursor: pointer;
}

#login button:hover {
    background: #444;
}

#message {
    margin-bottom: 0;
    color: #555;
}


/* =====================================================
   LIBRARY
===================================================== */

#library {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

#library > h1 {
    margin-top: 0;
    margin-bottom: 28px;
}


/* =====================================================
   SHARE SECTION
===================================================== */

#shareSection {
    background: white;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 28px;
}

#shareSection h3 {
    margin-top: 0;
}

#shareEmail {
    width: min(360px, 100%);
    padding: 10px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 7px;
    font-size: 14px;
}

#shareButton {
    padding: 10px 16px;
    margin-left: 6px;
    border: none;
    border-radius: 7px;
    background: #222;
    color: white;
    cursor: pointer;
}

#shareButton:hover {
    background: #444;
}

#shareMessage {
    color: #555;
}

#memberList {
    margin-top: 14px;
}

.memberRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #eee;
}

.memberRow:last-child {
    border-bottom: none;
}

.removeMemberButton {
    border: 1px solid #ddd;
    background: white;
    color: #555;
    padding: 5px 9px;
    border-radius: 6px;
    cursor: pointer;
}

.removeMemberButton:hover {
    background: #f3f3f3;
}


/* =====================================================
   BOOK GRID
===================================================== */

#bookList {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(190px, 1fr));
    gap: 22px;
    align-items: start;
}


/* =====================================================
   BOOK CARD
===================================================== */

.book-card {
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.06);

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.book-card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 7px 20px rgba(0, 0, 0, 0.10);
}


/* =====================================================
   COVER
===================================================== */

.book-cover-wrap {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: #eeeeee;
    overflow: hidden;
    position: relative;
}

.book-cover-placeholder {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 48px;
    color: #999;
}

.book-cover {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;
    display: none;
}


/* =====================================================
   BOOK INFO
===================================================== */

.book-info {
    padding: 12px;
}

.book-card h3 {
    margin: 0 0 7px;

    font-size: 16px;
    line-height: 1.35;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    overflow: hidden;

    min-height: 43px;
}

.book-author {
    margin: 0 0 7px;

    color: #777;
    font-size: 13px;
}

.book-opened {
    margin: 0 0 12px;

    color: #888;
    font-size: 12px;
}


/* =====================================================
   START BUTTON
===================================================== */

.book-actions {
    width: 100%;
}

.book-actions .readButton {
    width: 100%;

    padding: 9px 12px;

    border: none;
    border-radius: 7px;

    background: #222;
    color: white;

    font-size: 14px;

    cursor: pointer;
}

.book-actions .readButton:hover {
    background: #444;
}

.book-actions .readButton:active {
    transform: scale(0.98);
}


/* =====================================================
   READER
===================================================== */

#reader {
    min-height: 100vh;
    padding: 15px;
    background: #fff;
}

#backToLibrary {
    border: none;
    background: #eee;
    padding: 8px 13px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
}

#backToLibrary:hover {
    background: #ddd;
}

#readerTitle {
    margin: 15px 0;
}


/* =====================================================
   READER LAYOUT
===================================================== */

#readerLayout {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    height: calc(100vh - 115px);
}


/* =====================================================
   TOC
===================================================== */

#toc {
    background: #f7f7f7;
    border: 1px solid #e2e2e2;
    border-radius: 10px;

    overflow-y: auto;
    padding: 10px;
}

#toc h3 {
    margin-top: 0;
    position: sticky;
    top: 0;

    background: #f7f7f7;
    padding-bottom: 7px;

    font-size: 15px;
}

#tocList {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#tocList button {
    width: 100%;

    text-align: left;

    padding: 6px 8px;

    border: none;
    border-radius: 5px;

    background: transparent;

    cursor: pointer;

    font-size: 12px;
    line-height: 1.3;
}

#tocList button:hover {
    background: #e9e9e9;
}

#tocList button.active {
    background: #222;
    color: white;
}

/* =====================================================
   READER AREA
===================================================== */

#readerContent {
    min-width: 0;

    display: flex;
    flex-direction: column;

    min-height: 0;
}

#readerArea {
    flex: 1;

    min-height: 0;

    border: 1px solid #e3e3e3;
    border-radius: 10px;

    overflow: hidden;

    background: white;
}


/* =====================================================
   CHAPTER BUTTONS
===================================================== */

#chapterButtons {
    display: flex;
    justify-content: space-between;
    gap: 10px;

    padding-top: 12px;
}

#chapterButtons button {
    border: 1px solid #ddd;
    background: white;

    padding: 9px 15px;

    border-radius: 7px;

    cursor: pointer;
}

#chapterButtons button:hover {
    background: #f1f1f1;
}


/* =====================================================
   MOBILE
===================================================== */

 @media (max-width: 700px) {

    #library {
        padding: 18px 12px;
    }

    /* toàn bộ phần mobile của m ở đây */




    #library > h1 {
        font-size: 25px;
        margin-bottom: 20px;
    }


    /* 2 sách / hàng */

    #bookList {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 12px;
    }


    .book-card h3 {
        font-size: 14px;
        min-height: 38px;
    }


    .book-info {
        padding: 9px;
    }


    .book-author {
        font-size: 12px;
    }


    .book-opened {
        font-size: 11px;
    }


    .book-actions .readButton {
        padding: 8px;
        font-size: 13px;
    }


    /* Share */

    #shareEmail {
        width: 100%;
        margin-bottom: 8px;
    }


    #shareButton {
        width: 100%;
        margin-left: 0;
    }
    #chapterButtons {
    padding-top: 8px;
    gap: 8px;
}

#chapterButtons button {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
}



/* Reader */

#reader {
    padding: 7px 10px;
}

#backToLibrary {
    padding: 6px 10px;
    font-size: 13px;
}

#readerTitle {
    margin: 7px 0 8px;
    font-size: 20px;
}

#readerLayout {
    grid-template-columns: 1fr;
    height: auto;
}

#toc {
    max-height: 95px;
    overflow-y: auto;
}

#tocList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px 6px;
}

#tocList button {
    padding: 5px 6px;
    font-size: 11px;
    line-height: 1.2;
}

#readerContent {
    height: calc(100vh - 185px);
    min-height: 500px;
}

#chapterButtons {
    padding-top: 8px;
    gap: 8px;
}

#chapterButtons button {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
}
 }
/* =====================================================
   VERY SMALL PHONE
===================================================== */

@media (max-width: 380px) {

    #bookList {
        gap: 9px;
    }


    .book-card h3 {
        font-size: 13px;
    }


    .book-info {
        padding: 8px;
    }


    .book-opened {
        font-size: 10px;
    }
}