/*      GERAL      */

* {
    box-sizing: border-box;
}

body {
    background-image: linear-gradient(#faebd7, black 120%);
    background-attachment: fixed;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0px 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

/*         HEADER           */

header {
    text-align: center;
}

#menu {
    margin: 0;
    background-color: #faebd7;
    border-radius: 10px;
    padding: 0px 0px 0px 0px;
}

/*       NAVEGAÇÃO          */

nav {
    background-color: #c7baaa;
    border-radius: 7px 7px 0px 0px;
    position: relative;
    display: inline-block;
    color: rgb(0, 0, 0);
    padding: 0px;
    cursor: pointer;
    margin-right: 0px;
    vertical-align: bottom;
    margin-bottom: 0;
}

nav:hover {
    background-color: #b8a996;
    transition-duration: 0.3s;
}

/* ===== DROPDOWN ===== */

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #c7baaa;
    color: black;
    padding: 6px;
    min-width: 160px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 0px 0px 7px 7px;
    z-index: 10;
}

nav:hover .dropdown {
    display: block;
}

/* Scrollbar do dropdown */
.dropdown::-webkit-scrollbar {
    width: 6px;
}

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

.dropdown::-webkit-scrollbar-thumb {
    background: #8b7355;
    border-radius: 3px;
}

.dropdown::-webkit-scrollbar-thumb:hover {
    background: #6b5535;
}

.dropdown>a {
    color: black;
    text-decoration: none;
    display: block;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    transition: background-color 0.2s, color 0.2s;
}

.dropdown>a:hover {
    background-color: #b8a996;
    color: #faebd7;
    font-weight: bold;
}

.dropdown>a.semana-ativa {
    background-color: #5a4630;
    color: #faebd7;
    font-weight: bold;
    pointer-events: none;
}

.dropdown-carregando {
    padding: 8px 10px;
    color: #8b7355;
    font-size: 12px;
    font-style: italic;
    margin: 0;
}

.dropdown-vazio {
    padding: 8px 10px;
    color: #8b7355;
    font-size: 12px;
    font-style: italic;
    margin: 0;
}

/*         BOTÕES           */

button {
    background-color: #c7baaa;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
}

button:hover {
    background-color: #b8a996;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Botão Voltar para Atual */
#voltarAtual {
    margin-bottom: 15px;
    background-color: #5a4630;
    color: #faebd7;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 13px;
    border: none;
}

#voltarAtual:hover {
    background-color: #3d2f1e;
}

/* Botão Finalizar Semana */
#finalizarBtn {
    background-color: #5a4630;
    color: #faebd7;
    padding: 4px 10px;
    font-size: 14px;
}

#finalizarBtn:hover {
    background-color: #3d2f1e;
}

/* Botão Desfazer */
#desfazerBtn {
    background-color: #8b3a3a;
    color: #faebd7;
    padding: 4px 10px;
    font-size: 14px;
}

#desfazerBtn:hover {
    background-color: #6b2a2a;
}

/* Modal Desfazer */
#desfazerBox {
    background-color: #faebd7;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
}

#desfazerBox h3 {
    margin-top: 5px;
    margin-bottom: 15px;
    color: #8b3a3a;
}

#desfazerBox p {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    margin-bottom: 10px;
}

.desfazer-aviso {
    font-size: 12px;
    color: #8b3a3a;
    font-style: italic;
    font-weight: bold;
    margin-bottom: 20px;
}

.desfazer-botoes {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.desfazer-botoes button {
    padding: 10px 24px;
    font-size: 14px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}

#confirmarDesfazer {
    background-color: #8b3a3a;
    color: #faebd7;
}

#confirmarDesfazer:hover {
    background-color: #6b2a2a;
}

#desfazerMsg {
    margin-top: 12px;
    font-size: 13px;
}

#desfazerMsg.sucesso {
    color: green;
}

#desfazerMsg.erro {
    color: red;
}

/*          MAIN            */

main {
    background-color: #faebd7;
    border-radius: 10px;
    padding: 20px;
    margin: 15px 0px;
}

main h2 {
    margin-top: 0;
}

/* Indicador de histórico */
.historico-badge {
    display: inline-block;
    background-color: #8b7355;
    color: #faebd7;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
    font-weight: normal;
}

/*     GRID DE LIVROS       */

.books-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
}

.book {
    text-align: center;
    position: relative;
}

.book img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.book img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.book h5 {
    margin: 8px 0 0 0;
    font-size: 14px;
}

/* Botão editar sobre cada livro (só admin) */
.btn-editar-livro {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
    display: none;
    z-index: 5;
    line-height: 30px;
    padding: 0;
}

.btn-editar-livro:hover {
    background-color: rgba(0, 0, 0, 0.85);
}

/*     MODAL (Sinopse)      */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.modal-corpo {
    background-image: linear-gradient(#faebd7, #d4c5b0);
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    width: 85%;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-family: sans-serif;
    line-height: 1.6;
    max-height: 85vh;
    overflow-y: auto;
}

.fechar {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #8e8579;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.fechar:hover {
    color: #333;
}

/*     MODAL DE LOGIN       */

#loginOverlay {
    z-index: 1100;
}

#loginBox {
    background-color: #faebd7;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 350px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
}

#loginBox h3 {
    margin-top: 5px;
    margin-bottom: 20px;
    color: #5a4630;
}

#loginBox input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #c7baaa;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#loginBox input:focus {
    border-color: #8b7355;
}

#loginBox button {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    font-size: 16px;
}

#loginErro {
    margin-top: 10px;
    font-size: 13px;
}

/*    MODAL DE EDIÇÃO       */

#editOverlay {
    z-index: 1200;
}

#editBox {
    background-color: #faebd7;
    padding: 30px;
    border-radius: 10px;
    width: 92%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-height: 85vh;
    overflow-y: auto;
    top: 0%;
}

#editBox h3 {
    margin-top: 5px;
    margin-bottom: 20px;
    color: #5a4630;
    text-align: center;
}

#editBox label {
    display: block;
    margin-bottom: 4px;
    margin-top: 12px;
    font-weight: bold;
    font-size: 13px;
    color: #5a4630;
}

#editBox select,
#editBox input[type="text"],
#editBox textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c7baaa;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
}

#editBox select:focus,
#editBox input[type="text"]:focus,
#editBox textarea:focus {
    border-color: #8b7355;
}

#editBox textarea {
    resize: vertical;
    min-height: 120px;
}

.edit-dica {
    font-size: 12px;
    color: #8b7355;
    margin: 5px 0 15px 0;
}

#salvarEdicao {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    font-size: 16px;
    background-color: #5a4630;
    color: #faebd7;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#salvarEdicao:hover {
    background-color: #3d2f1e;
}

#editMsg {
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
}

#editMsg.sucesso {
    color: green;
}

#editMsg.erro {
    color: red;
}

/*  ================================  */
/*    PAINEL FLUTUANTE DE NOTAS       */
/*  ================================  */

#notasFloat {
    position: fixed;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    width: 260px;
    max-height: 80vh;
    background-color: #f0e4d0;
    border: 2px solid #c7baaa;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1250;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#notasFloat .notas-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid #c7baaa;
    background-color: #e8dcc8;
    flex-shrink: 0;
}

#notasFloat .notas-header h4 {
    margin: 0;
    font-size: 13px;
    color: #5a4630;
    white-space: nowrap;
}

#notasFloat .notas-corpo {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
}

/* Scrollbar */
#notasFloat .notas-corpo::-webkit-scrollbar {
    width: 5px;
}

#notasFloat .notas-corpo::-webkit-scrollbar-track {
    background: transparent;
}

#notasFloat .notas-corpo::-webkit-scrollbar-thumb {
    background: #c7baaa;
    border-radius: 3px;
}

/*     SEÇÕES DAS NOTAS     */

.nota-secao {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #c7baaa;
}

.nota-secao:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.nota-secao h5 {
    font-size: 11px;
    color: #5a4630;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 6px 0;
}

.nota-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 5px;
    padding: 4px 7px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
}

.nota-item.combinacao {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.nota-item code {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #5a4630;
    background-color: rgba(199, 186, 170, 0.4);
    padding: 2px 4px;
    border-radius: 3px;
    word-break: break-all;
}

.nota-resultado {
    font-size: 12px;
    color: #333;
    white-space: nowrap;
}

.nota-dicas {
    margin: 0;
    padding-left: 16px;
    font-size: 11px;
    color: #5a4630;
    line-height: 1.7;
}

.nota-dicas code {
    font-size: 9.5px;
    background-color: rgba(199, 186, 170, 0.4);
    padding: 1px 4px;
    border-radius: 2px;
}

/*    RESPONSIVO - NOTAS NO CELULAR    */

@media (max-width: 800px) {
    #notasFloat {
        left: 10px;
        right: 10px;
        width: auto;
        top: auto;
        bottom: 10px;
        transform: none;
        max-height: 30vh;
        border-radius: 8px;
    }
}

@media (max-width: 600px) {
    #notasFloat {
        max-height: 25vh;
    }

    .nota-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    #editOverlay {
        align-items: flex-start;
        padding-top: 20px;
    }

    #editBox {
        padding: 20px;
        max-height: 85vh;
    }
}

/*   MODAL FINALIZAR SEMANA   */

#finalizarOverlay {
    z-index: 1300;
}

#finalizarBox {
    background-color: #faebd7;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
}

#finalizarBox h3 {
    margin-top: 5px;
    margin-bottom: 15px;
    color: #5a4630;
}

#finalizarTexto {
    font-size: 15px;
    color: #333;
    margin-bottom: 8px;
}

.finalizar-aviso {
    font-size: 12px;
    color: #8b7355;
    font-style: italic;
    margin-bottom: 20px;
    line-height: 1.5;
}

.finalizar-botoes {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.finalizar-botoes button {
    padding: 10px 24px;
    font-size: 14px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}

#cancelarFinalizar {
    background-color: #c7baaa;
    color: #333;
}

#cancelarFinalizar:hover {
    background-color: #b8a996;
}

#confirmarFinalizar {
    background-color: #8b3a3a;
    color: #faebd7;
}

#confirmarFinalizar:hover {
    background-color: #6b2a2a;
}

#finalizarMsg {
    margin-top: 12px;
    font-size: 13px;
}

#finalizarMsg.sucesso {
    color: green;
}

#finalizarMsg.erro {
    color: red;
}

/*         FOOTER           */

footer {
    background-color: #1a1a1a;
    color: #faebd7;
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    font-size: 13px;
}

footer p {
    margin: 0;
}

/*      RESPONSIVIDADE      */

@media (max-width: 600px) {
    #menu {
        padding: 10px 5px 0 5px;
    }

    #menu h1 {
        font-size: 1.4em;
    }

    nav {
        font-size: 12px;
        padding: 4px 7px;
        margin-right: 5px;
        margin-bottom: 0;
        vertical-align: bottom;
    }

    .dropdown {
        max-height: 200px;
    }

    .books-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .modal-corpo {
        width: 92%;
        padding: 20px;
    }

    #editBox {
        padding: 20px;
    }

    .finalizar-botoes {
        flex-direction: column;
    }

    .finalizar-botoes button {
        width: 100%;
    }
}


/* ======================== */
/*    ÁREA DE IMPRESSÃO     */
/* ======================== */

#areaPrint {
    display: none;
}

/* ======================== */
/*    ESTILOS DE IMPRESSÃO  */
/* ======================== */

@media print {

    /* Força paisagem e tamanho A4 */
    @page {
        size: A4 landscape;
        margin: 5mm;
    }

    /* Esconde tudo */
    body * {
        visibility: hidden;
    }

    /* Mostra apenas a área de impressão */
    #areaPrint,
    #areaPrint * {
        visibility: visible;
    }

    #areaPrint {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
    }

    #areaPrint h1 {
        text-align: center;
        margin: 0 0 10px 0;
        font-size: 20px;
        color: #333;
    }

    /* Grid 4 colunas */
    #printContent {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: 10px;
    }

    .print-livro {
        border: 1px solid #ccc;
        padding: 8px;
        border-radius: 5px;
        page-break-inside: avoid;
        overflow: hidden;
    }

    .print-livro h3 {
        margin: 0 0 10px 0;
        padding-bottom: 4px;
        border-bottom: 2px solid #000000;
        font-size: 20px;
        color: #000000;
    }

    .print-livro h4 {
        font-size: 16px;
        margin: 4px 0;
        color: #000000;
    }

    .print-livro p {
        font-size: 16px;
        line-height: 1.15;
        margin: 3px 0;
    }

    /* Formatação dentro da sinopse */
    .print-livro strong {
        font-weight: bold;
    }

    .print-livro em {
        font-style: italic;
    }

    .print-livro u {
        text-decoration: underline;
    }

    .print-livro s {
        text-decoration: line-through;
    }

    .print-livro mark {
        background-color: #000000;
        padding: 0 2px;
    }

    .print-livro small {
        font-size: 7px;
    }

    .print-livro big {
        font-size: 10px;
    }

    .print-livro hr {
        border: none;
        border-top: 1px solid #ccc;
        margin: 4px 0;
    }

    .print-livro br {
        display: block;
        content: "";
        margin: 2px 0;
    }

    /* Esconde elementos desnecessários */
    header,
    footer,
    main,
    .modal,
    #loginOverlay,
    #editOverlay,
    #btnImprimir,
    .btn-editar-livro {
        display: none !important;
    }
}