/* =================================================== */
/* === DIGYO PORTAL - ESTILO GLOBAL v3.2 (GRID FIX) === */
/* =================================================== */

:root {
    --bg-body: #f5f5f5;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --primary: #425ff0;
    --primary-hover: #5a00d6;
    --accent: #ff0080;
    --text-main: #171717;
    --text-muted: #575757;
    --text-header: #444444;
    --border: #e5e5e5;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-left: 240px;
    --sidebar-right: 320px; /* Levemente mais larga para widgets */
    --container-max: 1280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul, ol { list-style: none; }

/* === HEADER === */
.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    height: 70px;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.header-container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; color: #000;
    display: flex; align-items: center; gap: 2px; z-index: 1002;
}
.logo span { color: var(--primary); }

/* Navegação Desktop */
.nav-desktop { display: flex; gap: 1rem; align-items: center; }
.nav-item { position: relative; }
.nav-link {
    font-weight: 600; color: var(--text-header); padding: 8px 14px; border-radius: var(--radius);
    display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: 0.95rem;
}
.nav-link:hover { background: #f0f0f0; color: var(--primary); }
.nav-link i.fa-chevron-down { font-size: 0.7rem; opacity: 0.6; }

/* Mega Menu Desktop */
.mega-menu {
    position: absolute; top: 100%; left: -20px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1); min-width: 680px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    padding: 20px; opacity: 0; visibility: hidden;
    transform: translateY(10px); transition: 0.2s ease; z-index: 1100;
}
.nav-item:hover .mega-menu { opacity: 1; visibility: visible; transform: translateY(5px); }

.mega-item { display: flex; align-items: flex-start; gap: 15px; padding: 12px; border-radius: var(--radius); transition: 0.2s; }
.mega-item:hover { background: #f9f9f9; }
.mega-item:hover h4 { color: var(--primary); }
.mega-icon { width: 36px; height: 36px; background: #f0f0f0; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 1.1rem; flex-shrink: 0; }
.mega-text h4 { font-size: 0.95rem; font-weight: 700; margin: 0; color: #333; line-height: 1.2; margin-bottom: 2px; }
.mega-text p { font-size: 0.8rem; color: var(--text-muted); margin: 0; line-height: 1.3; }

.btn-header { background: var(--primary); color: #fff; padding: 8px 20px; border-radius: 50px; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; }
.btn-header:hover { background: var(--primary-hover); transform: translateY(-1px); }

/* === LAYOUT GRID (PADRÃO 3 COLUNAS) === */
.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-left) 1fr var(--sidebar-right);
    gap: 1.5rem;
    max-width: var(--container-max);
    margin: 2rem auto;
    padding: 0 1rem;
    align-items: start;
    width: 100%;
}

/* --- COLUNA ESQUERDA (STICKY) --- */
.left-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 90px;
    height: fit-content;
    z-index: 900;
}

.side-link {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 4px; border-radius: 8px; color: var(--text-muted); font-weight: 500; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); position: relative;
}
.side-link:hover { background: #fff; color: var(--primary); transform: translateX(5px); box-shadow: var(--shadow-sm); }
.side-link.active { background: #fff; color: var(--primary); font-weight: 700; box-shadow: var(--shadow-sm); border-left: 4px solid var(--primary); }
.icon-box { width: 24px; display: flex; justify-content: center; transition: transform 0.2s; }
.side-link:hover .icon-box { transform: scale(1.1); }
.section-header { font-size: 0.85rem; font-weight: 700; color: #888; margin: 20px 0 10px 12px; text-transform: uppercase; }

/* Feed Tabs */
.feed-tabs { display: flex; gap: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.tab { font-weight: 600; color: var(--text-muted); padding: 8px 12px; border-radius: var(--radius); }
.tab:hover { color: var(--primary); background: #fff; }
.tab.active { color: #000; font-weight: 800; border-bottom: 3px solid var(--primary); border-radius: 0; }

/* Post Card */
.post-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 1.5rem; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #d1d1d1; }
.post-cover { width: 100%; height: 180px; background: #eee; object-fit: cover; }
.post-body { padding: 25px; }
.post-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; display: flex; gap: 10px; font-weight: 500; }
.tag { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
.post-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 10px; line-height: 1.3; color: #111; }
.post-excerpt { color: var(--text-muted); font-size: 1.05rem; line-height: 1.6; }

/* Widgets */
.widget-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 1.5rem; }
.widget-title { font-size: 1rem; font-weight: 800; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; text-transform: uppercase; letter-spacing: 0.5px; color: #888; }
.tool-mini { display: flex; align-items: center; gap: 15px; padding: 12px 0; border-bottom: 1px solid #f5f5f5; }
.tool-mini:last-child { border-bottom: none; }
.tool-mini:hover .tool-name { color: var(--primary); }
.tool-mini-icon { width: 42px; height: 42px; background: #f8f9fa; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #333; font-size: 1.2rem; }
.tool-name { font-weight: 700; font-size: 0.95rem; margin: 0; color: #333; }
.tool-desc { font-size: 0.8rem; color: #666; margin: 0; }

/* --- MENU MOBILE --- */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; color: #333; cursor: pointer; margin-right: 15px; }
.mobile-drawer { position: fixed; top: 0; left: 0; width: 80%; max-width: 300px; height: 100%; background: #fff; z-index: 2000; transform: translateX(-100%); transition: transform 0.3s ease; box-shadow: 0 0 50px rgba(0,0,0,0.2); padding: 20px; overflow-y: auto; }
.mobile-drawer.active { transform: translateX(0); }
.mobile-overlay-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1999; opacity: 0; visibility: hidden; transition: 0.3s; }
.mobile-overlay-bg.active { opacity: 1; visibility: visible; }
.mobile-nav-group { margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 20px; }
.mobile-nav-title { font-size: 0.8rem; text-transform: uppercase; color: #999; font-weight: 700; margin-bottom: 10px; }
.mobile-nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; color: #333; font-weight: 500; font-size: 1rem; }
.mobile-nav-item i { width: 24px; text-align: center; color: var(--primary); }
.mobile-nav-item:active { background: #f5f5f5; }

/* --- MODO FERRAMENTAS (FULL WIDTH FIX) --- */
/* Aqui está a correção: Forçamos 2 colunas com !important */

.tools-mode .left-sidebar {
    display: none !important; /* Garante que sumiu */
}

.tools-mode .main-layout {
    /* 1fr = Espaço livre (App), 320px = Sidebar Direita (Widgets) */
    grid-template-columns: 1fr 320px !important;
    max-width: 1400px; /* Permite crescer mais */
}

.tools-back-btn {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px;
    color: var(--text-muted); font-weight: 600; text-decoration: none;
    padding: 8px 15px; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 50px; transition: 0.2s;
}
.tools-back-btn:hover { background: #f3f4f6; color: var(--primary); border-color: var(--primary); }

/* Proteção de Anúncios */
.ad-slot { display: flex; justify-content: center; align-items: center; max-width: 100%; overflow: hidden; background: #f9f9f9; }
.ad-slot.ad-square { max-width: 300px; min-height: 250px; margin: 0 auto 20px; }
.ad-slot.ad-horizontal { min-height: 90px; width: 100%; }

/* --- RESPONSIVO GERAL --- */
@media (max-width: 1024px) {
    .main-layout { grid-template-columns: 200px 1fr; }
    .right-sidebar { display: none; }
    
    /* No tablet/mobile, Tools Mode vira coluna única */
    .tools-mode .main-layout { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
    .main-layout { grid-template-columns: 100%; display: block; padding: 0 15px; }
    .left-sidebar, .nav-desktop, .right-sidebar { display: none; }
    .mobile-menu-btn { display: block; }
    .header-container { padding: 0 15px; }
    .logo { font-size: 1.4rem; }
    .post-card, .widget-card { width: 100%; margin-left: 0; margin-right: 0; }
    .ad-slot.ad-horizontal { min-height: 90px; }
}