/* Container principal */
.author-book-form {
    max-width: 100%;
    padding: 20px;
    background: #fdfcfb;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 0;
    margin-top: 0;
}

/* Layout principal */
.author-book-layout {
    display: flex;
    padding: 0 20px;
    gap: 20px;
}

/* Campos do formulário */
.form-field {
    margin-bottom: 1.5em;
    width: 100%;
}

.form-field label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #333;
}

.form-field input[type="text"],
.form-field textarea {
    font-size: 16px !important; 
    font-weight: normal !important;
    color: #000 !important;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box; 
}

.form-field textarea {
    min-height: 150px;
}

.form-field textarea {
    min-height: 150px;
}

.author-books-header {
    padding: 0;
    display: block;
}

.ai-icon {
    background: url('ai.png') no-repeat left center;
    display: inline-flex;
    align-items: center;
    background-color: #5CCFBF;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    padding: 10px 10px;
    margin-bottom: -5px;
}

/* Meus-Livros */
.author-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 0fr));
    gap: 20px;
    padding: 20px;
}

.book-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: #fff;
    width: fit-content;
    height: 100%; /* Garante que todos os cards tenham a mesma altura */
    justify-content: space-between; /* Distribui o espaço verticalmente */
}

.book-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.book-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: auto;
  width: 100%;
}

.book-actions .button {
  height: 40px;
  min-width: 80px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  margin: 0;
  box-sizing: border-box;
}

@media (max-width: 768px) {
    .book-card {
        padding: 15px;
        width: 100%; 
    }
}

@media (max-width: 480px) {
    .book-card {
        padding: 10px;
        width: 100%; 
    }
}

/* Ajuste para as imagens responsivas */
.book-imagem,
.book-cover {
    width: 100%;
    max-width: 300px; /* Definindo uma largura máxima */
    height: auto;
    aspect-ratio: 2/3; /* Define a proporção exata de 2:3 */
    object-fit: cover;
    border-radius: 4px;
}

.book-titulo {
    font-size: 16px;
    margin: 10px 0;
    color: #333;
    font-family: "Poppins", Sans-serif;
    font-weight: 600;
    text-transform: none;
    font-style: normal;
    text-decoration: none;
    line-height: 1.2em;
    letter-spacing: 0px;
    word-spacing: 0em;
    padding: 0px;
}

.book-tipo {
    display: inline-block;
    padding: 4px 12px;
    margin: 5px 0 10px;
    background-color: #eee;
    color: #666;
    border-radius: 3px;
    font-size: 14px;
    font-family: "Poppins", Sans-serif;
    font-weight: 500;
}

.book-descricao {
    margin-bottom: 20px;
    color: #333;
    padding: 0px;
}

.book-botao,
.book-botao-off {
    display: inline-block;
    float: right;
    padding: 10px 30px;
    margin-right: 0px;
    color: white;
    font-weight: bold;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    min-width: fit-content;
}

.book-botao {
    background-color: #5CCFBF;
}

.book-botao:hover {
    background-color: #1B98E0;
    color: white;
}

.book-botao-off {
    background-color: #1D2327;
    color: #FE524D;
}

.ver-todos {
    float: right;
    background-color: #1D2327;
    margin-right: 20px;
}

/* Responsividade de Grade de Livros */
@media (min-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .author-books-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* AJUSTADO */
        gap: 15px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .author-books-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* NOVO */
        gap: 10px;
        padding: 10px;
    }
}

/* Edição de livro */
.form-content-wrapper {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

.form-cover-container {
    width: 200px;
    flex-shrink: 0;
}

.form-fields-container {
    flex: 1;
    min-width: 0;
}

.current-cover {
    margin-bottom: 1em;
    position: relative;
}

.current-cover img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    object-fit: cover;
}

.remove-cover {
    padding: 8px 16px;
    background: #98e1d6;
    color: #333;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: -10px;
    width: 100%;
}

.remove-cover:hover {
    background: #7dd1c5;
}

.button-primary {
    padding: 10px 20px;
    background: #98e1d6;
    color: #333;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    float: right;
}

.button-primary:hover {
    background: #FE524D;
    color: #fff;
}

/* Botão */
.button {
    display: inline-block;
    padding: 10px 20px;
    background: #5CCFBF;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
}

.button:hover {
    background: #005177;
}

.button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Botão de Upload de Arquivo */
.custom-file-upload {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
}

.custom-file-upload input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

.file-upload-button {
    padding: 8px 16px;
    background: #5CCFBF;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
}

.file-upload-button:hover {
    background: #7dd1c5;
}

.file-name {
    color: #666;
    font-size: 14px;
}

/* Sidebar de capítulos */
.book-chapters-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fbfbfa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    height: fit-content;
}

.book-chapters-sidebar h3 {
    margin: 0 0 15px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    color: #333;
}

/* Lista de capítulos */

.book-title h2 {
    font-size: 20px !important;
    color: #333;
    margin: 10px 0;
    font-weight: 600;
    text-transform: none;
    font-style: normal;
    text-decoration: none;
    letter-spacing: 0px;
    word-spacing: 0em;
    padding: 0px;
}


.chapters-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
}

.chapters-list th,
.chapters-list td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.chapters-list th {
    background: #f5f5f5;
    font-weight: 600;
}

.chapters-list tr:hover {
    background: #f9f9f9;
}

.chapter-item {
    border-radius: 6px;
    transition: background-color 0.2s;
}

.chapter-item:hover {
    background-color: #f5f5f5;
}

.chapter-title {
    display: block;
    padding: 0px;
    color: #333;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.2s;
}

.chapter-title:hover {
    color: #5CCFBF;
}

.chapter-title-in {
    font-size: 20px;
    font-weight: bold;
}

.chapter-summary {
   font-size: 16px !important;  
   font-style: normal !important;  
   font-variant: normal  !important;
   font-weight: normal  !important;
}

/* Ações nos capítulos */
.chapter-actions {
    display: flex;
    gap: 10px;
}

.chapter-actions a {
    color: #5CCFBF;
    text-decoration: none;
}

.chapter-actions a:hover {
    text-decoration: underline;
}

/* Edição de capítulo */
.chapter-edit-form {
    flex: 1;
    min-width: 0;
    background: #fdfcfb;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.form-actions-left {
    display: flex;
    gap: 10px;
}

.form-actions-right {
    display: flex;
    gap: 10px;
}

.delete-chapter {
    background-color: #dc3545 !important;
    color: white !important;
}

.delete-chapter:hover {
    background-color: #c82333 !important;
}

/* CSS DE PARTES */
.chapters-list-by-parts .part-group {
    margin-bottom: 15px;
    }
    
.chapters-list-by-parts .part-header {
    font-weight: bold;
    padding: 5px 10px;
    background-color: #f0f0f0;
    border-radius: 3px;
    margin-bottom: 5px;
}

.chapters-list-by-parts .part-chapters {
    margin-left: 10px;
    margin-bottom: 15px;
}

.chapters-list-by-parts .chapter-item {
    margin: 5px 0;
    padding: 3px 5px;
}

.part-header.handle {
    cursor: move;
    position: relative;
    padding-left: 20px;
}

.structure-bestseller-button-container {
    margin: 20px 0;
    text-align: center;
}

.structure-bestseller-button {
    display: inline-block;
    background-color: #5CCFBF;
    color: white;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.structure-bestseller-button:hover {
    background-color: #4AB0A1;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    text-decoration: none;
    color: white;
}

/* Botão Assistente */
.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    position: relative;
}

.field-header label {
    margin: 0;
    flex-grow: 1;
    font-weight: bold;
}

.chatbot-modal-trigger  {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 5px !important;
    background-color: #5CCFBF;
    color: white;
    border: none;
    border-radius: 3px;
    margin-left: 10px;
    margin-bottom: -17px !important;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    position: static;
    z-index: 1;
}

.chatbot-modal-trigger:hover {
    background-color: #4AB0A1;
}

.botao-assistente-modal {
    padding: 10px 17px !important;
    margin-bottom: 10px !important;
}

.botao-assistente-modal:hover {
    background-color: #4AB0A1;
}


.icon-assistant {
    color: white;
    pointer-events: none;
}

/* Modal do Assistente */
.agent-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.agent-modal.open {
    display: block;
    opacity: 1;
}

.agent-modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 5% auto;
    width: 80%;
    height: 80%;
    max-width: 1000px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
}

.agent-modal-close {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #333;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.agent-modal-close:hover {
    color: #000;
}

/* Garante posicionamento fixo adequado em iOS */
.agent-modal {
    -webkit-overflow-scrolling: touch;
}

#agent-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

body.modal-open {
    overflow: hidden;
}

/* Melhora o posicionamento do modal em dispositivos móveis */
@media (max-width: 767px) {
    .agent-modal-content {
        width: 95%;
        height: 90%;
        margin: 5% auto;
        max-width: none;
    }
    
    .agent-modal-close {
        font-size: 32px; /* Botão de fechar maior para toque */
        top: 5px;
        right: 15px;
    }
    
    /* Impede o zoom indesejado em dispositivos iOS */
    input[type="text"], 
    textarea {
        font-size: 16px;
    }
}

/* Input de arquivo */
input[type="file"] {
    display: block;
    margin-top: 0.5em;
}

/* Ajuste para os campos de entrada */
.field-header + input[type="text"],
.field-header + textarea {
    padding-right: 40px;
}

/* Responsividade */
@media (max-width: 1024px) {
    .author-book-layout {
        flex-direction: column;
    }

    .book-chapters-sidebar {
        width: 100%;
    }

    .chapters-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .form-content-wrapper {
        flex-direction: column;
    }

    .form-cover-container {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .author-book-form {
        padding: 15px;
    }

    .button {
        width: 100%;
        text-align: center;
    }
}

/* Mensagens de erro e sucesso */
.error-message {
    color: #dc3545;
    margin-top: 0.5em;
    font-size: 14px;
}

.success-message {
    color: #28a745;
    margin-top: 0.5em;
    font-size: 14px;
}

/* Seção de capítulos */
.book-chapters {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.book-chapters h3 {
    margin-bottom: 1em;
}

/* Loading state */
.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #5CCFBF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Melhorias para botões em mobile */
@media (max-width: 480px) {
    .button-primary,
    .book-botao,
    .book-botao-off,
    .button {
        display: block;
        width: 100%;
        text-align: center;
        padding: 12px 15px;
        margin-bottom: 10px;
    }
    
    .ver-todos {
        float: none;
        width: 100%;
        margin-right: 0;
        margin-top: 10px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions-left,
    .form-actions-right {
        width: 100%;
        margin-bottom: 10px;
    }
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Força a aplicação de estilos em dispositivos móveis */
@media (max-width: 767px) {
    /* Sobrescrever estilos do tema que podem estar causando problemas */
    #content .ast-container {
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .elementor-section.elementor-section-boxed > .elementor-container {
        max-width: 100% !important;
    }
}