:root {
    --primary: #3498db;
    --bg: #0a0a0a;
    --panel: rgba(10, 10, 10, 0.98);
    --border: #333;
    --accent: #e74c3c;
}

body {
    margin: 0;
    overflow: hidden; 
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: white;
    display: flex;
    height: 100vh;
}

/* SIDEBAR */
#sidebar {
    width: 70px;
    background: #111;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    z-index: 2000;
    height: 100vh;
    flex-shrink: 0; /* Impede que a sidebar esmague */
}

.nav-item {
    margin-bottom: 25px;
    cursor: pointer;
    font-size: 24px;
    opacity: 0.4;
    transition: 0.3s;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.nav-item.active {
    opacity: 1;
    color: var(--primary);
    background: rgba(52, 152, 219, 0.1);
}

.nav-item:hover {
    opacity: 1;
    background: #222;
}

/* VIEWS */
.view {
    flex: 1;
    height: 100vh;
    position: relative;
    display: none;
    overflow-y: auto; /* Ajustado para permitir scroll na ficha */
    -webkit-overflow-scrolling: touch;
}

.view.active {
    display: block;
}

/* TELA DE DADOS */
#ui-dice-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    background: var(--panel);
    padding: 18px;
    border-radius: 15px;
    z-index: 100;
    border: 1px solid #444;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
}

.dice-btn {
    padding: 12px 18px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    color: white;
    background: #2a2a2a;
    transition: 0.2s;
    min-width: 65px;
    font-size: 14px;
}

.dice-btn:hover {
    background: #444;
    transform: translateY(-3px);
}

.d4 { border-bottom: 4px solid #e74c3c; }
.d6 { border-bottom: 4px solid #e67e22; }
.d8 { border-bottom: 4px solid #f1c40f; }
.d10 { border-bottom: 4px solid #9b59b6; }
.d12 { border-bottom: 4px solid #2ecc71; }
.d20 { border-bottom: 4px solid #3498db; }

#side-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 300px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat {
    max-height: 500px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.6);
    pointer-events: all;
}

.sum-entry {
    background: rgba(46, 204, 113, 0.1);
    border-left: 5px solid #2ecc71;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    animation: slideIn 0.3s ease;
}

.sum-entry strong {
    font-size: 22px;
    color: #2ecc71;
    display: block;
}

.formula {
    color: #aaa;
    font-size: 13px;
    margin-top: 6px;
    font-family: monospace;
    display: block;
}

/* CONFIGS FÍSICA */
#menu-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: #222;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
}

#config-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 250px;
    background: var(--panel);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 20px;
    z-index: 999;
    display: none;
}

.config-group {
    margin-bottom: 15px;
    font-size: 12px;
}

.config-val {
    float: right;
    color: var(--primary);
    font-weight: bold;
}

.btn-reset {
    width: 100%;
    padding: 8px;
    background: #444;
    border: none;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
}

.btn-clear-chat {
    background: #1a1a1a;
    font-size: 11px;
    padding: 8px 12px;
    min-width: auto;
    align-self: flex-start;
    color: #eee;
    border: 1px solid #c0392b;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-clear-chat:hover {
    background: #c0392b;
    color: white;
}

/* FICHA TIPO D&D - ESTRUTURA PRINCIPAL */
.sheet-container {
    padding: 30px;
    background: #0f0f0f;
    min-height: 100vh;
    box-sizing: border-box;
}

.sheet-locked input, 
.sheet-locked textarea {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    cursor: default;
    padding-left: 0;
}

.sheet-locked #view-notes textarea,
.sheet-locked #view-campaign textarea {
    background: rgba(255, 255, 255, 0.02) !important;
}

.sheet-locked .mod-main, 
.sheet-locked .score-sub {
    color: var(--primary) !important;
    font-weight: bold;
}

.dnd-grid {
    display: grid;
    grid-template-columns: 120px 300px 1fr 280px;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.sheet-header {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.5fr 3fr;
    gap: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.header-box {
    background: #1a1a1a;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #333;
}

.header-box label {
    font-size: 10px;
    color: var(--primary);
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

/* COLUNA DE ATRIBUTOS */
.attr-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attr-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 15px 5px;
    gap: 2px;
    width: 100px; 
    height: 80px; /* Ajustado para caber o label e inputs */
    justify-content: space-around;
}

.attr-box label {
    font-size: 9px;
    color: #aaa;
    margin-bottom: 2px;
}

.attr-box input {
    width: 60px;
    font-size: 24px;
    text-align: center;
    background: none;
    border: none;
    color: white;
    font-weight: bold;
    outline: none;
}

/* HP BAR */
.hp-bar-container {
    width: 100%;
    height: 14px;
    background: #1a1a1a;
    border-radius: 7px;
    border: 1px solid #333;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
    display: flex;
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: #2ecc71;
    transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s;
    z-index: 2;
}

.hp-temp-fill {
    height: 100%;
    width: 0%;
    background: #f1c40f;
    transition: width 0.5s ease;
    box-shadow: -2px 0 10px rgba(241, 196, 15, 0.4);
    z-index: 1;
}

/* PERÍCIAS */
.skill-item {
    display: flex;
    align-items: center;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#skills-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
}

#insp, #prof {
    width: 120px !important;
    height: 40px !important;
    font-size: 18px !important;
    background: rgba(255, 255, 255, 0.1);
}

#saves-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mod-num-fixed {
    width: 40px !important;
    height: 24px !important;
    text-align: center;
    margin: 0 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    flex-shrink: 0;
}

.mod-main {
    width: 100%;
    height: 30px;
    font-size: 20px !important;
    text-align: center;
    background: transparent;
    border: none;
    color: #fff;
    font-weight: bold;
}

.score-sub {
    width: 40px;
    height: 18px;
    font-size: 11px !important;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    border-radius: 4px;
    color: #888;
    margin-top: 2px;
}

.score-badge {
    background: #222;
    border: 1px solid #666;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: -5px;
}

.score-small {
    width: 100%;
    background: transparent;
    border: none;
    color: #aaa;
    text-align: center;
    font-size: 12px;
}

/* COMBATE E BLOCOS */
.combat-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.combat-box input {
    text-align: center;
    font-weight: bold;
    border-radius: 8px;
    border: 2px solid var(--primary);
}

.sheet-block {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.sheet-block h4 {
    margin: 0 0 12px 0;
    font-size: 11px;
    color: var(--primary);
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.sheet-block textarea {
    width: 100%;
    resize: none;
    border: 1px solid #333;
    background: #222;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    outline: none;
    display: block;
}

/* INPUTS GERAIS */
textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #222;
    color: #ddd;
    width: 100%;
    resize: vertical;
    padding: 10px;
    border-radius: 5px;
    box-sizing: border-box;
}

input[type="text"], input[type="number"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    color: white;
    border-radius: 4px;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
}

/* ==========================================
   SISTEMA DE ZOOM DE ARTE (FLUTUANDO À ESQUERDA)
   ========================================== */

/* 1. Container que segura a foto original (miniatura) */
.monster-img-wrapper {
    transition: all 0.2s;
    position: relative; /* FUNDAMENTAL: É o ponto de referência do zoom */
    display: inline-block;
    cursor: zoom-in;
}

/* 2. O Overlay de Zoom (A caixa que surge) */
.monster-zoom-overlay {
    display: none; /* Escondido por padrão */
    position: absolute; /* Ancorado à div da miniatura */
    
    /* CENTRALIZAÇÃO VERTICAL */
    top: 50%;
    transform: translateY(-50%); /* Centraliza verticalmente em relação à foto original */
    
    /* NOVA POSIÇÃO: À ESQUERDA (Jogado para fora da miniatura) */
    right: calc(100% + 15px); /* Move 100% para a esquerda + 15px de respiro */
    
    z-index: 5000; /* Fica na frente de TUDO */
    
    /* Estilo do Painel de Arte */
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid var(--primary); /* Borda com a cor do tema */
    border-radius: 12px;
    padding: 8px;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.9); /* Sombra pesada para a esquerda */
    
    pointer-events: none; /* Evita que o hover quebre se o mouse mover rápido */
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* 3. A Imagem Ampliada dentro do Overlay */
.monster-zoom-overlay img {
    /* Define o tamanho da imagem de zoom (não muito grande para não quebrar a tela) */
    max-width: 550px;  /* Tamanho grande, mas que cabe à esquerda do bestiário */
    max-height: 550px; /* Limite de altura */
    
    display: block;
    border-radius: 6px;
    object-fit: contain; /* Garante que a imagem não estique */
}

/* 4. Gatilho de Ativação (Hover) */
.monster-img-wrapper:hover .monster-zoom-overlay {
    display: block;
    opacity: 1;
}

/* 5. Efeito visual na miniatura original ao passar o mouse */
.monster-img-wrapper:hover #m-image {
    border-color: var(--primary);
    filter: brightness(1.2);
}

/* ==========================================
   AJUSTE PARA MOBILE (RESPONSIVIDADE)
   ========================================== */
@media (max-width: 768px) {
    /* No celular, o zoom para o lado não funciona. Melhor centralizar na tela. */
    .monster-zoom-overlay {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%) scale(0.9);
        width: 90vw;
        max-width: 90vw;
    }
    
    .monster-zoom-overlay img {
        max-width: 100%;
        max-height: 70vh;
    }
}

/* TOASTS */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: none;
    animation: slideInUp 0.3s ease;
}

.toast {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--panel);
    border: 1px solid #2ecc71;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
}

/* ANIMAÇÕES */
@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==========================================
   AJUSTES DE RESPONSIVIDADE (MOBILE)
   ========================================== */
@media (max-width: 850px) {
    body {
        flex-direction: column; /* Sidebar vai para o topo */
    }

    #sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding-top: 0;
        justify-content: space-around;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav-item {
        margin-bottom: 0;
    }

    .dnd-grid {
        grid-template-columns: 1fr; /* Tudo vira uma coluna só */
        padding: 10px;
    }

    .sheet-header {
        grid-template-columns: 1fr;
    }

    .attr-col {
        display: grid;
        grid-template-columns: repeat(3, 1fr); /* 3 atributos por linha no mobile */
        gap: 10px;
        width: 100%;
    }

    .attr-box {
        width: 100%;
    }

    #ui-dice-box {
        width: 90%;
        bottom: 10px;
        padding: 10px;
    }

    .dice-btn {
        flex: 1 1 30%;
        min-width: 50px;
    }

    #side-panel {
        position: relative;
        width: 100%;
        left: 0;
        top: 0;
        padding: 10px;
    }
    
    /* Prevenção de Zoom no Mobile */
    input, textarea {
        font-size: 16px !important;
    }
}