/* ==========================================================================
   DESIGN PREMIUM (TRIPLE-A) - QUADRO DE MISSÕES DA GUILDA
   ========================================================================== */
:root {
    --rpg-bg-dark: #120e0a;
    --rpg-bg-panel: #261c14;
    --rpg-border-color: #3e2723;
    --rpg-accent-purple: #8d6e63;
    --rpg-accent-glow: rgba(141, 110, 99, 0.4);
    --rpg-gold: #d4af37;
    --rpg-gold-glow: rgba(212, 175, 55, 0.5);
    --rpg-text-main: #e8dcc4;
    /* Tom de pergaminho */
    --rpg-text-muted: #a69b85;
    --rpg-font: 'Georgia', serif;
}

#app-missoes {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: radial-gradient(circle at center, rgba(30, 20, 15, 0.8) 0%, rgba(10, 5, 0, 0.95) 70%),
        url('https://www.transparenttextures.com/patterns/black-scales.png');
    background-blend-mode: multiply;
    color: var(--rpg-text-main);
    font-family: var(--rpg-font);
    overflow: hidden;
    position: relative;
}

/* Scrollbars Customizados */
#app-missoes ::-webkit-scrollbar {
    width: 8px;
}

#app-missoes ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

#app-missoes ::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #3e2723, #5d4037);
    border: 1px solid var(--rpg-gold);
    border-radius: 4px;
}

#app-missoes ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #5d4037, #8d6e63);
}

/* ================== CABEÇALHO E FILTROS ================== */
.missoes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--rpg-bg-dark) 0%, var(--rpg-bg-panel) 100%),
        url('https://img.freepik.com/free-photo/dark-brown-wooden-textured-background_53876-128489.jpg');
    background-size: cover;
    background-blend-mode: overlay;
    padding: 20px 25px;
    border-bottom: 3px solid var(--rpg-border-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 10;
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
}

.missoes-header::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 10px;
    right: 10px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--rpg-gold), transparent);
    opacity: 0.3;
}

.missoes-filtros {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.m-btn {
    background: linear-gradient(to bottom, #3e2723, #1f1412);
    border: 1px solid var(--rpg-border-color);
    color: var(--rpg-text-muted);
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-family: var(--rpg-font);
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px #000;
}

.m-btn:hover {
    background: linear-gradient(to bottom, #5d4037, #2a1b12);
    color: var(--rpg-text-main);
    border-color: var(--rpg-gold);
    box-shadow: 0 0 10px var(--rpg-gold-glow);
    transform: translateY(-2px);
}

.m-ativo {
    background: linear-gradient(to bottom, #5d4037, #3e2723);
    color: var(--rpg-gold);
    border-color: var(--rpg-gold);
    box-shadow: 0 0 15px var(--rpg-gold-glow), inset 0 0 5px rgba(255, 255, 255, 0.1);
}

/* ================== LAYOUT PRINCIPAL ================== */
.missoes-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Lista Lateral Esquerda */
.missoes-lista {
    flex: 0 0 340px;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(18, 14, 10, 0.95) 0%, rgba(38, 28, 20, 0.9) 100%);
    backdrop-filter: blur(10px);
    border-right: 3px solid var(--rpg-border-color);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.9), inset -2px 0 5px rgba(212, 175, 55, 0.1);
    z-index: 5;
    padding-top: 10px;
}

/* Painel Principal de Detalhes */
.missoes-detalhe {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
    background: radial-gradient(circle at center, rgba(30, 20, 15, 0.4) 0%, rgba(10, 5, 0, 0.7) 100%),
        url('https://www.transparenttextures.com/patterns/black-paper.png');
    background-blend-mode: multiply;
}

.placeholder-missao {
    text-align: center;
    color: #555;
    font-style: italic;
    font-size: 16px;
    margin-top: 20%;
}

/* ================== CARDS DE MISSÃO (LISTA LATERAL) ================== */
.missao-card {
    background: linear-gradient(135deg, rgba(38, 28, 20, 0.4) 0%, rgba(18, 14, 10, 0.6) 100%);
    margin: 8px 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.missao-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--status-color, #444);
    transition: width 0.3s ease;
}

.missao-card:hover {
    background: linear-gradient(90deg, rgba(93, 64, 55, 0.3), rgba(18, 14, 10, 0.8));
    border-color: var(--rpg-gold);
    transform: translateX(5px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8), 0 0 10px var(--rpg-gold-glow);
}

.missao-card:hover::before {
    width: 6px;
}

.missao-card h4 {
    margin: 0;
    color: var(--rpg-text-main);
    font-size: 15px;
    font-family: var(--rpg-font);
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

.missao-card:hover h4 {
    color: var(--rpg-gold);
}

.tag-cat {
    background: rgba(38, 28, 20, 0.8);
    color: var(--rpg-gold);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--rpg-border-color);
    box-shadow: 0 2px 4px #000;
    font-size: 9px;
    font-weight: bold;
}

.tag-status {
    background: rgba(0, 0, 0, 0.5);
    color: var(--rpg-text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #333;
    box-shadow: 0 2px 4px #000;
    font-size: 9px;
}


/* ================== VISUALIZAÇÃO DO CONTRATO ================== */
.quest-view {
    max-width: 900px;
    margin: 0 auto;
}

.q-titulo {
    font-size: 38px;
    color: var(--rpg-gold);
    margin: 0 0 5px 0;
    font-family: var(--rpg-font);
    text-shadow: 2px 2px 5px #000, 0 0 20px var(--rpg-gold-glow);
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--rpg-border-color);
    padding-bottom: 15px;
}

.q-meta {
    font-size: 12px;
    color: var(--rpg-text-muted);
    margin-bottom: 25px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

.q-meta b {
    color: var(--rpg-text-main);
}

/* Texto Rico da Missão (O Pergaminho) */
#app-missoes .rich-text-body {
    font-size: 15px;
    line-height: 1.7;
    color: #3e2723;
    /* Darker text for readability on light parchment */
    margin-bottom: 30px;
    background: #e8dcc4;
    /* Light parchment color */
    background-image: url('https://www.transparenttextures.com/patterns/old-paper.png');
    padding: 30px;
    border-radius: 4px;
    border: 1px solid #c4b496;
    border-left: 8px solid var(--rpg-gold);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 0 40px rgba(0, 0, 0, 0.1);
    font-family: var(--rpg-font);
    position: relative;
}

#app-missoes .rich-text-body::after {
    content: '📜';
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 20px;
    opacity: 0.2;
}

#app-missoes .rich-text-body img {
    max-width: 100%;
    border: 4px solid #fff;
    border-radius: 2px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    margin: 20px 0;
}

#app-missoes .rich-text-body h1,
#app-missoes .rich-text-body h2 {
    color: #5d4037;
    margin-top: 0;
    border-bottom: 1px solid rgba(62, 39, 35, 0.2);
    padding-bottom: 10px;
    font-family: var(--rpg-font);
}

#app-missoes .rich-text-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.3);
}

#app-missoes .rich-text-body td,
#app-missoes .rich-text-body th {
    border: 1px solid #c4b496;
    padding: 12px;
    text-align: left;
}

#app-missoes .rich-text-body th {
    background: #c4b496;
    color: #3e2723;
}

/* Caixas de Recompensa e Grupo */
.q-recompensas,
.q-party {
    background: linear-gradient(135deg, #261c14, #120e0a);
    padding: 25px;
    border-radius: 4px;
    margin-bottom: 25px;
    border: 1px solid var(--rpg-border-color);
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 5px 15px rgba(0, 0, 0, 0.6);
}

.q-recompensas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to bottom, var(--rpg-gold), #b8860b);
    border-radius: 4px 0 0 4px;
}

.q-party::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to bottom, #4fc3f7, #0288d1);
    border-radius: 4px 0 0 4px;
}

.q-recompensas h3,
.q-party h3 {
    margin: 0 0 20px 0;
    color: var(--rpg-gold);
    font-size: 16px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: var(--rpg-font);
}

.q-party p {
    color: var(--rpg-text-muted);
    font-style: italic;
    font-size: 14px;
    margin: 0;
}

.q-rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.q-rec-grid div {
    background: linear-gradient(to bottom, #1a1510, #0d0a08);
    padding: 15px;
    border: 1px solid #3e2723;
    border-radius: 4px;
    text-align: center;
    font-family: var(--rpg-font);
    font-size: 14px;
    font-weight: bold;
    color: var(--rpg-text-main);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.q-rec-grid div b {
    display: block;
    color: var(--rpg-gold);
    margin-bottom: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Botões e Ações */
.q-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    border-top: 1px dashed #444;
    padding-top: 25px;
    flex-wrap: wrap;
}

.gm-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-family: sans-serif;
    text-transform: uppercase;
    font-size: 12px;
    transition: 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6);
}

.gm-btn:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.gm-btn-gold {
    background: linear-gradient(to bottom, var(--rpg-gold), #b8860b);
    color: #000;
    text-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.gm-btn-red {
    background: linear-gradient(to bottom, #f44336, #b71c1c);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.gm-btn-purple {
    background: linear-gradient(to bottom, #ab47bc, #6a1b9a);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.player-btn-accept {
    background: linear-gradient(to bottom, #4caf50, #1b5e20);
    color: #fff;
    border: 2px solid #81c784;
    padding: 18px 30px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    width: 100%;
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.2);
    font-family: var(--rpg-font);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.player-btn-accept:hover {
    transform: scale(1.02) translateY(-3px);
    box-shadow: 0 15px 40px rgba(76, 175, 80, 0.4);
    filter: brightness(1.2);
}

.player-accepted-badge {
    background: rgba(0, 77, 64, 0.8);
    color: #80cbc4;
    padding: 15px;
    text-align: center;
    width: 100%;
    font-weight: bold;
    border-radius: 4px;
    border: 1px dashed #4db6ac;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-sizing: border-box;
}

.quest-finished-badge {
    background: linear-gradient(45deg, #4a0000, #b71c1c);
    color: #ffcdd2;
    padding: 15px;
    text-align: center;
    width: 100%;
    font-weight: bold;
    border-radius: 4px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-sizing: border-box;
    box-shadow: inset 0 0 20px #000;
    border: 1px solid #ff5252;
}

.quest-warning-box {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid #ff9800;
    color: #ffb74d;
    padding: 15px;
    text-align: center;
    width: 100%;
    border-radius: 4px;
    font-style: italic;
    box-sizing: border-box;
}


/* ================== EDITOR DE MISSÕES DO MESTRE ================== */
.quest-editor-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 900px;
    margin: 0 auto;
}

.qe-input {
    background: rgba(0, 0, 0, 0.6);
    color: var(--rpg-gold);
    border: 1px solid var(--rpg-border-color);
    padding: 12px;
    border-radius: 4px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
    font-family: var(--rpg-font);
    outline: none;
    box-shadow: inset 0 0 10px #000;
    transition: border-color 0.3s;
}

.qe-input:focus {
    border-color: var(--rpg-gold);
    background: rgba(0, 0, 0, 0.8);
}

.rt-toolbar {
    display: flex;
    gap: 5px;
    background: linear-gradient(to bottom, #3e2723, #1a1510);
    padding: 10px;
    border-radius: 4px 4px 0 0;
    flex-wrap: wrap;
    border: 1px solid var(--rpg-border-color);
}

.rt-toolbar button {
    background: #261c14;
    border: 1px solid var(--rpg-border-color);
    color: var(--rpg-text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 3px;
    font-family: var(--rpg-font);
    font-size: 12px;
    transition: 0.2s;
}

.rt-toolbar button:hover {
    background: var(--rpg-gold);
    color: #000;
}

.rt-editor {
    background: #e8dcc4;
    background-image: url('https://www.transparenttextures.com/patterns/old-paper.png');
    border: 2px solid var(--rpg-border-color);
    padding: 25px;
    min-height: 300px;
    border-radius: 0 0 4px 4px;
    outline: none;
    color: #3e2723;
    font-family: var(--rpg-font);
    font-size: 16px;
    line-height: 1.6;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.1);
}

.rt-editor:focus {
    border-color: var(--rpg-gold);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1), 0 0 10px var(--rpg-gold-glow);
}

.qe-recompensas-box {
    background: linear-gradient(135deg, #1a1510, #0d0a08);
    padding: 20px;
    border-radius: 4px;
    border: 1px solid var(--rpg-border-color);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
}

.qe-recompensas-box h4 {
    margin: 0 0 15px 0;
    color: var(--rpg-gold);
    text-transform: uppercase;
    font-size: 14px;
    font-family: var(--rpg-font);
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 5px;
}


/* ================== COMPATIBILIDADE MOBILE / TABLET ================== */
@media (max-width: 1024px) {
    .missoes-lista {
        flex: 0 0 280px;
    }
}

@media (max-width: 900px) {
    .missoes-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    .missoes-lista {
        flex: none;
        width: 100%;
        border-right: none;
        border-bottom: 3px solid var(--rpg-border-color);
        max-height: 250px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }

    .missoes-detalhe {
        flex: none;
        width: 100%;
        padding: 20px;
    }

    .q-titulo {
        font-size: 28px;
    }

    .q-actions {
        flex-direction: column;
    }

    .gm-quest-controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
}

/* ================== MÁGICA: MODO DE ESCRITA PROFUNDA (MAGIC FOCUS) ================== */
#app-missoes:has(.rt-editor:focus) .missoes-header,
#app-missoes:has(.rt-editor:focus) .missoes-lista,
#app-missoes:has(.rt-editor:focus) .qe-recompensas-box,
#app-missoes:has(.rt-editor:focus) h3 {
    opacity: 0.1;
    pointer-events: none;
    filter: blur(2px);
    transition: 0.5s ease;
}

#app-missoes:has(.rt-editor:focus) .missoes-detalhe {
    padding-top: 0;
    transition: 0.5s ease;
}

#app-missoes:has(.rt-editor:focus) .quest-editor-container {
    transform: translateY(-20px);
    transition: 0.5s ease;
}