/* css/style.css - Versão Corrigida para o̊ */

/* --- 0. RESET GLOBAL --- */
* { box-sizing: border-box; }

/* --- 1. CONFIGURAÇÃO DE FONTES --- */
@font-face { 
    font-family: 'CharisSIL'; 
    src: url('../fonts/CharisSIL-Regular.woff2') format('woff2'),
         url('../fonts/CharisSIL-Regular.ttf') format('truetype');
    font-display: swap;
}

@font-face { 
    font-family: 'CharisSILBold'; 
    src: url('../fonts/CharisSIL-Bold.woff2') format('woff2'),
         url('../fonts/CharisSIL-Bold.ttf') format('truetype');
    font-display: swap;
}

@font-face { 
    font-family: 'GordinWomeh'; 
    src: url('../fonts/GordinWomeh-Regular.ttf') format('truetype'); 
}

@font-face { 
    font-family: 'GordinWomehBold'; 
    src: url('../fonts/GordinWomeh-Bold.ttf') format('truetype'); 
}

@font-face { 
    font-family: 'WomehHand'; 
    src: url('../fonts/WomehSegoePrint.ttf') format('truetype'); 
}

@font-face { 
    font-family: 'Comic Neue'; 
    src: url('../fonts/ComicNeue-Regular.ttf') format('truetype'); 
}

@font-face { 
    font-family: 'Comic Neue Bold'; 
    src: url('../fonts/ComicNeue-Bold.ttf') format('truetype'); 
}

/* --- 2. CORES E TEMA --- */
:root {
    --azul-ciano: #00B7EB;
    --verde-hortela: #00AB78;
    --terracota: #E35336;
    --cinza-carvao: #36454F;
    --poeira: #fff2f0; 
    
    --bg-color: var(--poeira);
    --text-color: var(--cinza-carvao);
    --card-bg: #fff;
    --nav-bg-img: url('../img/barra_azul.png');
    --footer-bg-img: url('../img/barra_terracota.png');
    --border-color: #eee;
    --espacamento-uome: 1.5px; 
}

body.dark-mode {
    --bg-color: var(--cinza-carvao) !important;
    --text-color: var(--poeira) !important; 
    --card-bg: #2C3E50 !important;
    --nav-bg-img: url('../img/barra_azul_dark.png') !important;
    --footer-bg-img: url('../img/barra_terracota_dark.png') !important;
    --border-color: #4a5a6a !important;
}

/* --- 3. ESTRUTURA GLOBAL --- */
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; height: 100%; display: flex; flex-direction: column; }

body {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
    transition: background-color 0.3s, color 0.3s;
    font-family: 'CharisSIL', serif;
    
    /* ⭐ CRITICAL: Força renderização OpenType para diacríticos */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 
        "ccmp" 1,  /* Composição de caracteres combinados */
        "mark" 1,  /* Posicionamento de marcas diacríticas */
        "mkmk" 1,  /* Marca sobre marca */
        "liga" 1;  /* Ligatures */
    font-variant-ligatures: common-ligatures;
}

/* ⭐ Aplicar features OpenType em todos elementos que usam CharisSIL */
textarea,
input,
.search-input,
.main-word,
.word-info,
p, span, div {
    text-rendering: optimizeLegibility;
    font-feature-settings: "ccmp" 1, "mark" 1, "mkmk" 1;
}

a { text-decoration: none; color: inherit; transition: opacity 0.2s; }
a:hover { opacity: 0.8; }

/* --- 4. HEADER & MENU --- */
header { width: 100%; flex-shrink: 0; }

.nav-bar {
    display: flex; justify-content: space-between; align-items: center;
    height: 50px; padding: 0 10px;
    background-image: var(--nav-bg-img);
    background-repeat: repeat-x; background-position: center; background-size: cover;
}

.nav-left { 
    display: flex; align-items: center; justify-content: center;
    height: 100%; 
    z-index: 200; 
}

#theme-toggle {
    background: transparent; border: none; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
}
#theme-toggle img { 
    width: 38px; 
    height: auto; 
    display: block; 
    filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.2)); 
}

.nav-links { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.nav-links a { 
    font-family: 'GordinWomeh', sans-serif; 
    font-size: 1.5em; 
    white-space: nowrap;
    letter-spacing: var(--espacamento-uome);
}

.nav-icons { display: flex; gap: 10px; align-items: center; }
.icon-btn { width: 28px; height: 28px; cursor: pointer; transition: transform 0.2s; }

/* --- 5. HERO, BUSCA, CARDS --- */
.hero { position: relative; width: 100%; min-height: 350px; background-color: var(--bg-color); }
.main-art { width: 100%; min-height: 350px; object-fit: cover; mask-image: linear-gradient(to bottom, black 90%, transparent 100%); -webkit-mask-image: linear-gradient(to bottom, black 90%, transparent 100%); }

.search-wrapper { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 600px; z-index: 10; text-align: center; }

.search-box { 
    position: relative; 
    display: flex; 
    align-items: center; 
    background: var(--card-bg); 
    border-radius: 25px; 
    padding: 5px 15px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3); 
    margin-bottom: 15px; 
    height: 50px; 
}

.search-input { 
    flex: 1; 
    border: none; 
    background: transparent; 
    font-size: 1.1em; 
    padding: 10px; 
    outline: none; 
    font-family: 'CharisSIL', serif; 
    color: var(--text-color); 
    padding-right: 110px; 
}

.lang-swap-btn { 
    position: absolute; 
    right: 50px; 
    top: 50%; 
    transform: translateY(-50%); 
    font-family: 'GordinWomehBold', sans-serif; 
    color: #555; 
    background: #f0f0f0; 
    padding: 4px 10px; 
    border-radius: 15px; 
    font-size: 0.9em; 
    border: 1px solid #ddd; 
    z-index: 20; 
    white-space: nowrap;
    letter-spacing: var(--espacamento-uome);
}

.search-btn { border: none; background: none; cursor: pointer; padding: 5px; }

.lang-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tag { 
    background: var(--card-bg); color: var(--text-color); padding: 5px 12px; border-radius: 20px; 
    font-family: 'GordinWomeh', sans-serif; 
    font-size: 0.85em; font-weight: bold; border: 1px solid var(--border-color); box-shadow: 1px 2px 5px rgba(0,0,0,0.2); 
    letter-spacing: var(--espacamento-uome);
}
.tag:hover, .tag:active { background-color: #D98BA3 !important; color: white !important; border-color: #D98BA3; }
.tag.active { background-color: #84BC95 !important; color: white !important; border-color: #84BC95; pointer-events: none; }

.content-wrapper { max-width: 1000px; margin: 20px auto; padding: 0 20px; width: 100%; flex: 1; }
.page-content img, .rich-text-content img { max-width: 100%; height: auto; border-radius: 10px; }
.section-title { font-family: 'WomehHand', cursive; font-size: 1.8em; margin-bottom: 20px; color: var(--text-color); }
.word-card { background: var(--card-bg); border: 1px solid var(--text-color); border-radius: 25px; padding: 30px; position: relative; box-shadow: 5px 5px 0px rgba(0,0,0,0.1); min-height: 200px; }

.card-header { display: flex; justify-content: space-between; margin-bottom: 20px; }

.dice-icon { width: 60px; cursor: pointer; transition: transform 0.6s ease-in-out; display: block; } 
.dice-icon:hover { transform: rotate(360deg); }

.word-card-inner { display: flex; flex-direction: row; gap: 30px; }
.word-info { flex: 1; }
.word-visual { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 20px; }

.main-word { 
    font-size: 1.6em; 
    color: var(--verde-hortela); 
    font-family: 'GordinWomehBold', sans-serif; 
    margin-bottom: 15px; 
    letter-spacing: var(--espacamento-uome);
}

.label { font-weight: bold; font-family: 'CharisSILBold'; color: var(--terracota); }
.verbete-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--text-color); }
.extra-block h4 { margin: 0 0 5px 0; font-family: 'Comic Neue Bold', sans-serif; color: var(--cinza-carvao); font-size: 1.2em; }
body.dark-mode .extra-block h4 { color: var(--poeira) !important; }

/* --- 6. FOOTER --- */
footer { position: relative; min-height: 40px; flex-shrink: 0; background-image: var(--footer-bg-img); background-repeat: repeat-x; background-size: auto 100%; margin-top: 20px; padding: 5px 0; display: flex; justify-content: center; align-items: center; }
.scroll-top { margin-top: -10px; transition: transform 0.3s; display: inline-block; cursor: pointer; }
.scroll-top:hover { transform: translateY(-5px); }
.arrow-icon { width: 35px; filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.3)); }

/* --- 7. TABELAS --- */
table { border-collapse: collapse !important; width: 100%; margin-bottom: 20px; }
.table-invisible, .table-invisible td, .table-invisible th { border: none !important; background: transparent !important; }
.table-cyan { border: 2px solid #00B7EB; } .table-cyan td, .table-cyan th { border: 1px solid #00B7EB; } .table-cyan th { background-color: #00B7EB; color: white; }
.table-green { border: 2px solid #00AB78; } .table-green td, .table-green th { border: 1px solid #00AB78; } .table-green th { background-color: #00AB78; color: white; }
.table-terracotta { border: 2px solid #E35336; } .table-terracotta td, .table-terracotta th { border: 1px solid #E35336; } .table-terracotta th { background-color: #E35336; color: white; }
.table-charcoal { border: 2px solid #36454F; } .table-charcoal td, .table-charcoal th { border: 1px solid #36454F; } .table-charcoal th { background-color: #36454F; color: white; }
.table-dust { border: 2px solid #ffe5e0; } .table-dust td, .table-dust th { border: 1px solid #ffe5e0; color: #36454F; } .table-dust th { background-color: #fff2f0; }
.table-striped tr:nth-child(even) { background-color: rgba(0,0,0,0.05); }

/* --- 8. FULL WIDTH --- */
.full-width-mode { max-width: 100% !important; width: 100% !important; padding: 0 !important; margin: 0 !important; }
.transparent-container { background: transparent !important; border: none !important; box-shadow: none !important; padding: 20px 10px !important; width: 100%; }
.transparent-container img { max-width: 100%; height: auto; display: block; margin: 10px auto; }
textarea.rich-text { width: 100%; min-height: 500px; padding: 15px; border: 1px solid #ccc; background: #fff; color: #000; }

/* --- 9. DARK MODE CORES --- */
body.dark-mode [style*="color"] {
    filter: brightness(1.5); 
}

body.dark-mode [style*="color: #000000"],
body.dark-mode [style*="color: rgb(0, 0, 0)"],
body.dark-mode [style*="color: black"],
body.dark-mode [style*="color: #36454F"],
body.dark-mode [style*="color: rgb(54, 69, 79)"] {
    color: var(--poeira) !important;
    -webkit-text-fill-color: var(--poeira) !important;
    filter: none;
}

/* --- 10. TINYMCE EDITOR --- */
.tox-tinymce { 
    height: 800px !important;
    min-height: 800px !important;
    max-height: none !important;
}

.tox-sidebar-wrap {
    height: 800px !important;
    min-height: 800px !important;
}

.tox-edit-area {
    height: 750px !important;
    min-height: 750px !important;
}

.tox-edit-area__iframe {
    height: 750px !important;
    min-height: 750px !important;
}

/* --- 11. PLAYER DE ÁUDIO --- */
audio {
    width: 100%;
    max-width: 300px;
    height: 40px;
    margin: 10px 0;
    border-radius: 20px;
    background-color: #f1f3f4;
}
body.dark-mode audio {
    filter: invert(1) hue-rotate(180deg);
}

/* --- 12. VÍDEOS EMBARCADOS --- */
.rich-text iframe, 
.rich-text object, 
.rich-text embed,
.rich-text video {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
    margin: 15px 0;
    border: none;
}

.rich-text iframe[src*="shorts"], 
.rich-text iframe[src*="tiktok"] {
    aspect-ratio: 9 / 16;
    max-width: 350px;
    display: block;
    margin: 15px auto;
}

/* --- 13. MOBILE OVERFLOW FIX --- */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

img, video, iframe, object, embed, .rich-text {
    max-width: 100% !important;
    height: auto !important;
}

/* --- 14. MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
    .nav-bar { flex-direction: column; height: auto; padding-bottom: 10px; gap: 10px; }
    .nav-left { order: 1; width: 100%; justify-content: flex-start; }
    .nav-icons { order: 2; width: auto; position: absolute; top: 10px; right: 15px; gap: 25px; z-index: 9999; }
    .nav-links { order: 3; width: 100%; justify-content: center; border-top: 1px solid rgba(0,0,0,0.1); padding-top: 10px; }
    
    .word-card-inner { flex-direction: column; }
    .word-info, .word-visual { display: contents; }
    .main-word { order: 1; width: 100%; text-align: center; }
    .verbete-img { order: 2; width: 100%; margin-bottom: 20px; }
    .word-info p { order: 3; width: 100%; }
    .extra-block { order: 4; width: 100%; background: rgba(0,0,0,0.03); padding: 10px; }

    .hero { 
        min-height: auto !important; 
        display: flex;
        flex-direction: column;
        padding-bottom: 20px;
    }
    
    .main-art {
        min-height: auto !important;
        height: auto !important;
        max-height: 50vh;
        aspect-ratio: auto;
        object-fit: contain !important;
        order: 1;
    }

    .search-wrapper {
        order: 2;
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        width: 100% !important;
        margin-top: -25px;
        padding: 0 15px;
    }

    .search-box {
        padding: 5px 10px;
    }
    
    .lang-swap-btn {
        right: 15px;
        padding: 3px 8px;
        font-size: 0.8em;
    }
    
    .search-input {
        font-size: 1em; 
        padding-right: 80px;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    p, h1, h2, h3, h4, li, div, td {
        overflow-wrap: break-word;
        word-wrap: break-word;
        hyphens: auto;
    }

    .content-wrapper {
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
    }
}

/* --- 15. ADMIN & FORMS WIDTH FIX --- */
input[type="text"],
input[type="email"],
input[type="password"],
select,
.tab-content input,
.admin-form input {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
}

textarea {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: pre-wrap !important; 
    overflow-wrap: break-word !important;
}

.tab-content, 
.tab-pane,
.admin-tabs-wrapper {
    width: 100% !important;
    overflow: visible !important;
}

.tox-tinymce {
    width: 100% !important;
}

.text-box textarea {
    height: 100%;
    resize: none;
    line-height: 1.5;
}
