/* ================== DO ARQUIVO INDEX.PHP ==================== */

/* ================= ESTILO GERAL ================= */
* { box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, sans-serif; margin: 0; padding: 0; background: #f2f2f2; color: #333; }

/* ================= HEADER ================= */
header { padding: 15px; text-align: center; background: #120f0e; color: white; border-bottom: 3px solid #ff6f61; }
header img { width: 50%; max-width: 400px; border-radius: 4px; transition: width 0.3s; }
header a { color: #1976d2; text-decoration: underline; cursor: pointer; }
header p { margin: 5px 0; font-size: 0.95rem; }

/* ================= LAYOUT ================= */
.container { max-width: 1200px; margin: 0 auto; padding: 15px; }

/* ================= BUSCA ================= */
.search-box { display: flex; justify-content: center; gap: 5px; margin-bottom: 20px; }
.search-box form { display: flex; width: 100%; max-width: 500px; }
.search-box input[type="text"] { padding: 12px; flex-grow: 1; border: 1px solid #ddd; border-radius: 5px 0 0 5px; outline: none; }
.search-box button { padding: 12px 20px; background: #ff6f61; border: none; color: white; cursor: pointer; border-radius: 0 5px 5px 0; font-weight: bold; }

/* ================= BOTÕES ================= */
.action-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 20px; }
.action-buttons button { padding: 10px 15px; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; color: white; font-size: 0.9rem; transition: opacity 0.2s; }
.action-buttons button:hover { opacity: 0.9; }
.action-buttons .sorte { background: #ff6f61; }
.action-buttons .casinha { background: #6aa84f; }
.action-buttons .excluirimg { background: #f50000; }
.action-buttons .compartilhar { background: #4CAF50; }
.action-buttons .inicio { background: #2196F3; }

/* ================= GALERIA ================= */
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.gallery-item { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); text-align: center; padding-bottom: 10px; }
.gallery-item img { width: 100%; height: auto; display: block; aspect-ratio: 1 / 1; object-fit: cover; cursor: pointer; }
.caption { padding: 10px 5px; font-weight: bold; font-size: 0.9rem; color: #444; word-wrap: break-word; }
.gallery-item button { margin: 3px; padding: 6px 12px; background: #ff6f61; color: white; border: none; cursor: pointer; border-radius: 4px; font-size: 0.8rem; }
.report-btn { background: #e74c3c !important; }

/* Tags */
.tags { margin: 5px 0 10px 0; padding: 0 5px; }
.tag { display: inline-block; background: #f0f0f0; color: #555; padding: 3px 8px; border-radius: 10px; font-size: 11px; margin: 2px; text-decoration: none; }

/* ================= PAGINAÇÃO ================= */
.pagination { text-align: center; margin: 15px 0 5px 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; }
.pagination a { display: inline-block; padding: 8px 12px; background: white; color: #333; border-radius: 5px; text-decoration: none; border: 1px solid #ddd; }
.pagination a.active { background: #ff6f61; color: white; border-color: #ff6f61; }
.pagination form { display: flex; gap: 5px; margin-left: 10px; }

/* ================= MODAL ================= */
#modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); }
#modal .modal-content { background: #fff; width: 90%; max-width: 600px; margin: 5% auto; padding: 20px; border-radius: 8px; position: relative; }
#modal .fechar { position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; color: #333; cursor: pointer; }


/* ======================== DO ARQUIVO exibirB.php ==================== */

/* ================= MODO VIEWER (exibirB.php) ================= */
body.viewer-mode { 
    margin: 0; padding: 0; height: 100vh; background: #000; 
    font-family: Arial, sans-serif; display: flex; flex-direction: column; overflow: hidden; 
}

.viewer-mode .viewer { 
    flex: 1; display: flex; justify-content: center; align-items: center; 
    overflow: hidden; position: relative; width: 100%; height: 100%; 
}
.viewer-mode .viewer img { 
    max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; 
    cursor: grab; transform-origin: center center; 
}
.viewer-mode .viewer img:active { cursor: grabbing; }

/* Botões da Toolbar */
.viewer-mode .toolbar {
    display: flex; justify-content: center; gap: 10px; padding: 10px; 
    background: rgba(0,0,0,0.6); position: fixed; bottom: 0; 
    width: 100%; box-sizing: border-box; z-index: 999;
}
.viewer-mode .toolbar button, .viewer-mode .toolbar a {
    padding: 4px 10px; font-size: 13px; border: none; border-radius: 4px; 
    cursor: pointer; color: white; text-decoration: none; transition: 0.3s;
}
.viewer-mode .toolbar button:hover, .viewer-mode .toolbar a:hover { opacity: 0.85; }
.viewer-mode .copy-btn { background: #3498db; }
.viewer-mode .zoom-btn { background: #2ecc71; }
.viewer-mode .delete-btn { background: #e74c3c; }

/* Animação Botão Artigo */
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 111, 97, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 111, 97, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 111, 97, 0); }
}
.viewer-mode .btn-artigo { background: #ff6f61; font-weight: bold; animation: pulse 2s infinite; }

/* Legenda do Viewer */
.viewer-mode .caption-container {
    position: absolute; bottom: 70px; width: 100%; display: flex; 
    flex-direction: column; align-items: center; pointer-events: none; z-index: 500;
}
/* Note que agora tem .viewer-mode antes do .caption para não quebrar a galeria */
.viewer-mode .caption { 
    color: white; font-size: 18px; text-shadow: 2px 2px 4px #000; 
    padding: 5px 10px; background: rgba(0,0,0,0.3); border-radius: 8px; 
    margin-bottom: 5px; max-width: 90%; text-align: center;
}

/* Setas laterais */
.viewer-mode .arrow {
    position: absolute; top: 50%; transform: translateY(-50%); font-size: 40px; 
    color: white; background: rgba(0,0,0,0.3); padding: 12px; 
    border-radius: 50%; cursor: pointer; user-select: none; z-index: 100; text-decoration: none;
}
.viewer-mode .arrow:hover { background: rgba(0,0,0,0.6); }
.viewer-mode .arrow-left { left: 10px; }
.viewer-mode .arrow-right { right: 10px; }

/* Painel Lateral de Artigos */
.viewer-mode .sidebar-artigo {
    position: fixed; top: 0; right: -450px; width: 400px; height: 100%;
    background: rgba(18, 18, 18, 0.95); color: #e0e0e0;
    box-shadow: -5px 0 20px rgba(0,0,0,0.7); z-index: 1500;
    transition: right 0.3s ease-in-out; overflow-y: auto; padding: 25px;
    box-sizing: border-box; backdrop-filter: blur(10px);
}
.viewer-mode .sidebar-artigo.open { right: 0; }
.viewer-mode .fechar-sidebar { float: right; font-size: 28px; cursor: pointer; color: #888; background: none; border: none; padding: 0; }
.viewer-mode .fechar-sidebar:hover { color: #ff6f61; }
.viewer-mode .artigo-bloco { margin-bottom: 30px; }
.viewer-mode .artigo-titulo { color: #ff6f61; border-bottom: 1px solid #444; padding-bottom: 5px; margin-top: 0; }
.viewer-mode .artigo-texto { line-height: 1.6; font-size: 15px; color: #ccc; }
.viewer-mode .artigo-texto a { color: #2196F3; text-decoration: none; font-weight: bold; }
.viewer-mode .artigo-texto a:hover { text-decoration: underline; }

/* Painel Lateral IA (Esquerda) */
.viewer-mode .sidebar-ia {
    position: fixed; top: 0; left: -450px; width: 400px; height: 100%;
    background: rgba(18, 18, 18, 0.95); color: #e0e0e0;
    box-shadow: 5px 0 20px rgba(0,0,0,0.7); z-index: 1500;
    transition: left 0.3s ease-in-out; overflow-y: auto; padding: 25px;
    box-sizing: border-box; backdrop-filter: blur(10px);
}
.viewer-mode .sidebar-ia.open { left: 0; }
.viewer-mode .btn-ia { background: #8e44ad; font-weight: bold; }

.viewer-mode #conteudoIA_painel table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.viewer-mode #conteudoIA_painel th, .viewer-mode #conteudoIA_painel td { padding: 8px; border: 1px solid #444; color: #ccc; }
.viewer-mode #conteudoIA_painel th { background: #333; }


/* ================= RESPONSIVO (TELAS MENORES) ================= */
@media (max-width: 900px) { 
    .gallery { grid-template-columns: repeat(3, 1fr); } 
}

/* Juntamos todas as regras de 768px em um único bloco */
@media (max-width: 768px) {
    /* Do Index */
    header img { width: 90%; }
    .container { padding: 10px; }
    .action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .action-buttons button { width: 100%; margin: 0; padding: 12px; }
    .gallery { grid-template-columns: 1fr 1fr; gap: 10px; }
    .gallery-item img { aspect-ratio: auto; }
    .caption { font-size: 0.8rem; }
    .gallery-item button { padding: 8px; width: 90%; margin-bottom: 5px; }
    .pagination input { width: 50px; }
    
    /* Do exibirB */
    .viewer-mode .toolbar button, .viewer-mode .toolbar a { font-size: 13px; padding: 4px 10px; }
    .viewer-mode .caption { font-size: 14px; }
    .viewer-mode .sidebar-artigo { width: 100%; right: -100%; }
    .viewer-mode .sidebar-ia { width: 100%; left: -100%; }
}

@media (max-width: 600px) { 
    .gallery { grid-template-columns: repeat(2, 1fr); } 
}