.chapter_popup {
    /* Initially hidden */
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-vanished-color);
    z-index: 9999;
}
.popup_chap_span {
    display: flex;
    flex-direction: row;
    gap: 4px;
    justify-content: center;
}
.popup_chap_span p {
    margin: 0;
}
.chapter_item p {
    margin: 0;
}

.chapter_popup_container {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 40vw;
    background: var(--background-color);
    border-radius: 1rem;
    box-shadow: 0 4px 16px var(--shadow-semitransparent-color);
    overflow-y: auto;
    text-align:right;
}


.chapter_list_scroll{
    padding: 0.5rem 2rem 0rem 2rem;
}

/* Close X icon*/
.close_popup {
    display: inline-block;
    margin: 1rem 1rem 0 0;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 10000;
}

/*Animation transition X*/
.close_popup:hover {
    transform: rotate(90deg);
}

/* Scrollable chapter list inside card*/
#chapter_list {
    max-height: 70vh;
    overflow-y: auto;
    text-align:center;
}

/*General card-chapter style*/
.chapter_item {
    margin: 0 8px 0.5rem 8px; /* equal horizontal margins */
    padding: 0.5rem;
    border-radius: 8px;
}

/*Unlocked Chpaters*/
.chapter_item.unlocked {
    background-color: var(--card-color);
    cursor: pointer;
}


/*Locked Chpaters*/
.chapter_item.locked {
    background-color: var(--card-locked-color);
    opacity: 0.7;
}
.chapter_item.bought {
    background-color: var(--bc_primary);
    opacity: 1;
}
/*Hover General card-chapter*/
.chapter_item:hover {
    box-shadow: 0 0.2rem 0.4rem var(--shadow-semitransparent-color);
    transform: scale(1.03);
    cursor: pointer; 
}

@media( max-width: 768px) {
    .chapter_popup_container {
        width: 360px;
        top: 25%;
        max-width: 90%;
        height: 50%;    
    }
}
.library_popup {
    display: none; /* Initially hidden */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-vanished-color);
    z-index: 9999;
}

/* Popup container */
.library_popup_container {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 25vw;
    background: var(--background-color);
    border-radius: 1rem;
    box-shadow: 0 4px 16px var(--shadow-semitransparent-color);
    overflow-y: auto;
    padding-bottom: 1rem;
}

/* Close button (X) */
#library_close_popup {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    transition: transform 0.3s ease;
}
#library_close_popup:hover {
    transform: rotate(90deg);
}

/* Center content inside popup */
.popup_content {
    text-align: center;
    padding: 2rem 1rem 1rem 1rem;
}

/* Nueva lista button */
#create_new_list {
    display: inline-block;
    height: 48px;
    width: 280px;
    margin-top: 16px;
    border-radius: 52px;
    background: var(--button-color);
    border: none;
    cursor: pointer;
}
#create_new_list:hover {
    background: var(--button-hover-color);
}

/* Separator line */
.popup_separator {
    width: 80%;
    margin: 1rem auto;
    border: none;
    height: 1px;
    background: var(--button-color);
}

/* Scrollable list section */
/* Parent container that holds all the lists */
.library_list_scroll {
    padding: 0.5rem 1rem;
    max-height: 80vh;       /* adjust to your layout */
    overflow-y: auto;

    /* Reserve scrollbar space so layout doesn’t shift */
    scrollbar-gutter: stable;

    /* Hide scrollbar visually until scrolling */
    scrollbar-width: thin;            /* Firefox */
    scrollbar-color: transparent transparent;
}

.library_list_scroll:hover {
    scrollbar-color: var(--shadow-semitransparent-color) transparent;
}

/* Chrome / Edge / Safari */
.library_list_scroll::-webkit-scrollbar {
    width: 8px;             /* thin scrollbar */
}

.library_list_scroll::-webkit-scrollbar-track {
    background: transparent;
}

.library_list_scroll::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 10px;
}

.library_list_scroll:hover::-webkit-scrollbar-thumb {
    background-color: var(--shadow-semitransparent-color);
}


/* Each list container */
.list_container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 0px 24px;
    border-radius: 10px;
    margin: 14px 24px;
    background-color: var(--card-color);
    box-shadow: 0 2px 4px var(--shadow-semitransparent-color);
}

.list_container:hover{
    background-color: var(--card-hover-color); 
}

.list_container p{
    display: flex;
    align-items: center;
    gap: 4px;
    
}

.list_container .list_name{
    display: -webkit-box;
    -webkit-line-clamp: 3;      /* limit to 3 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;

    text-align: left;           /* ensure left aligned */
    align-self: flex-start;     /* if inside flex container */
    margin-right: 10px;
}

/* Form hidden state */
.popup_content form {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;

    transform: scale(0.8); /* Start smaller */
    transform-origin: top center; /* Makes it come from the top */
    transition: opacity 0.4s ease, max-height 0.4s ease, transform 0.4s ease;
}

/* Form visible state (add 'show' class via JS) */
.popup_content form.show {
    opacity: 1;
    max-height: 200px;
    margin-top: 1rem;

    transform: scale(1); /* Zoom to normal size */
}
/* Input styling */
.popup_content form input[type="text"] {
    padding: 0.6rem;
    width: 80%;
    max-width: 250px;
    border: 2px solid var(--button-color);
    text-align: center;
    border-radius: 10px;;
    background: var(--background-light-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Submit button */
.popup_content form button {
    padding: 0.5rem 1.2rem;
    background-color: var(--button-color);
    color: var(--text-white-color); 
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.popup_content form button:hover {
    background-color: var(--button-hover-color);
}


@media (max-width: 768px) {
  .library_popup_container {
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: none; /* Allow it to take more space on small screens */
    border-radius: 0.75rem;
    padding-bottom: 0.5rem;
  }

  #create_new_list {
    width: 90%; /* Shrink button to fit smaller screen */
    max-width: 300px;
  }

  .popup_content {
    padding: 1.5rem 1rem 1rem 1rem; /* Reduce padding */
  }

  .list_container {
    flex-direction: column; /* Stack items vertically */
    align-items: center;
    margin: 10px 16px;
    padding: 0.75rem;
  }
    
  .list_container p{
      margin: 0;
  }
    
  .popup_content form input[type="text"] {
    width: 90%;
    max-width: 100%;
  }
}
 /*Review title container*/
#title_review {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Optional: vertically align */
}
.reviewForm{
    display: none;
}
/*Sapcing for labels a*/
#title_review p{
    margin: 0;
}
.hor_top_part {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
}
/*General layout right buttons reviews*/
.handle_review a {
    text-decoration: none;
}

/*Padding reviews*/
#reviews {
    display: flex;
    flex-direction: column;
}
.low_part_span{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
/*indivdual review container*/
.review-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s ease;
    margin-bottom: 26px;
}

/*User container avatr + nick*/
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

/*user avatar*/
.user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.review_body{
    padding: 12px 16px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bc_primary_light);
}
/*User nickname*/
.name p {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/*Container title + rating*/
.title-rating {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/*Title fo the review*/
.title-rating .title {
    font-size: 1.1rem;
    font-weight: 700;
}


/*Users rating starts layout*/
.rating {
  display: inline-flex;
  gap: 3px;
}

/*Date of the review*/
.date {
    margin-top: auto;
    text-align: right;
}

/* Container Form */
.review_form {
    width: 100%;
    text-align: center;
    border: none;
    background: inherit;
    padding: 10px;
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
}

/*Sapce between labels*/
.review_content {
    margin-bottom: 16px;
}

/*Sizing input labels for border*/
.review_form input,
.review_form textarea {
    box-sizing: border-box;
}

/* Make rating label and stars inline */
.rating_container {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 18px;
    height: 84px;
    margin-bottom: 10px;
    justify-content: space-around;
    width: 100%;
}
.spoiler_title{
    padding: 2px 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
/* Inputs and textarea */
.review_form input[type="text"],
.review_form textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 0;
    background: inherit;
    resize: vertical;
    text-align: center;
}

.review_form input[type="text"]:focus ,
.review_form textarea:focus  {
    outline: none;
    border: none;
    box-shadow: 0 0 5px var(--bc_primary_light);
}

/*Height of textarea form*/
.review_form textarea {
    min-height: 120px;
    max-height: 180px;
}
hr {
  border: none;
  height: 1px;
  width: 100%;
  background-color: var(--separator-color);
  margin: 24px 0;
}
/* Star Rating */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    font-size: 84px;
    gap: 12px;
}

/*avoid label style with the star*/
.star-rating input[type="radio"] {
    display: none;
}

/*NO color on starts*/
.star-rating label {
    cursor: pointer;
    transition: color 0.2s;
}

/*Color stars*/ 
.star-rating label::before {
  content: '★';
  color: lightgray;
}

/* On hover: fill stars to the left (because of RTL) */
.star-rating label:hover::before,
.star-rating label:hover ~ label::before {
  content: '★';
  color: rgb(205, 166, 94);
}

/* When selected: fill stars to the left (RTL layout) */
.star-rating input[type="radio"]:checked ~ label::before {
  content: '★';
  color: orange;
}



/* Submit Button Centered */
.review_form button[type="submit"] {
    margin: 10px auto 0 auto;
    display: block; 
    margin-top: 10px;
    padding: 10px 20px;
    background-color: var(--button-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
}

/*Submit button on hover*/
.review_form button:hover {
    background-color: var(--button-hover-color);
}

/* Review message -- DOESNT WORK*/
#reviewMessage {
    text-align: center;
    margin-top: 10px;
}


@media(max-width: 768px) {
    #reviews {
        flex-direction: row;
        overflow-x: scroll;
        padding: 0px;
    }
    .reviews-popup-content {
        width: 100%;
        margin: 0px 24px;
    }
    .star-rating {
        font-size: 48px;
        gap: 8px;
    }
    .rating_container{
        margin-top: 8px;
        margin-bottom: 4px;
    }
    .review-card{
        flex-shrink: 0;
        width: 330px;
        height: 185px;
        margin-right: 16px;
        border-bottom: none;
        margin-bottom: 0px;
        overflow: hidden;
        padding-bottom: 0px;
    }
    .review_body{
        height: 140px;
    }
    .reviewForm{
        max-width: 100%;
    }
    .review_content{
        margin-bottom: 18px;
    }
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    margin-left: 10px;
    vertical-align: middle;
  }

  .switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0;
    right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
  }

  .slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
  }

  input:checked + .slider {
    background-color: #4CAF50;
  }

  input:checked + .slider:before {
    transform: translateX(24px);
  }
    .blurred {
    filter: blur(3px);
    position: relative;
    cursor: pointer;
  }

  .spoiler-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.7);
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    padding: 10px;
    border-radius: 6px;
  }

  .review-text {
    position: relative;
    transition: filter 0.3s ease;
  }
  .current-user-review .review_body{
    background-color: var(--card-color);
    border-radius: 4px;
  }

  @media (min-width: 768px) {
    hr {
        margin: 26px 0;
        margin-right: 80px;
        width: calc(100% - 80px);
    }
}
/* Popup base */
.reviews-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
}

.reviews-popup-content {
    max-height: 90%;
    width: 800px;
    padding: 18px 36px;
    box-sizing: border-box;
    background: var(--background-color);
    border-radius: 10px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.review_body_details {
    margin-right: 80px;
    box-sizing: border-box;
}
/* Top section */
.reviews-popup-top {
    margin-bottom: 0px;
    margin-top: 0px;
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--separator-color);
    padding: 12px 4px;
}

.reviews-popup-left {
    flex: 0 0 20%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.big-star {
    font-size: 60px;
}

.reviews-popup-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.rating-row {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.rating-label {
    width: 30px;
}

.rating-bar {
    flex: 1;
    background: #eee;
    height: 10px;
    margin: 0 10px;
    position: relative;
    border-radius: 3px;
    overflow: hidden;
}

.rating-bar > div {
    background: var(--card-locked-color);;
    height: 100%;
}

.rating-count {
    min-width: 20px;
    text-align: right;
}

/* Bottom section */
.reviews-popup-bottom {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    margin-left: 16px;
}

/* Comments */
.review-card-popup {
    display: flex;
    gap: 10px;
    flex-direction: column;
    padding: 10px 0;
}
.top-review-part {
    display: flex;
    gap: 10px;
    flex-direction: row;
}
.review-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.review-divider {
    margin: 2px 0 8px 0px;
}
.review-content {
    margin-left: 54px;
    margin-top: -16px;
    flex: 1;
}

.review-header {
    margin-bottom: 5px;
    margin-right: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.review-header span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.review-stars {
    margin-bottom: 5px;
}

.review-title {
    margin-bottom: 5px;
}

.rating-row.active-rating {
    border-radius: 4px;
    padding: 0px 4px;
    border: 1px solid var(--text-grey-color);
}

@media (max-width: 768px) {
    .reviews-popup-left {
        flex: 0 0 30%;
    }
    .review-divider {
        margin: 2px 0 8px 0px;
    }
    .reviews-popup-bottom {
        margin: 0;
        padding: 0;
    }
    .review-avatar {
        width: 42px;
        height: 42px;
    }
    .review_body_details {
        margin-right: 0px;
    }
    .review-content {
        margin-left: 0;
        margin-top: 0;
    }
    .review-header {
        display: flex;
        flex-direction: column;
        margin-right: 0px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
/* Novel container remains unchanged */
.novel {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 1rem;
  gap: 1rem;
  transition: transform 0.2s ease;
}

/*Move card of similar novels*/
.novel:hover {
  transform: translateY(-3px);
}

/* Right info: text + image */
.novel-right-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}
.novel-rating{
  margin: 0;
  margin-top: 4px;
}
.chap_span, .auth_span {
  gap: 4px;
  display: flex;
  flex-direction: row;
}
/* Main info box */
.novel-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* Distribute title top, author/status bottom */
  max-width: 140px;
  height: 180px; /* Match image height */
  margin-right: auto;
}

/* Novel title at the top */
.novel-title {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;     /* Show up to 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Author and status at the bottom */
.novel-bottom {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-bottom: 1rem;
}

/* Author and status styling */
.novel-author,
.novel-status {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cover image */
.novel-cover {
  height: 180px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  box-shadow: 0 3px 6px var(--shadow-semitransparent-color), 0 12px 24px var(--shadow-semitransparent-color);
}

@media (max-width: 768px) {
  .novel {
    flex-direction: column;
    gap: 5px;
    padding: 0px;
  }
  .novel-cover {
    width: 90px;
    aspect-ratio: 2 / 3;
    height: auto;
    border-radius: 8px;
  }
  .novel-rating, .novel-status, .chap_span {
    display: none;
  }
  .similar_nov_layout {
    white-space: unset;
  }
  .novel-title {
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .auth_span {
    white-space: nowrap;
    max-width: 90px;
  }
  .novel-info {
    height: auto;
  }
  .novel-info {
    height: auto;
  }
}